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 ( e59319...265227 )
by SignpostMarv
06:27
created

VarExportNonScalars()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 10
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0
cc 3
nc 3
nop 1
crap 3
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
    * @var array<string, array<string, string>>
15
    */
16
    private static $ids = [];
17
18
    /**
19
    * @see DefinesOwnIdPropertiesInterface::DaftObjectIdHash()
20
    */
21 4
    public static function DaftObjectIdHash(DefinesOwnIdPropertiesInterface $object) : string
22
    {
23 4
        $id = [];
24
25
        /**
26
        * @var array<int, string>
27
        */
28 4
        $properties = $object::DaftObjectIdProperties();
29
30 4
        foreach ($properties as $prop) {
31
            /**
32
            * @var scalar|array|object|resource|null
33
            */
34 4
            $val = $object->$prop;
35
36 4
            $id[] = static::VarExportNonScalars($val);
37
        }
38
39 4
        return static::DaftObjectIdValuesHash($id);
40
    }
41
42
    /**
43
    * @param (scalar|array|object|null)[] $id
44
    *
45
    * @see DefinesOwnIdPropertiesInterface::DaftObjectIdValuesHash()
46
    */
47 8
    public static function DaftObjectIdValuesHash(array $id) : string
48
    {
49 8
        $className = static::class;
50
51 8
        $objectIds = implode('::', array_map(static::class . '::VarExportNonScalars', $id));
52
53 8
        if ( ! isset(self::$ids[$className])) {
54 6
            self::$ids[$className] = [];
55
        }
56
57 8
        if ( ! isset(self::$ids[$className][$objectIds])) {
58 6
            self::$ids[$className][$objectIds] = static::VarExportNonScalars(count(
59 6
                self::$ids[$className]
60
            ));
61
        }
62
63 8
        return self::$ids[$className][$objectIds];
64
    }
65
66
    /**
67
    * @param mixed $maybe
68
    */
69 8
    private static function VarExportNonScalars($maybe) : string
70
    {
71 8
        if (is_string($maybe)) {
72 4
            return $maybe;
73
        }
74
75
        return
76 8
            is_scalar($maybe)
77 8
                ? (string) $maybe
78 8
                : var_export($maybe, true);
79
    }
80
}
81