From deb6810b56a386f3177ccdd5b04a0801b4d67478 Mon Sep 17 00:00:00 2001 From: Jay Trees Date: Sat, 11 May 2024 18:26:27 +0200 Subject: [PATCH] refactor: create config class --- index.php | 6 ++---- src/classes/wishthis/Config.php | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 src/classes/wishthis/Config.php diff --git a/index.php b/index.php index 83f87e14..ef062bfa 100644 --- a/index.php +++ b/index.php @@ -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 diff --git a/src/classes/wishthis/Config.php b/src/classes/wishthis/Config.php new file mode 100644 index 00000000..9b61a5b6 --- /dev/null +++ b/src/classes/wishthis/Config.php @@ -0,0 +1,26 @@ +filePath); + } + + public function load(): bool + { + $exists = $this->exists(); + + if ($exists) { + require $this->filePath; + } + + return $exists; + } +}