| Conditions | 2 |
| Paths | 1 |
| Total Lines | 25 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 13 |
| CRAP Score | 2 |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 10 | function each() |
||
| 11 | { |
||
| 12 | 3 | $args = func_get_args(); |
|
| 13 | |||
| 14 | $each = function (\Closure $fn, $ls) { |
||
| 15 | 3 | if ($ls instanceof \Iterator) { |
|
| 16 | iterator_apply($ls, function () use ($fn, $ls) { |
||
| 17 | $args = [ |
||
| 18 | 1 | $ls->current(), |
|
| 19 | 1 | $ls->key() |
|
| 20 | 1 | ]; |
|
| 21 | |||
| 22 | 1 | call_user_func_array($fn, $args); |
|
| 23 | 1 | return true; |
|
| 24 | 1 | }); |
|
| 25 | |||
| 26 | 1 | return $ls; |
|
| 27 | } |
||
| 28 | |||
| 29 | 2 | array_walk($ls, $fn); |
|
| 30 | 2 | return $ls; |
|
| 31 | 3 | }; |
|
| 32 | |||
| 33 | 3 | return call_user_func_array(curry($each), $args); |
|
| 34 | } |
||
| 35 |