Passed
Push — master ( a8ea98...ccb0bf )
by SignpostMarv
03:21
created

DaftWriteableObjectMemoryTree   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 32
ccs 13
cts 13
cp 1
rs 10
c 0
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A ThrowIfNotType() 0 17 3
A RememberDaftObjectData() 0 5 1
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 DaftWriteableObjectMemoryTree extends DaftObjectMemoryTree implements DaftNestedWriteableObjectTree
12
{
13
    use TraitRememberDaftObject;
14
    use TraitWriteableTree;
15
16 112
    protected function RememberDaftObjectData(DefinesOwnIdPropertiesInterface $object) : void
17
    {
18 112
        static::ThrowIfNotType($object, DaftNestedWriteableObject::class, 1, __METHOD__);
19
20 112
        parent::RememberDaftObjectData($object);
21 112
    }
22
23
    /**
24
    * @param DaftObject|string $object
25
    */
26 114
    protected static function ThrowIfNotType(
27
        $object,
28
        string $type,
29
        int $argument,
30
        string $function
31
    ) : void {
32 114
        if ( ! is_a($object, DaftNestedWriteableObject::class, is_string($object))) {
33 2
            throw new DaftObjectRepositoryTypeByClassMethodAndTypeException(
34 2
                $argument,
35 2
                static::class,
36 2
                $function,
37 2
                DaftNestedWriteableObject::class,
38 2
                is_string($object) ? $object : get_class($object)
39
            );
40
        }
41
42 112
        parent::ThrowIfNotType($object, $type, $argument, $function);
43 112
    }
44
}
45