Passed
Push — master ( 913c0a...fd8403 )
by Ondřej
05:45
created

EqualableWithCompareTo::compareTo()

Size

Total Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 1
c 0
b 0
f 0
nc 1
1
<?php
2
declare(strict_types=1);
3
namespace Ivory\Value\Alg;
4
5
/**
6
 * Implements the {@link IEqualable::equals()} using the {@link IComparable::compareTo()} method.
7
 */
8
trait EqualableWithCompareTo
9
{
10
    abstract public function compareTo($other): ?int;
11
12
    public function equals($other): bool
13
    {
14
        if ($other === null) {
15
            return false;
16
        }
17
18
        return ($this->compareTo($other) == 0);
19
    }
20
}
21