CallableAccess::create()   A
last analyzed

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 0
Metric Value
eloc 1
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 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