WriteableObjectTrait::SetIntNestedRight()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
* Base daft nested objects.
4
*
5
* @author SignpostMarv
6
*/
7
declare(strict_types=1);
8
9
namespace SignpostMarv\DaftObject;
10
11
/**
12
* @template T as DaftNestedWriteableObject
13
*/
14
trait WriteableObjectTrait
15
{
16 86
    public function SetIntNestedLeft(int $value) : void
17
    {
18 86
        $this->NudgePropertyValue('intNestedLeft', $value);
19 86
    }
20
21 86
    public function SetIntNestedRight(int $value) : void
22
    {
23 86
        $this->NudgePropertyValue('intNestedRight', $value);
24 86
    }
25
26 60
    public function SetIntNestedLevel(int $value) : void
27
    {
28 60
        $this->NudgePropertyValue('intNestedLevel', $value);
29 60
    }
30
31 28
    public function SetIntNestedSortOrder(int $value) : void
32
    {
33 28
        $this->NudgePropertyValue('intNestedSortOrder', $value);
34 28
    }
35
36
    /**
37
    * @param scalar[] $value
38
    */
39 60
    public function SetDaftNestedObjectParentId(array $value) : void
40
    {
41 60
        foreach (static::DaftNestedObjectParentIdProperties() as $i => $prop) {
42 60
            $this->NudgePropertyValue($prop, $value[$i] ?? null);
43
        }
44 60
    }
45
46
    /**
47
    * @return array<int, string>
48
    */
49
    abstract public static function DaftNestedObjectParentIdProperties() : array;
50
51
    /**
52
    * @see AbstractDaftObject::NudgePropertyValue()
53
    *
54
    * @param string $property property being nudged
55
    * @param scalar|array|object|null $value value to nudge property with
56
    */
57
    abstract protected function NudgePropertyValue(
58
        string $property,
59
        $value,
60
        bool $autoTrimStrings = AbstractArrayBackedDaftObject::BOOL_DEFAULT_AUTOTRIMSTRINGS,
61
        bool $throwIfNotUnique = AbstractArrayBackedDaftObject::BOOL_DEFAULT_THROWIFNOTUNIQUE
62
    ) : void;
63
}
64