Passed
Pull Request — main (#1)
by Diego
03:33
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
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
    {
11 3
        if ($a > $b) {
12 1
            return 1;
13
        }
14
15 2
        if ($a < $b) {
16 1
            return -1;
17
        }
18
19 1
        return 0;
20
    }
21
22 5
    public function supports(mixed $value): bool
23
    {
24 5
        return $value instanceof DateTimeInterface;
25
    }
26
}
27