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

Combinator   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
dl 0
loc 14
ccs 5
cts 5
cp 1
rs 10
c 1
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A with() 0 9 2
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