Asc   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 2
eloc 5
c 2
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 uasort;
10
11
final class Asc implements Sorter
12
{
13 37
    public function __construct(private Comparable $comparable)
14
    {
15 37
    }
16
17
    /**
18
     * {@inheritDoc}
19
     */
20 36
    public function sort(array $values): array
21
    {
22 36
        $comparable = $this->comparable;
23 36
        uasort(
24 36
            $values,
25 36
            static fn (mixed $first, mixed $second): int => $comparable->compare($first, $second)
26 36
        );
27
28 35
        return $values;
29
    }
30
}
31