HasChildrenTrait::addChild()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

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