Passed
Push — master ( 519921...cb1b1b )
by Pol
50:23 queued 48:27
created

M::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

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