TextNode   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
eloc 7
dl 0
loc 29
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A render() 0 3 1
A __construct() 0 5 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