Passed
Push — master ( c83ab4...4ae41b )
by Pol
19:03 queued 06:34
created

Ki::__invoke()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

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
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 Ki.
11
 *
12
 * @psalm-template XType
13
 */
14
final class Ki extends Combinator
15
{
16
    /**
17
     * @var mixed
18
     */
19
    private $x;
20
21
    /**
22
     * @var mixed
23
     */
24
    private $y;
25
26
    /**
27
     * Ki constructor.
28
     *
29
     * @psalm-param XType $x
30
     * @psalm-param XType $y
31
     *
32
     * @param mixed $x
33
     * @param mixed $y
34
     */
35
    public function __construct($x, $y)
36
    {
37
        $this->x = $x;
38
        $this->y = $y;
39
    }
40
41
    /**
42
     * @psalm-return XType
43
     */
44
    public function __invoke()
45
    {
46
        return $this->y;
47
    }
48
49
    /**
50
     * @return callable
51
     */
52
    public static function closure(): callable
53
    {
54
        return static function ($x, $y) {
55
            return (new self($x, $y))();
56
        };
57
    }
58
}
59