HasChildrenTrait   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
eloc 7
dl 0
loc 26
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A renderChildren() 0 8 2
A addChild() 0 3 1
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
namespace SN\HtmlSanitizer\Node;
10
11
/**
12
 * Used by nodes which can have children.
13
 *
14
 * @author Steve Nebes <[email protected]>
15
 */
16
trait HasChildrenTrait
17
{
18
    /**
19
     * @var NodeInterface[]
20
     */
21
    private $children = [];
22
23
    /**
24
     * @param NodeInterface $child
25
     */
26 6
    public function addChild(NodeInterface $child): void
27
    {
28 6
        $this->children[] = $child;
29 6
    }
30
31
    /**
32
     * @return string
33
     */
34 14
    protected function renderChildren(): string
35
    {
36 14
        $rendered = '';
37 14
        foreach ($this->children as $child) {
38 5
            $rendered .= $child->render();
39
        }
40
41 14
        return $rendered;
42
    }
43
}
44