refactor: create config class

This commit is contained in:
Jay Trees 2024-05-11 18:26:27 +02:00
parent 269b41ffa9
commit deb6810b56
2 changed files with 28 additions and 4 deletions

View file

@ -37,10 +37,8 @@ spl_autoload_register(
* Config * Config
*/ */
$configPath = __DIR__ . '/' . 'src/config/config.php'; $configPath = __DIR__ . '/' . 'src/config/config.php';
$config = new Config($configPath);
if (file_exists($configPath)) { $config->load();
require $configPath;
}
/** /**
* Session * Session

View 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;
}
}