Passed
Pull Request — master (#2)
by Pol
02:21
created

B::closure()   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
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 4
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace loophp\combinator\Combinator;
6
7
use loophp\combinator\Combinator;
8
9
/**
10
 * Class B.
11
 *
12
 * @psalm-template GOutput
13
 * @psalm-template XType
14
 * @psalm-template ResultType
15
 */
16
final class B extends Combinator
17
{
18
    /**
19
     * @var callable
20
     */
21
    private $f;
22
23
    /**
24
     * @var callable
25
     */
26
    private $g;
27
28
    /**
29
     * @var mixed
30
     */
31
    private $x;
32
33
    /**
34
     * B constructor.
35
     *
36
     * @psalm-param callable(GOutput) : ResultType $f
37
     * @psalm-param callable(XType) : GOutput $g
38
     * @psalm-param XType $x
39
     *
40
     * @param callable $f
41
     * @param callable $g
42
     * @param mixed $x
43
     */
44 1
    public function __construct(callable $f, callable $g, $x)
45
    {
46 1
        $this->f = $f;
47 1
        $this->g = $g;
48 1
        $this->x = $x;
49 1
    }
50
51
    /**
52
     * @psalm-return ResultType
53
     */
54 1
    public function __invoke()
55
    {
56 1
        return ($this->f)(($this->g)($this->x));
57
    }
58
}
59