Passed
Push — master ( 6d8c6e...429e9a )
by Sérgio
03:55
created

unless.php ➔ unless()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 6
nc 1
nop 1
dl 0
loc 10
ccs 5
cts 5
cp 1
crap 2
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Prelude;
4
5
const unless = __NAMESPACE__.'\unless';
6
7
/**
8
 * @see http://elixir-lang.org/getting-started/case-cond-and-if.html#if-and-unless
9
 */
10
function unless(...$args)
11
{
12
    $unless = partial(function (callable $pred, callable $fail, $x) {
13 2
        return $pred($x)
14 2
            ? $x
15 2
            : $fail($x);
16 2
    });
17
18 2
    return $unless(...$args);
19
}
20