Passed
Push — master ( 114e37...c14d71 )
by SignpostMarv
02:54
created

DaftWriteableObjectMemoryTree   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 31
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 TraitWriteableTree;
14
15 88
    protected function RememberDaftObjectData(DefinesOwnIdPropertiesInterface $object) : void
16
    {
17 88
        static::ThrowIfNotType($object, DaftNestedWriteableObject::class, 1, __METHOD__);
18
19 88
        parent::RememberDaftObjectData($object);
20 88
    }
21
22
    /**
23
    * @param DaftObject|string $object
24
    */
25 102
    protected static function ThrowIfNotType(
26
        $object,
27
        string $type,
28
        int $argument,
29
        string $function
30
    ) : void {
31 102
        if ( ! is_a($object, DaftNestedWriteableObject::class, is_string($object))) {
32 2
            throw new DaftObjectRepositoryTypeByClassMethodAndTypeException(
33 2
                $argument,
34 2
                static::class,
35 2
                $function,
36 2
                DaftNestedWriteableObject::class,
37 2
                is_string($object) ? $object : get_class($object)
38
            );
39
        }
40
41 100
        parent::ThrowIfNotType($object, $type, $argument, $function);
42 100
    }
43
}
44