GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Branch object-only (2b4c07)
by SignpostMarv
14:54
created

CompareToDaftSortableObject()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 18
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 20

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 18
ccs 0
cts 10
cp 0
rs 9.9666
c 0
b 0
f 0
cc 4
nc 4
nop 1
crap 20
1
<?php
2
/**
3
* Exceptions.
4
*
5
* @author SignpostMarv
6
*/
7
declare(strict_types=1);
8
9
namespace SignpostMarv\DaftObject;
10
11
/**
12
* @template T as DaftSortableObject
13
*/
14
trait TraitSortableDaftObject
15
{
16
    /**
17
    * @return scalar|array|object|null
18
    */
19
    abstract public function __get(string $property);
20
21
    /**
22
    * @psalm-param T as $otherObject
23
    */
24
    public function CompareToDaftSortableObject(DaftSortableObject $otherObject) : int
25
    {
26
        if ( ! is_a(static::class, DaftSortableObject::class, true)) {
27
            throw new ClassDoesNotImplementClassException(
28
                static::class,
29
                DaftSortableObject::class
30
            );
31
        }
32
33
        foreach (static::DaftSortableObjectProperties() as $property) {
34
            $sort = $this->__get($property) <=> $otherObject->__get($property);
35
36
            if (0 !== $sort) {
37
                return $sort;
38
            }
39
        }
40
41
        return 0;
42
    }
43
44
    /**
45
    * @return array<int, string>
46
    */
47
    public static function DaftSortableObjectProperties() : array
48
    {
49
        if ( ! is_a(static::class, DaftSortableObject::class, true)) {
50
            throw new ClassDoesNotImplementClassException(
51
                static::class,
52
                DaftSortableObject::class
53
            );
54
        }
55
56
        /**
57
        * @var array<int, string>
58
        */
59
        $out = (array) constant(static::class . '::SORTABLE_PROPERTIES');
60
61
        return $out;
62
    }
63
}
64