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 ( ce1e69...5665d5 )
by SignpostMarv
04:49
created

AbstractDaftObjectRepository::ForgetDaftObject()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 20
Code Lines 10

Duplication

Lines 20
Ratio 100 %

Code Coverage

Tests 12
CRAP Score 3

Importance

Changes 0
Metric Value
cc 3
eloc 10
nc 2
nop 1
dl 20
loc 20
ccs 12
cts 12
cp 1
crap 3
rs 9.4285
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
abstract class AbstractDaftObjectRepository implements DaftObjectRepository
12
{
13
    /**
14
    * @var DefinesOwnIdPropertiesInterface[]
15
    */
16
    protected $memory = [];
17
18
    /**
19
    * mixed[][].
20
    */
21
    protected $data = [];
22
23
    /**
24
    * @var string
25
    */
26
    protected $type;
27
28 6
    protected function __construct(string $type)
29
    {
30 6
        $this->type = $type;
31 6
    }
32
33 3 View Code Duplication
    public function ForgetDaftObject(
34
        DefinesOwnIdPropertiesInterface $object
35
    ) : void {
36 3
        if (false === is_a($object, $this->type, true)) {
37 1
            throw new DaftObjectRepositoryTypeByClassMethodAndTypeException(
38 1
                1,
39 1
                static::class,
40 1
                __FUNCTION__,
41 1
                $this->type,
42 1
                get_class($object)
43
            );
44
        }
45
46 2
        $id = [];
47
48 2
        foreach ($object::DaftObjectIdProperties() as $prop) {
49 2
            $id[] = $object->$prop;
50
        }
51
52 2
        $this->ForgetDaftObjectById($id);
53 2
    }
54
55 3 View Code Duplication
    public function RemoveDaftObject(
56
        DefinesOwnIdPropertiesInterface $object
57
    ) : void {
58 3
        if (false === is_a($object, $this->type, true)) {
59 1
            throw new DaftObjectRepositoryTypeByClassMethodAndTypeException(
60 1
                1,
61 1
                static::class,
62 1
                __FUNCTION__,
63 1
                $this->type,
64 1
                get_class($object)
65
            );
66
        }
67
68 2
        $id = [];
69
70 2
        foreach ($object::DaftObjectIdProperties() as $prop) {
71 2
            $id[] = $object->$prop;
72
        }
73
74 2
        $this->RemoveDaftObjectById($id);
75 2
    }
76
77 6
    public static function DaftObjectRepositoryByType(
78
        string $type
79
    ) : DaftObjectRepository {
80
        if (
81 6
            false === is_a(
82 6
                $type,
83 6
                DefinesOwnIdPropertiesInterface::class,
84 6
                true
85
            )
86
        ) {
87 1
            throw new DaftObjectRepositoryTypeByClassMethodAndTypeException(
88 1
                1,
89 1
                static::class,
90 1
                __FUNCTION__,
91 1
                DefinesOwnIdPropertiesInterface::class,
92 1
                $type
93
            );
94
        }
95
96 6
        return new static($type);
97
    }
98
99 5
    public static function DaftObjectRepositoryByDaftObject(
100
        DefinesOwnIdPropertiesInterface $object
101
    ) : DaftObjectRepository {
102 5
        return static::DaftObjectRepositoryByType(get_class($object));
103
    }
104
}
105