This commit is contained in:
xl
2023-05-26 18:26:46 +08:00
parent 74ebcbe630
commit f641cb9b82
+30
View File
@@ -48,6 +48,36 @@ class ConfigProvider
}
/**
* @param string $key
* @param mixed $value
* @return bool
*/
public function modify(string $key, mixed $value): bool
{
$keys = explode('.', $key);
$hashMap = $this->hashMap->get(array_shift($keys));
if (is_null($hashMap)) {
return false;
}
$setting = &$hashMap;
foreach ($keys as $k => $val) {
if (!is_array($val)) {
unset($setting);
return false;
}
$setting = &$setting[$k];
}
$setting = $value;
unset($setting);
return $this->get($key) == $value;
}
/**
* @param array $config
* @return void