misuzu/src/Config.php

33 lines
851 B
PHP
Raw Normal View History

2022-09-13 13:14:49 +00:00
<?php
namespace Misuzu;
2023-01-01 20:23:53 +00:00
use Misuzu\Config\IConfig;
2022-09-13 13:14:49 +00:00
final class Config {
2023-01-01 20:23:53 +00:00
private static IConfig $config;
2022-09-13 13:14:49 +00:00
2023-01-01 20:23:53 +00:00
public static function init(IConfig $config): void {
self::$config = $config;
2022-09-13 13:14:49 +00:00
}
public static function keys(): array {
2023-01-01 20:23:53 +00:00
return self::$config->getNames();
2022-09-13 13:14:49 +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);
2022-09-13 13:14:49 +00:00
}
public static function has(string $key): bool {
2023-01-01 20:23:53 +00:00
return self::$config->hasValue($key);
2022-09-13 13:14:49 +00: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);
2022-09-13 13:14:49 +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-09-13 13:14:49 +00:00
}
}