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
Push — master ( 6cf9ce...3aaa4b )
by SignpostMarv
07:03
created

TraitSortableDaftObject   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
eloc 16
dl 0
loc 43
ccs 17
cts 17
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A CompareToDaftSortableObject() 0 18 4
A DaftSortableObjectProperties() 0 15 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
    * @psalm-param T as $otherObject
18
    */
19 4
    public function CompareToDaftSortableObject(DaftSortableObject $otherObject) : int
20
    {
21 4
        if ( ! is_a(static::class, DaftSortableObject::class, true)) {
22 2
            throw new ClassDoesNotImplementClassException(
23 2
                static::class,
24 2
                DaftSortableObject::class
25
            );
26
        }
27
28 2
        foreach (static::DaftSortableObjectProperties() as $property) {
29 2
            $sort = $this->__get($property) <=> $otherObject->__get($property);
0 ignored issues
show
Bug introduced by
It seems like __get() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

29
            $sort = $this->/** @scrutinizer ignore-call */ __get($property) <=> $otherObject->__get($property);
Loading history...
30
31 2
            if (0 !== $sort) {
32 2
                return $sort;
33
            }
34
        }
35
36 2
        return 0;
37
    }
38
39
    /**
40
    * @return array<int, string>
41
    */
42 6
    public static function DaftSortableObjectProperties() : array
43
    {
44 6
        if ( ! is_a(static::class, DaftSortableObject::class, true)) {
45 2
            throw new ClassDoesNotImplementClassException(
46 2
                static::class,
47 2
                DaftSortableObject::class
48
            );
49
        }
50
51
        /**
52
        * @var array<int, string>
53
        */
54 4
        $out = static::SORTABLE_PROPERTIES;
0 ignored issues
show
Bug introduced by
The constant SignpostMarv\DaftObject\...ct::SORTABLE_PROPERTIES was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
55
56 4
        return $out;
57
    }
58
}
59