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

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