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 ( f7df6f...7005eb )
by SignpostMarv
03:11
created

AbstractDaftObjectRepository::ForgetDaftObject()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 17
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 17
c 0
b 0
f 0
ccs 6
cts 6
cp 1
rs 10
cc 2
nc 2
nop 1
crap 2
1
<?php
2
/**
3
* Base daft objects.
4
*
5
* @author SignpostMarv
6
*/
7
declare(strict_types=1);
8
9
namespace SignpostMarv\DaftObject;
10
11
/**
12
* @template T as SuitableForRepositoryType
13
*
14
* @template-implements DaftObjectRepository<T>
15
*/
16
abstract class AbstractDaftObjectRepository implements DaftObjectRepository
17
{
18
    /**
19
    * @var array<string, SuitableForRepositoryType>
20
    *
21
    * @psalm-var array<string, T>
22
    */
23
    protected $memory = [];
24
25
    /**
26
    * @var array<string, array<string, mixed>>
27
    */
28
    protected $data = [];
29
30
    /**
31
    * @var string
32
    *
33
    * @psalm-var class-string<T>
34
    */
35
    protected $type;
36
37
    /**
38
    * @var mixed[]|null
39
    */
40
    protected $args;
41
42
    /**
43
    * @param mixed ...$args
44
    *
45
    * @psalm-param class-string<T> $type
46
    */
47 4
    protected function __construct(string $type, ...$args)
48
    {
49 4
        $this->type = $type;
50 4
        $this->args = $args;
51 4
        unset($this->args);
52 4
    }
53
54
    /**
55
    * {@inheritdoc}
56
    */
57 4
    public function ForgetDaftObject(SuitableForRepositoryType $object) : void
58
    {
59
        /**
60
        * @var (scalar|array|object|null)[]
61
        */
62 4
        $id = [];
63
64 4
        foreach ($object::DaftObjectIdProperties() as $prop) {
65
            /**
66
            * @var scalar|array|object|null
67
            */
68 4
            $id_val = $object->__get($prop);
69
70 4
            $id[] = $id_val;
71
        }
72
73 4
        $this->ForgetDaftObjectById($id);
74 4
    }
75
76
    /**
77
    * {@inheritdoc}
78
    */
79 4
    public function RemoveDaftObject(SuitableForRepositoryType $object) : void
80
    {
81
        /**
82
        * @var (scalar|array|object|null)[]
83
        */
84 4
        $id = [];
85
86 4
        $properties = $object::DaftObjectIdProperties();
87
88 4
        foreach ($properties as $prop) {
89 4
            $id_val = $object->__get($prop);
90
91 4
            $id[] = $id_val;
92
        }
93
94 4
        $this->RemoveDaftObjectById($id);
95 4
    }
96
97
    /**
98
    * {@inheritdoc}
99
    *
100
    * @psalm-param class-string<T> $type
101
    *
102
    * @psalm-return AbstractDaftObjectRepository<T>
103
    */
104 4
    public static function DaftObjectRepositoryByType(
105
        string $type,
106
        ...$args
107
    ) : DaftObjectRepository {
108 4
        return new static($type, ...$args);
109
    }
110
111
    /**
112
    * {@inheritdoc}
113
    *
114
    * @psalm-param T $object
115
    *
116
    * @psalm-return AbstractDaftObjectRepository<T>
117
    */
118 4
    public static function DaftObjectRepositoryByDaftObject(
119
        SuitableForRepositoryType $object,
120
        ...$args
121
    ) : DaftObjectRepository {
122
        /**
123
        * @psalm-var class-string<T>
124
        */
125 4
        $className = get_class($object);
126
127 4
        return static::DaftObjectRepositoryByType($className, ...$args);
128
    }
129
}
130