Passed
Pull Request — main (#1)
by Diego
15:22
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
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