refactor: create config class
This commit is contained in:
parent
269b41ffa9
commit
deb6810b56
2 changed files with 28 additions and 4 deletions
|
@ -37,10 +37,8 @@ spl_autoload_register(
|
|||
* Config
|
||||
*/
|
||||
$configPath = __DIR__ . '/' . 'src/config/config.php';
|
||||
|
||||
if (file_exists($configPath)) {
|
||||
require $configPath;
|
||||
}
|
||||
$config = new Config($configPath);
|
||||
$config->load();
|
||||
|
||||
/**
|
||||
* Session
|
||||
|
|
26
src/classes/wishthis/Config.php
Normal file
26
src/classes/wishthis/Config.php
Normal file
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
|
||||
namespace wishthis;
|
||||
|
||||
class Config
|
||||
{
|
||||
public function __construct(private string $filePath)
|
||||
{
|
||||
}
|
||||
|
||||
public function exists(): bool
|
||||
{
|
||||
return \file_exists($this->filePath);
|
||||
}
|
||||
|
||||
public function load(): bool
|
||||
{
|
||||
$exists = $this->exists();
|
||||
|
||||
if ($exists) {
|
||||
require $this->filePath;
|
||||
}
|
||||
|
||||
return $exists;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue