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

K   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 44
ccs 9
cts 9
cp 1
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 3 1
A __construct() 0 4 1
A on() 0 4 1
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 K.
12
 *
13
 * @psalm-template AType
14
 * @psalm-template BType
15
 */
16
final class K extends Combinator
17
{
18
    /**
19
     * @var mixed
20
     */
21
    private $x;
22
23
    /**
24
     * @var mixed
25
     */
26
    private $y;
27
28
    /**
29
     * K constructor.
30 1
     *
31
     * @psalm-param AType $x
32 1
     * @psalm-param BType $y
33 1
     *
34 1
     * @param mixed $x
35
     * @param mixed $y
36
     */
37
    public function __construct($x, $y)
38
    {
39 1
        $this->x = $x;
40
        $this->y = $y;
41 1
    }
42
43
    /**
44
     * @psalm-return BType
45
     */
46
    public function __invoke()
47 1
    {
48
        return $this->x;
49
    }
50 1
51 1
    /**
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