Passed
Push — master ( 0f152c...b64aff )
by Pol
22:11 queued 07:09
created

Ki::on()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

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