DateTimeComparator::supports()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 1 Features 1
Metric Value
c 1
b 1
f 1
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
namespace PHPExtra\Sorter\Comparator;
4
5
/**
6
 * Compare dates (\DateTime)
7
 *
8
 * @author Jacek Kobus <[email protected]>
9
 */
10
class DateTimeComparator implements ComparatorInterface
11
{
12
    /**
13
     * {@inheritdoc}
14
     */
15 3
    public function compare($a, $b)
16
    {
17 3
        if ($a > $b) {
18 1
            return 1;
19 2
        } elseif ($a < $b) {
20 1
            return -1;
21
        }
22
23 1
        return 0;
24
    }
25
26
    /**
27
     * {@inheritdoc}
28
     */
29 5
    public function supports($value)
30
    {
31 5
        return $value instanceof \DateTime;
32
    }
33
}