Passed
Push — master ( 693b6d...992193 )
by Claudio
02:16
created

CallableAccess   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A create() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Budgegeria\IntlSort\ComparatorFactory;
6
7
use Budgegeria\IntlSort\Collator\Collator;
8
use Budgegeria\IntlSort\Comparator\CallableAccess as Comparator;
9
use Budgegeria\IntlSort\Comparator\Comparable;
10
use Closure;
11
12
class CallableAccess implements Factory
13
{
14
    /** @psalm-var Closure(mixed):string */
15
    private Closure $func;
16
17
    /** @psalm-param callable(mixed):string $func */
18 1
    public function __construct(callable $func)
19
    {
20 1
        $this->func = Closure::fromCallable($func);
21
    }
22
23 1
    public function create(Collator $collator): Comparable
24
    {
25 1
        return new Comparator($collator, $this->func);
26
    }
27
}
28