Initial import
This commit is contained in:
Executable
+32
@@ -0,0 +1,32 @@
|
||||
<?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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user