| Conditions | 2 |
| Paths | 1 |
| Total Lines | 16 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 7 |
| CRAP Score | 2 |
| Changes | 3 | ||
| Bugs | 0 | Features | 3 |
| 1 | <?php |
||
| 12 | function ifelse(/* ...$args */) |
||
| 13 | { |
||
| 14 | 1 | $args = func_get_args(); |
|
| 15 | |||
| 16 | $ifelse = function (callable $condition, callable $ontrue, callable $onfalse) { |
||
| 17 | return function ($x) use ($condition, $ontrue, $onfalse) { |
||
| 18 | 1 | if ($condition($x)) { |
|
| 19 | 1 | return $ontrue($x); |
|
| 20 | } |
||
| 21 | |||
| 22 | 1 | return $onfalse($x); |
|
| 23 | 1 | }; |
|
| 24 | 1 | }; |
|
| 25 | |||
| 26 | 1 | return call_user_func_array(partial($ifelse), $args); |
|
| 27 | } |
||
| 28 |