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