Conditions | 6 |
Paths | 6 |
Total Lines | 27 |
Code Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
37 | public function get($key = '', $default = null) |
||
38 | { |
||
39 | $allConfig = $this->allConfig; |
||
40 | |||
41 | if (strlen($key)) { |
||
42 | if (strpos($key, '.')) { |
||
43 | $keys = explode('.', $key); |
||
44 | $val = $allConfig; |
||
45 | foreach ($keys as $k) { |
||
46 | if (!isset($val[$k])) { |
||
47 | return $default; // 任一下标不存在就返回默认值 |
||
48 | } |
||
49 | |||
50 | $val = $val[$k]; |
||
51 | } |
||
52 | |||
53 | return $val; |
||
54 | } else { |
||
55 | if (isset($allConfig[$key])) { |
||
56 | return $allConfig[$key]; |
||
57 | } |
||
58 | |||
59 | return $default; |
||
60 | } |
||
61 | } |
||
62 | |||
63 | return $allConfig; |
||
64 | } |
||
74 | } |