Key::sort()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 1

Importance

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