Passed
Push — master ( c76e09...db80fb )
by Pol
12:47
created

Phoenix::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

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