Passed
Branch master (9026fd)
by Bartko
02:45
created

ChildTop   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 11
c 0
b 0
f 0
dl 0
loc 31
rs 10
ccs 11
cts 11
cp 1
wmc 3

3 Methods

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