Test Failed
Push — main ( bd5910...7fd4c8 )
by Diego
07:59 queued 04:39
created

NumericComparator   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 20
ccs 6
cts 6
cp 1
rs 10
wmc 5
1
<?php
2
3
namespace Ninja\Sorter\Comparator;
4
5
final readonly class NumericComparator implements ComparatorInterface
0 ignored issues
show
Bug introduced by
A parse error occurred: Syntax error, unexpected T_READONLY, expecting T_CLASS on line 5 at column 6
Loading history...
6
{
7 19
    public function __construct(private int $scale = 10) {}
8
9 19
    /**
10
     * {@inheritdoc}
11
     */
12
    public function compare(mixed $a, mixed $b): int
13
    {
14 14
        return bccomp((string)$a, (string)$b, $this->scale);
15
    }
16 14
17
    /**
18
     * {@inheritdoc}
19
     */
20
    public function supports(mixed $value): bool
21
    {
22 5
        return is_numeric($value);
23
    }
24
}
25