| Conditions | 1 |
| Paths | 1 |
| Total Lines | 20 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 9 |
| CRAP Score | 1 |
| Changes | 0 | ||
| 1 | <?php |
||
| 12 | function cond(array $pairs): \Closure |
||
| 13 | { |
||
| 14 | return function ($x) use ($pairs) { |
||
| 15 | 3 | $pair = head($pairs); |
|
| 16 | |||
| 17 | $lazyfn = function ($x) use ($pairs) { |
||
| 18 | 2 | $xs = tail($pairs); |
|
| 19 | 2 | return cond($xs)($x); |
|
| 20 | 3 | }; |
|
| 21 | |||
| 22 | $throw = function() { |
||
| 23 | 1 | throw new \InvalidArgumentException(); |
|
| 24 | 3 | }; |
|
| 25 | |||
| 26 | 3 | return ifElse($pair[0] ?? $throw()) |
|
| 27 | 3 | ($pair[1] ?? $throw()) |
|
| 28 | ($lazyfn) |
||
| 29 | ($x); |
||
| 30 | 3 | }; |
|
| 31 | } |
||
| 32 |