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

DateTimeComparator   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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