33 lines
661 B
PHP
Executable File
33 lines
661 B
PHP
Executable File
<?php
|
|
|
|
class Config {
|
|
private static $config = null;
|
|
|
|
private function __construct() {
|
|
}
|
|
|
|
public static function get(string $val, mixed $default = null) : mixed {
|
|
if (Config::$config == null) {
|
|
Config::$config = parse_ini_file(__DIR__ . "/../.env", false, INI_SCANNER_RAW);
|
|
}
|
|
if (array_key_exists($val, Config::$config)) {
|
|
$c = Config::$config[$val];
|
|
try {
|
|
$j = json_decode($c, false);
|
|
if ($j) return $j;
|
|
} catch (Exception $e) {
|
|
print_r($e);
|
|
}
|
|
return $c;
|
|
} else {
|
|
return $default;
|
|
}
|
|
}
|
|
|
|
public static function refresh() {
|
|
Config::$config = parse_ini_file(__DIR__ . "/../.env", false, INI_SCANNER_RAW);
|
|
}
|
|
|
|
}
|
|
|