Completed
Push — master ( cc8038...edef00 )
by Bartko
01:27
created

ChildBottom   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 3
dl 0
loc 34
ccs 0
cts 20
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A canCreateNewNode() 0 3 1
A makeHole() 0 6 1
A createNewNodeNodeInfo() 0 11 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace StefanoTree\NestedSet\AddStrategy;
6
7
use StefanoTree\NestedSet\NodeInfo;
8
9
class ChildBottom extends AddStrategyAbstract
10
{
11
    /**
12
     * {@inheritdoc}
13
     */
14
    protected function canCreateNewNode(NodeInfo $targetNode): void
15
    {
16
    }
17
18
    /**
19
     * {@inheritdoc}
20
     */
21
    protected function makeHole(NodeInfo $targetNode): void
22
    {
23
        $moveFromIndex = $targetNode->getRight() - 1;
24
        $this->getManipulator()->moveLeftIndexes($moveFromIndex, 2, $targetNode->getScope());
25
        $this->getManipulator()->moveRightIndexes($moveFromIndex, 2, $targetNode->getScope());
26
    }
27
28
    /**
29
     * {@inheritdoc}
30
     */
31
    protected function createNewNodeNodeInfo(NodeInfo $targetNode): NodeInfo
32
    {
33
        return new NodeInfo(
34
            null,
35
            $targetNode->getId(),
36
            $targetNode->getLevel() + 1,
37
            $targetNode->getRight(),
38
            $targetNode->getRight() + 1,
39
            $targetNode->getScope()
40
        );
41
    }
42
}
43