Passed
Push — master ( f98ecf...4dc4ad )
by Pol
02:13
created

G   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Test Coverage

Coverage 90%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A __invoke() 0 3 1
A toClosure() 0 4 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 G.
11
 */
12
final class G extends Combinator
13
{
14
    /**
15
     * @var callable
16
     */
17
    private $f;
18
19
    /**
20
     * @var callable
21
     */
22
    private $g;
23
24
    /**
25
     * @var mixed
26
     */
27
    private $x;
28
29
    /**
30
     * @var callable
31
     */
32
    private $y;
33
34
    /**
35
     * G constructor.
36
     *
37
     * @param callable $f
38
     * @param callable $g
39
     * @param mixed $x
40
     * @param mixed $y
41
     */
42 1
    public function __construct(callable $f, callable $g, $x, $y)
43
    {
44 1
        $this->f = $f;
45 1
        $this->g = $g;
46 1
        $this->x = $x;
47 1
        $this->y = $y;
48 1
    }
49
50
    /**
51
     * @return mixed
52
     */
53 1
    public function __invoke()
54
    {
55 1
        return (($this->f)($this->y))(($this->g)($this->x));
56
    }
57
58
    /**
59
     * @return callable
60
     */
61 1
    public static function toClosure(): callable
62
    {
63
        return static function (callable $f, callable $g, $x, $y) {
64
            return (new self($f, $g, $x, $y))();
65 1
        };
66
    }
67
}
68