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.

DaftSortableObjectProperties()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 15
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 15
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 0
crap 2
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 4
    public function CompareToDaftSortableObject(DaftSortableObject $otherObject) : int
25
    {
26 4
        foreach (static::DaftSortableObjectProperties() as $property) {
27 4
            $sort = $this->__get($property) <=> $otherObject->__get($property);
28
29 4
            if (0 !== $sort) {
30 4
                return $sort;
31
            }
32
        }
33
34 4
        return 0;
35
    }
36
37
    /**
38
    * @return array<int, string>
39
    */
40 16
    public static function DaftSortableObjectProperties() : array
41
    {
42 16
        if ( ! is_a(static::class, DaftSortableObject::class, true)) {
43 4
            throw Exceptions\Factory::ClassDoesNotImplementClassException(
44 4
                static::class,
45 4
                DaftSortableObject::class
46
            );
47
        }
48
49
        /**
50
        * @var array<int, string>
51
        */
52 12
        $out = constant(static::class . '::SORTABLE_PROPERTIES');
53
54 12
        return $out;
55
    }
56
}
57