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