HasChildrenTrait::renderChildren()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 8
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 0
crap 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
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