| Conditions | 8 |
| Paths | 7 |
| Total Lines | 27 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 23 | public static function get($array, $key, $default = null) |
||
| 24 | { |
||
| 25 | if (!static::accessible($array)) { |
||
| 26 | return value($default); |
||
| 27 | } |
||
| 28 | |||
| 29 | if (is_null($key)) { |
||
| 30 | return $array; |
||
| 31 | } |
||
| 32 | |||
| 33 | if (static::exists($array, $key)) { |
||
| 34 | return $array[$key]; |
||
| 35 | } |
||
| 36 | |||
| 37 | if (strpos($key, '.') === false) { |
||
| 38 | return $array[$key] ?? value($default); |
||
| 39 | } |
||
| 40 | |||
| 41 | foreach (explode('.', $key) as $segment) { |
||
| 42 | if (static::accessible($array) && static::exists($array, $segment)) { |
||
| 43 | $array = $array[$segment]; |
||
| 44 | } else { |
||
| 45 | return value($default); |
||
| 46 | } |
||
| 47 | } |
||
| 48 | |||
| 49 | return $array; |
||
| 50 | } |
||
| 73 |