Passed
Push — master ( 6e67eb...aff4f7 )
by SignpostMarv
03:24
created

RememberDaftObjectData()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

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