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

DateTimeComparator::compare()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3

Importance

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