Passed
Push — master ( bef509...69203b )
by Pol
01:52
created

E::toClosure()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace loophp\combinator\Combinator;
6
7
use loophp\combinator\Combinator;
8
9
/**
10
 * Class E.
11
 */
12
final class E extends Combinator
13
{
14
    /**
15
     * @var callable
16
     */
17
    private $f;
18
19
    /**
20
     * @var callable
21
     */
22
    private $g;
23
24
    /**
25
     * @var mixed
26
     */
27
    private $x;
28
29
    /**
30
     * @var mixed
31
     */
32
    private $y;
33
34
    /**
35
     * @var mixed
36
     */
37
    private $z;
38
39
    /**
40
     * E constructor.
41
     *
42
     * @param callable $f
43
     * @param mixed $x
44
     * @param callable $g
45
     * @param mixed $y
46
     * @param mixed $z
47
     */
48 1
    public function __construct(callable $f, $x, callable $g, $y, $z)
49
    {
50 1
        $this->f = $f;
51 1
        $this->g = $g;
52 1
        $this->x = $x;
53 1
        $this->y = $y;
54 1
        $this->z = $z;
55 1
    }
56
57
    /**
58
     * @return mixed
59
     */
60 1
    public function __invoke()
61
    {
62 1
        return (($this->f)($this->x))((($this->g)($this->y))($this->z));
63
    }
64
65
    /**
66
     * @return callable
67
     */
68 1
    public static function closure(): callable
69
    {
70
        return static function (callable $f, $x, callable $g, $y, $z) {
71 1
            return (new self($f, $x, $g, $y, $z))();
72 1
        };
73
    }
74
}
75