Total Complexity | 9 |
Total Lines | 34 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
8 | readonly class UnicodeComparator implements ComparatorInterface |
||
9 | { |
||
10 | private Collator $collator; |
||
11 | 35 | ||
12 | public function __construct(?string $locale = null) |
||
13 | 35 | { |
|
14 | 10 | if (!$locale) { |
|
15 | $locale = Locale::getDefault(); |
||
16 | } |
||
17 | 35 | ||
18 | 35 | $this->collator = new Collator($locale); |
|
19 | $this->collator->setAttribute(Collator::NUMERIC_COLLATION, Collator::ON); |
||
20 | } |
||
21 | 2 | ||
22 | public function getLocale(): string |
||
23 | 2 | { |
|
24 | return $this->collator->getLocale(Locale::VALID_LOCALE); |
||
25 | } |
||
26 | |||
27 | /** |
||
28 | * {@inheritdoc} |
||
29 | 28 | */ |
|
30 | public function compare(mixed $a, mixed $b): int |
||
34 | } |
||
35 | |||
36 | /** |
||
37 | * {@inheritdoc} |
||
38 | 9 | */ |
|
39 | public function supports(mixed $value): bool |
||
42 | } |
||
43 | } |
||
44 |