优化初始化数据
This commit is contained in:
parent
7417662219
commit
6d60eb4891
|
@ -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);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user