Passed
Push — master ( 6c8dfe...6e67eb )
by SignpostMarv
03:14
created

DaftWriteableObjectMemoryTree   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 34
ccs 0
cts 13
cp 0
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 7 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
    public function RememberDaftObjectData(
17
        DefinesOwnIdPropertiesInterface $object,
18
        bool $assumeDoesNotExist = false
19
    ) : void {
20
        static::ThrowIfNotType($object, DaftNestedWriteableObject::class, 1, __METHOD__);
21
22
        parent::RememberDaftObjectData($object, $assumeDoesNotExist);
23
    }
24
25
    /**
26
    * @param DaftObject|string $object
27
    */
28
    protected static function ThrowIfNotType(
29
        $object,
30
        string $type,
31
        int $argument,
32
        string $function
33
    ) : void {
34
        if ( ! is_a($object, DaftNestedWriteableObject::class, is_string($object))) {
35
            throw new DaftObjectRepositoryTypeByClassMethodAndTypeException(
36
                $argument,
37
                static::class,
38
                $function,
39
                DaftNestedWriteableObject::class,
40
                is_string($object) ? $object : get_class($object)
41
            );
42
        }
43
44
        parent::ThrowIfNotType($object, $type, $argument, $function);
45
    }
46
}
47