@@ 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. |
@@ 294-314 (lines=21) @@ | ||
291 | * |
|
292 | * @return SimpleHtmlDomInterface |
|
293 | */ |
|
294 | protected function replaceTextWithString($string): SimpleHtmlDomInterface |
|
295 | { |
|
296 | if (empty($string)) { |
|
297 | if ($this->node->parentNode) { |
|
298 | $this->node->parentNode->removeChild($this->node); |
|
299 | } |
|
300 | $this->node = new \DOMText(); |
|
301 | ||
302 | return $this; |
|
303 | } |
|
304 | ||
305 | $ownerDocument = $this->node->ownerDocument; |
|
306 | if ($ownerDocument) { |
|
307 | $newElement = $ownerDocument->createTextNode($string); |
|
308 | $newNode = $ownerDocument->importNode($newElement, true); |
|
309 | $this->node->parentNode->replaceChild($newNode, $this->node); |
|
310 | $this->node = $newNode; |
|
311 | } |
|
312 | ||
313 | return $this; |
|
314 | } |
|
315 | ||
316 | /** |
|
317 | * Set attribute value. |