| Conditions | 2 |
| Paths | 1 |
| Total Lines | 19 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 10 |
| CRAP Score | 2 |
| Changes | 3 | ||
| Bugs | 0 | Features | 2 |
| 1 | <?php |
||
| 14 | function hold(callable $fn /* ...$args */) |
||
| 15 | { |
||
| 16 | $placeholder = pipe(filter(function ($x) { |
||
| 17 | 2 | return _ === $x; |
|
| 18 | 2 | }))->pipe('array_keys'); |
|
| 19 | |||
| 20 | 2 | $args = array_slice(func_get_args(), 1); |
|
| 21 | 2 | $ks = $placeholder($args); |
|
| 22 | |||
| 23 | return function ($x) use ($fn, $args, $ks) { |
||
| 24 | 2 | if ([] === $ks) { |
|
| 25 | 2 | return call_user_func_array($fn, array_merge($args, [$x])); |
|
| 26 | } |
||
| 27 | |||
| 28 | 2 | return call_user_func_array($fn, array_replace($args, [ |
|
| 29 | 2 | $ks[0] => $x |
|
| 30 | 2 | ])); |
|
| 31 | 2 | }; |
|
| 32 | } |
||
| 33 |