Passed
Push — master ( 0d07bf...dd4616 )
by Steve
35s
created

BodyNode   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 41
ccs 16
cts 16
cp 1
rs 10
c 0
b 0
f 0
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A copyTree() 0 12 2
A getMinimalDeletedSet() 0 10 2
1
<?php
2
/**
3
 * (c) Steve Nebes <[email protected]>
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
9
declare(strict_types=1);
10
11
namespace SN\DaisyDiff\Html\Dom;
12
13
/**
14
 * Represents the root of a HTML document.
15
 */
16
class BodyNode extends TagNode
17
{
18
    /**
19
     * Default values.
20
     */
21 71
    public function __construct()
22
    {
23 71
        parent::__construct(null, 'body');
24 71
    }
25
26
    /**
27
     * @return Node
28
     */
29 2
    public function copyTree(): Node
30
    {
31 2
        $newThis = new static();
32
33
        /** @var Node $child */
34 2
        foreach ($this->getIterator() as $child) {
35 1
            $newChild = $child->copyTree();
36 1
            $newChild->setParent($newThis);
37 1
            $newThis->addChild($newChild);
38
        }
39
40 2
        return $newThis;
41
    }
42
43
    /**
44
     * @param int $id
45
     * @return Node[]
46
     */
47 11
    public function getMinimalDeletedSet(int $id): array
48
    {
49 11
        $nodes = [];
50
51 11
        foreach ($this->getIterator() as $child) {
52 9
            $childrenChildren = $child->getMinimalDeletedSet($id);
53 9
            $nodes = \array_merge($nodes, $childrenChildren);
54
        }
55
56 11
        return $nodes;
57
    }
58
}
59