2019-12-03 19:52:20 +01:00
|
|
|
<?php
|
|
|
|
namespace Misuzu;
|
|
|
|
|
2023-01-01 20:23:53 +00:00
|
|
|
use Misuzu\Config\IConfig;
|
2019-12-03 19:52:20 +01:00
|
|
|
|
2019-12-06 02:04:10 +01:00
|
|
|
final class Config {
|
2023-01-01 20:23:53 +00:00
|
|
|
private static IConfig $config;
|
2019-12-03 19:52:20 +01:00
|
|
|
|
2023-01-01 20:23:53 +00:00
|
|
|
public static function init(IConfig $config): void {
|
|
|
|
self::$config = $config;
|
2019-12-03 19:52:20 +01:00
|
|
|
}
|
|
|
|
|
2022-07-04 23:25:58 +00:00
|
|
|
public static function keys(): array {
|
2023-01-01 20:23:53 +00:00
|
|
|
return self::$config->getNames();
|
2022-07-04 23:25:58 +00:00
|
|
|
}
|
|
|
|
|
2023-01-06 20:50:41 +00:00
|
|
|
public static function get(string $key, string $type = IConfig::T_ANY, $default = null): mixed {
|
2023-01-01 20:23:53 +00:00
|
|
|
return self::$config->getValue($key, $type, $default);
|
2019-12-03 19:52:20 +01:00
|
|
|
}
|
|
|
|
|
2020-06-09 17:42:35 +00:00
|
|
|
public static function has(string $key): bool {
|
2023-01-01 20:23:53 +00:00
|
|
|
return self::$config->hasValue($key);
|
2020-06-09 17:42:35 +00:00
|
|
|
}
|
|
|
|
|
2019-12-03 19:52:20 +01:00
|
|
|
public static function set(string $key, $value, bool $soft = false): void {
|
2023-01-01 20:23:53 +00:00
|
|
|
self::$config->setValue($key, $value, !$soft);
|
2019-12-03 19:52:20 +01:00
|
|
|
}
|
2022-07-04 23:25:58 +00:00
|
|
|
|
|
|
|
public static function remove(string $key, bool $soft = false): void {
|
2023-01-01 20:23:53 +00:00
|
|
|
self::$config->removeValue($key, !$soft);
|
2022-07-04 23:25:58 +00:00
|
|
|
}
|
2019-12-03 19:52:20 +01:00
|
|
|
}
|