Completed
Push — master ( a7bf70...50513b )
by Pol
25s queued 12s
created

Boolean   A

Complexity

Total Complexity 13

Size/Duplication

Total Lines 65
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 14
c 1
b 0
f 0
dl 0
loc 65
ccs 26
cts 26
cp 1
rs 10
wmc 13

13 Methods

Rating   Name   Duplication   Size   Complexity  
A CNot() 0 3 1
A isZero() 0 3 1
A COr() 0 3 1
A CFalse() 0 3 1
A gt() 0 3 1
A CXor() 0 3 1
A eq() 0 3 1
A lt() 0 3 1
A gte() 0 3 1
A CAnd() 0 3 1
A CTrue() 0 3 1
A lte() 0 3 1
A CIf() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace loophp\churchencoding;
6
7
use Closure;
8
use loophp\combinator\Combinators;
0 ignored issues
show
Bug introduced by
The type loophp\combinator\Combinators was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
10
/**
11
 * Class Boolean.
12
 *
13
 * phpcs:disable Generic.Files.LineLength.TooLong
14
 */
15
final class Boolean
16
{
17 5
    public static function CAnd(): Closure
18
    {
19 5
        return static fn (callable $l): Closure => static fn (callable $c): Closure => $l($c)(self::CFalse());
20
    }
21
22 23
    public static function CFalse(): Closure
23
    {
24 23
        return Combinators::Ki();
25
    }
26
27 5
    public static function CIf(): Closure
28
    {
29 5
        return Combinators::I();
30
    }
31
32 5
    public static function CNot(): Closure
33
    {
34 5
        return Combinators::C();
35
    }
36
37 3
    public static function COr(): Closure
38
    {
39 3
        return Combinators::M();
40
    }
41
42 22
    public static function CTrue(): Closure
43
    {
44 22
        return Combinators::K();
45
    }
46
47 3
    public static function CXor(): Closure
48
    {
49 3
        return static fn (callable $a): Closure => static fn (callable $b): Closure => ($a($b(self::CFalse())(self::CTrue())))($b(self::CTrue())(self::CFalse()));
50
    }
51
52 1
    public static function eq(): Closure
53
    {
54 1
        return static fn (callable $a): Closure => static fn (callable $b): Closure => self::CAnd()(self::lte()($a)($b))(self::lte()($b)($a));
55
    }
56
57 1
    public static function gt(): Closure
58
    {
59 1
        return static fn (callable $a): Closure => static fn (callable $b): Closure => self::CNot()(self::lte()($a)($b));
60
    }
61
62 2
    public static function gte(): Closure
63
    {
64 2
        return static fn (callable $a): Closure => static fn (callable $b): Closure => self::isZero()(Numeral::minus()($b)($a));
65
    }
66
67 6
    public static function isZero(): Closure
68
    {
69 6
        return static fn (callable $a): Closure => $a(Combinators::K()(self::CFalse()))(self::CTrue());
70
    }
71
72 1
    public static function lt(): Closure
73
    {
74 1
        return static fn (callable $a): Closure => static fn (callable $b): Closure => self::CNot()(self::gte()($a)($b));
75
    }
76
77 3
    public static function lte(): Closure
78
    {
79 3
        return static fn (callable $a): Closure => static fn (callable $b): Closure => self::isZero()(Numeral::minus()($a)($b));
80
    }
81
}
82