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

Ki   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 42
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A closure() 0 4 1
A __invoke() 0 3 1
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