| Conditions | 6 |
| Paths | 5 |
| Total Lines | 18 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 6 |
| CRAP Score | 7.3329 |
| Changes | 0 | ||
| 1 | <?php |
||
| 13 | function array_get($array, $key, $default = null) |
||
| 14 | { |
||
| 15 | 6 | if (is_null($key)) return $array; |
|
| 16 | |||
| 17 | 6 | if (isset($array[$key])) return $array[$key]; |
|
| 18 | |||
| 19 | 5 | foreach (explode('.', $key) as $segment) |
|
| 20 | { |
||
| 21 | 5 | if ( ! is_array($array) || ! array_key_exists($segment, $array)) |
|
| 22 | 5 | { |
|
| 23 | 5 | return value($default); |
|
| 24 | } |
||
| 25 | |||
| 26 | $array = $array[$segment]; |
||
| 27 | } |
||
| 28 | |||
| 29 | return $array; |
||
| 30 | } |
||
| 31 | } |
||
| 42 |