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

NumericComparator::compare()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

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