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.
Completed
Push — master ( ac587f...53bcfa )
by SignpostMarv
07:07
created

DaftObjectIdValuesHashLazyInt::DaftObjectIdHash()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 1
dl 0
loc 9
ccs 0
cts 7
cp 0
crap 6
rs 9.6666
c 0
b 0
f 0
1
<?php
2
/**
3
* Base daft objects.
4
*
5
* @author SignpostMarv
6
*/
7
declare(strict_types=1);
8
9
namespace SignpostMarv\DaftObject;
10
11
trait DaftObjectIdValuesHashLazyInt
12
{
13
    /**
14
    * @see DefinesOwnIdPropertiesInterface::DaftObjectIdHash()
15
    */
16
    public static function DaftObjectIdHash(DefinesOwnIdPropertiesInterface $object) : string
17
    {
18
        $id = [];
19
20
        foreach ($object::DaftObjectIdProperties() as $prop) {
21
            $id[] = $object->$prop;
22
        }
23
24
        return static::DaftObjectIdValuesHash($id);
25
    }
26
27
    /**
28
    * @see DefinesOwnIdPropertiesInterface::DaftObjectIdValuesHash()
29
    */
30
    public static function DaftObjectIdValuesHash(array $id) : string
31
    {
32
        static $ids = [];
33
34
        $className = static::class;
35
36
        $objectIds = '';
37
        foreach (array_values($id) as $i => $idVal) {
38
            if ($i >= 1) {
39
                $objectIds .= '::';
40
            }
41
            $objectIds .= (string) $idVal;
42
        }
43
44
        if (false === isset($ids[$className], $ids[$className][$objectIds])) {
45
            $ids[$className] = $ids[$className] ?? [];
46
            $ids[$className][$objectIds] = (string) count($ids[$className]);
47
        }
48
49
        return $ids[$className][$objectIds];
50
    }
51
}
52