Conditions | 2 |
Paths | 2 |
Total Lines | 10 |
Code Lines | 6 |
Lines | 0 |
Ratio | 0 % |
Tests | 5 |
CRAP Score | 2 |
Changes | 0 |
1 | <?php |
||
9 | function partial(callable $callback, ...$args) |
||
10 | { |
||
11 | 3 | $arity = (new \ReflectionFunction($callback))->getNumberOfRequiredParameters(); |
|
12 | |||
13 | 3 | return $args[$arity - 1] ?? false |
|
14 | 3 | ? $callback(...$args) |
|
15 | : function (...$rest) use ($callback, $args) { |
||
16 | 3 | return partial($callback, ...\array_merge($args, $rest)); |
|
17 | 3 | }; |
|
18 | } |
||
19 |