Key   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 2 1
A sort() 0 9 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Budgegeria\IntlSort\Sorter;
6
7
use Budgegeria\IntlSort\Comparator\Comparable;
8
9
use function uksort;
10
11
final class Key implements Sorter
12
{
13 5
    public function __construct(private Comparable $comparable)
14
    {
15 5
    }
16
17
    /**
18
     * {@inheritDoc}
19
     */
20 5
    public function sort(array $values): array
21
    {
22 5
        $comparable = $this->comparable;
23 5
        uksort(
24 5
            $values,
25 5
            static fn (mixed $first, mixed $second): int => $comparable->compare($first, $second)
26 5
        );
27
28 4
        return $values;
29
    }
30
}
31