优化初始化数据

This commit is contained in:
zyimm 2023-08-24 15:23:04 +08:00
parent 7417662219
commit 6d60eb4891

View File

@ -16,12 +16,19 @@ class Config
foreach ($configs as $key => $val) {
$method = 'set'.$this->camelCase($key);
if (method_exists($method, $this)) {
if (method_exists($this, $method)) {
call_user_func([$this, $method], $val);
}
}
}
private function camelCase(string $underscored)
{
return preg_replace_callback('/_([a-z])/', function ($match) {
return strtoupper($match[1]);
}, $underscored);
}
/**
* @return mixed
*/
@ -66,12 +73,4 @@ class Config
{
$this->backUrl = $backUrl;
}
private function camelCase(string $underscored)
{
return preg_replace_callback('/_([a-z])/', function ($match) {
return strtoupper($match[1]);
}, $underscored);
}
}