eeprom/src/Config.php

25 lines
753 B
PHP

<?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) {
return array_key_exists($section, self::$config)
&& array_key_exists($key, self::$config[$section])
&& !empty(self::$config[$section][$key]);
}
}