Passed
Push — master ( cb1b1b...50940b )
by Pol
02:05
created

Combinator::with()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 0
dl 0
loc 9
ccs 5
cts 5
cp 1
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace loophp\combinator;
6
7
use Closure;
8
use InvalidArgumentException;
9
10
use function get_called_class;
11
use function is_callable;
12
13
/**
14
 * Class Combinator.
15
 */
16
abstract class Combinator implements \loophp\combinator\Contract\Combinator
17
{
18
    /**
19
     * @return Closure
20
     */
21 29
    public static function with(): Closure
22
    {
23 29
        $possibleCallable = ['static', 'on'];
24
25 29
        if (true === is_callable($possibleCallable)) {
26 28
            return Closure::fromCallable($possibleCallable);
27
        }
28
29 1
        throw new InvalidArgumentException('Implement on() method in ' . get_called_class() . '.');
30
    }
31
}
32