@@ 296-316 (lines=21) @@ | ||
293 | * |
|
294 | * @return SimpleHtmlDomInterface |
|
295 | */ |
|
296 | protected function replaceTextWithString($string): SimpleHtmlDomInterface |
|
297 | { |
|
298 | if (empty($string)) { |
|
299 | if ($this->node->parentNode) { |
|
300 | $this->node->parentNode->removeChild($this->node); |
|
301 | } |
|
302 | $this->node = new \DOMText(); |
|
303 | ||
304 | return $this; |
|
305 | } |
|
306 | ||
307 | $ownerDocument = $this->node->ownerDocument; |
|
308 | if ($ownerDocument) { |
|
309 | $newElement = $ownerDocument->createTextNode($string); |
|
310 | $newNode = $ownerDocument->importNode($newElement, true); |
|
311 | $this->node->parentNode->replaceChild($newNode, $this->node); |
|
312 | $this->node = $newNode; |
|
313 | } |
|
314 | ||
315 | return $this; |
|
316 | } |
|
317 | ||
318 | /** |
|
319 | * Set attribute value. |
@@ 254-273 (lines=20) @@ | ||
251 | * |
|
252 | * @return SimpleXmlDomInterface |
|
253 | */ |
|
254 | protected function replaceTextWithString($string): SimpleXmlDomInterface |
|
255 | { |
|
256 | if (empty($string)) { |
|
257 | if ($this->node->parentNode) { |
|
258 | $this->node->parentNode->removeChild($this->node); |
|
259 | } |
|
260 | ||
261 | return $this; |
|
262 | } |
|
263 | ||
264 | $ownerDocument = $this->node->ownerDocument; |
|
265 | if ($ownerDocument) { |
|
266 | $newElement = $ownerDocument->createTextNode($string); |
|
267 | $newNode = $ownerDocument->importNode($newElement, true); |
|
268 | $this->node->parentNode->replaceChild($newNode, $this->node); |
|
269 | $this->node = $newNode; |
|
270 | } |
|
271 | ||
272 | return $this; |
|
273 | } |
|
274 | ||
275 | /** |
|
276 | * Set attribute value. |