| Conditions | 2 |
| Paths | 1 |
| Total Lines | 17 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 8 |
| CRAP Score | 2 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 12 | function partial($fn) |
||
| 13 | { |
||
| 14 | 25 | $args = array_slice(func_get_args(), 1); |
|
| 15 | 25 | $params = (new \ReflectionFunction($fn))->getNumberOfRequiredParameters(); |
|
| 16 | |||
| 17 | return function () use ($fn, $args, $params) { |
||
| 18 | 25 | $args = array_merge($args, func_get_args()); |
|
| 19 | |||
| 20 | 25 | if ($params > count($args)) { |
|
| 21 | 15 | array_unshift($args, $fn); |
|
| 22 | |||
| 23 | 15 | return call_user_func_array(__NAMESPACE__.'\partial', $args); |
|
| 24 | } |
||
| 25 | |||
| 26 | 25 | return call_user_func_array($fn, $args); |
|
| 27 | 25 | }; |
|
| 28 | } |
||
| 29 |