1 | <?php |
||
9 | class TextNode extends LeafNode |
||
10 | { |
||
11 | |||
12 | /** |
||
13 | * This is a text node. |
||
14 | * |
||
15 | * @var Tag |
||
16 | */ |
||
17 | protected $tag; |
||
18 | |||
19 | /** |
||
20 | * This is the text in this node. |
||
21 | * |
||
22 | * @var string |
||
23 | */ |
||
24 | protected $text; |
||
25 | |||
26 | /** |
||
27 | * This is the converted version of the text. |
||
28 | * |
||
29 | * @var string |
||
30 | */ |
||
31 | protected $convertedText = null; |
||
32 | |||
33 | /** |
||
34 | * Sets the text for this node. |
||
35 | * |
||
36 | * @param string $text |
||
37 | * @param bool $removeDoubleSpace |
||
38 | */ |
||
39 | 258 | public function __construct(string $text, $removeDoubleSpace = true) |
|
53 | |||
54 | /** |
||
55 | * Returns the text of this node. |
||
56 | * |
||
57 | * @return string |
||
58 | */ |
||
59 | 177 | public function text(): string |
|
77 | |||
78 | /** |
||
79 | * Sets the text for this node. |
||
80 | * |
||
81 | * @var string $text |
||
82 | * @return void |
||
83 | */ |
||
84 | 9 | public function setText(string $text): void |
|
95 | |||
96 | /** |
||
97 | * This node has no html, just return the text. |
||
98 | * |
||
99 | * @return string |
||
100 | * @uses $this->text() |
||
101 | */ |
||
102 | 6 | public function innerHtml(): string |
|
106 | |||
107 | /** |
||
108 | * This node has no html, just return the text. |
||
109 | * |
||
110 | * @return string |
||
111 | * @uses $this->text() |
||
112 | */ |
||
113 | 3 | public function outerHtml(): string |
|
117 | |||
118 | /** |
||
119 | * Call this when something in the node tree has changed. Like a child has been added |
||
120 | * or a parent has been changed. |
||
121 | */ |
||
122 | protected function clear(): void |
||
126 | |||
127 | /** |
||
128 | * Checks if the current node is a text node. |
||
129 | * |
||
130 | * @return bool |
||
131 | */ |
||
132 | 6 | public function isTextNode(): bool |
|
136 | } |
||
137 |