Passed
Pull Request — master (#2)
by Pol
13:44
created

U::closure()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 4
ccs 2
cts 2
cp 1
crap 1
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 U.
11
 *
12
 * @psalm-template ResultType
13
 */
14
final class U extends Combinator
15
{
16
    /**
17
     * @var callable
18
     */
19
    private $f;
20
21
    /**
22
     * @var callable
23
     */
24
    private $g;
25
26
    /**
27
     * U constructor.
28
     *
29
     * @psalm-param callable $f
30 1
     * @psalm-param callable $g
31
     *
32 1
     * @param callable $f
33 1
     * @param callable $g
34 1
     */
35
    public function __construct(callable $f, callable $g)
36
    {
37
        $this->f = $f;
38
        $this->g = $g;
39 1
    }
40
41 1
    /**
42 1
     * @psalm-return ResultType
43
     */
44 1
    public function __invoke()
45
    {
46
        $f = $this->f;
47
        $g = $this->g;
48
49
        return $g(($f($f()))($g));
50 1
    }
51
}
52