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

DaftWriteableObjectMemoryTree::RememberDaftObject()   A

Complexity

Conditions 5
Paths 3

Size

Total Lines 32

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 15
CRAP Score 5

Importance

Changes 0
Metric Value
cc 5
nc 3
nop 1
dl 0
loc 32
rs 9.0968
c 0
b 0
f 0
ccs 15
cts 15
cp 1
crap 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A DaftWriteableObjectMemoryTree::ThrowIfNotType() 0 17 3
A DaftWriteableObjectMemoryTree::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