| Conditions | 4 |
| Paths | 1 |
| Total Lines | 20 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 12 |
| CRAP Score | 4.0072 |
| Changes | 0 | ||
| 1 | <?php |
||
| 9 | function path() |
||
| 10 | { |
||
| 11 | $path = function (array $paths, $obj) { |
||
| 12 | 11 | return reduce( |
|
| 13 | function ($acc, $item) { |
||
| 14 | 11 | if ($acc === null) { |
|
| 15 | return null; |
||
| 16 | } |
||
| 17 | 11 | if (is_array($acc)) { |
|
| 18 | 9 | return array_key_exists($item, $acc) ? $acc[$item] : null; |
|
| 19 | } |
||
| 20 | 2 | throw new \InvalidArgumentException('path(array $paths, $obj) only support array object'); |
|
| 21 | 11 | }, |
|
| 22 | 11 | $obj, |
|
| 23 | 11 | $paths |
|
| 24 | ); |
||
| 25 | 11 | }; |
|
| 26 | 11 | $arguments = func_get_args(); |
|
| 27 | 11 | $curried = curryN($path, 2); |
|
| 28 | 11 | return call_user_func_array($curried, $arguments); |
|
| 29 | } |
||
| 47 |