| Total Complexity | 5 |
| Total Lines | 20 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 5 | final readonly class NumericComparator implements ComparatorInterface |
||
|
|
|||
| 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 |