Passed
Push — dev ( a28fc9...ad5e2a )
by 世昌
02:19
created

ConfigTrait::getDefaultConfig()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 8
c 2
b 0
f 0
nc 1
nop 0
dl 0
loc 10
rs 10
1
<?php
2
namespace suda\framework\debug;
3
4
trait ConfigTrait
5
{
6
    
7
    /**
8
     * 配置信息
9
     *
10
     * @var array
11
     */
12
    protected $config;
13
14
    public function applyConfig(array $config)
15
    {
16
        $defaultConfig = $this->getDefaultConfig();
17
        foreach ($defaultConfig as $name => $value) {
18
            $this->config[$name] = $config[$name] ?? $this->config[$name] ?? $value;
19
        }
20
    }
21
22
    public function getConfig(string $name)
23
    {
24
        $defaultConfig = $this->getDefaultConfig();
25
        return $this->config[$name] ?? $defaultConfig[$name];
26
    }
27
28
    abstract public function getDefaultConfig():array;
29
}
30