TextNode::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 5
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
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
use SN\HtmlSanitizer\Sanitizer\StringSanitizerTrait;
12
13
/**
14
 * @author Steve Nebes <[email protected]>
15
 *
16
 * @internal
17
 */
18
class TextNode extends AbstractNode
19
{
20
    use IsChildlessTrait;
21
    use StringSanitizerTrait;
22
23
    /**
24
     * @var string
25
     */
26
    private $text;
27
28
    /**
29
     * Default values.
30
     *
31
     * @param NodeInterface $parent
32
     * @param string        $text
33
     */
34 3
    public function __construct(NodeInterface $parent, string $text)
35
    {
36 3
        parent::__construct($parent);
37
38 3
        $this->text = $text;
39 3
    }
40
41
    /**
42
     * @return string
43
     */
44 3
    public function render(): string
45
    {
46 3
        return $this->encodeHtmlEntities($this->text);
47
    }
48
}
49