Adds ConfigLoader core class

main
Yasen Pramatarov 2025-04-24 13:49:52 +03:00
parent ed0baf18d3
commit 7dfbe49996
1 changed files with 27 additions and 0 deletions

View File

@ -0,0 +1,27 @@
<?php
namespace App\Core;
class ConfigLoader
{
/**
* Load configuration array from a set of possible file locations.
*
* @param string[] $locations
* @return array
*/
public static function loadConfig(array $locations): array
{
$configFile = null;
foreach ($locations as $location) {
if (file_exists($location)) {
$configFile = $location;
break;
}
}
if (!$configFile) {
die('Config file not found');
}
return require $configFile;
}
}