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

Numeral::five()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
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 Numeral
16
{
17 9
    public static function eight(): Closure
18
    {
19 9
        return self::plus()(self::one())(self::seven());
20
    }
21
22 1
    public static function exponentiation(): Closure
23
    {
24 1
        return Combinators::T();
25
    }
26
27 11
    public static function five(): Closure
28
    {
29 11
        return self::plus()(self::one())(self::four());
30
    }
31
32 15
    public static function four(): Closure
33
    {
34 15
        return self::plus()(self::one())(self::three());
35
    }
36
37 8
    public static function minus(): Closure
38
    {
39 8
        return Combinators::V()(self::pred());
40
    }
41
42 1
    public static function multiply(): Closure
43
    {
44 1
        return Combinators::B();
45
    }
46
47 9
    public static function nine(): Closure
48
    {
49 9
        return self::plus()(self::one())(self::eight());
50
    }
51
52 21
    public static function one(): Closure
53
    {
54 21
        return Combinators::A();
55
    }
56
57 21
    public static function plus(): Closure
58
    {
59 21
        return static fn (callable $a): Closure => static fn (callable $b): Closure => static fn (callable $c): Closure => Combinators::B()($a($c))($b($c));
60
    }
61
62 9
    public static function pred(): Closure
63
    {
64 9
        return static fn (callable $a): Closure => static fn (callable $b): Closure => static fn ($c) => $a(static fn ($d): Closure => static fn ($e) => $e($d($b)))(static fn () => $c)(Combinators::I());
65
    }
66
67 9
    public static function seven(): Closure
68
    {
69 9
        return self::plus()(self::one())(self::six());
70
    }
71
72 9
    public static function six(): Closure
73
    {
74 9
        return self::plus()(self::one())(self::five());
75
    }
76
77 4
    public static function succ(): Closure
78
    {
79 4
        return static fn (callable $n): Closure => static fn (callable $f): Closure => Combinators::B()($f)($n($f));
80
    }
81
82 20
    public static function three(): Closure
83
    {
84 20
        return self::plus()(self::one())(self::two());
85
    }
86
87 1
    public static function toInt(callable $numeral): int
88
    {
89 1
        return $numeral(static fn (int $n): int => $n + 1)(0);
90
    }
91
92 1
    public static function toNumeral(int $n): Closure
93
    {
94 1
        return 0 === $n - 1 ?
95 1
            Numeral::one() :
96 1
            Numeral::plus()(Numeral::one())(Numeral::toNumeral($n - 1));
97
    }
98
99 20
    public static function two(): Closure
100
    {
101 20
        return self::plus()(self::one())(self::one());
102
    }
103
104 6
    public static function zero(): Closure
105
    {
106 6
        return static fn (callable $s): Closure => Combinators::I();
0 ignored issues
show
Unused Code introduced by
The parameter $s is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

106
        return static fn (/** @scrutinizer ignore-unused */ callable $s): Closure => Combinators::I();

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
107
    }
108
}
109