2020-05-08 22:53:21 +00:00
|
|
|
<?php
|
|
|
|
namespace EEPROM;
|
|
|
|
|
|
|
|
final class Config {
|
|
|
|
private static array $config = [];
|
|
|
|
|
|
|
|
public static function load(string $path): void {
|
|
|
|
$config = parse_ini_file($path, true, INI_SCANNER_TYPED);
|
|
|
|
|
|
|
|
if(!empty($config))
|
|
|
|
self::$config = array_merge(self::$config, $config);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function get(string $section, string $key, $default = null) {
|
|
|
|
if(!self::has($section, $key))
|
|
|
|
return $default;
|
|
|
|
return self::$config[$section][$key];
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function has(string $section, string $key) {
|
2022-07-06 16:58:40 +00:00
|
|
|
return array_key_exists($section, self::$config)
|
|
|
|
&& array_key_exists($key, self::$config[$section])
|
|
|
|
&& !empty(self::$config[$section][$key]);
|
2020-05-08 22:53:21 +00:00
|
|
|
}
|
|
|
|
}
|