| @@ 284-301 (lines=18) @@ | ||
| 281 | * |
|
| 282 | * @return SimpleHtmlDomInterface |
|
| 283 | */ |
|
| 284 | protected function replaceTextWithString($string): SimpleHtmlDomInterface |
|
| 285 | { |
|
| 286 | if (empty($string)) { |
|
| 287 | $this->node->parentNode->removeChild($this->node); |
|
| 288 | ||
| 289 | return $this; |
|
| 290 | } |
|
| 291 | ||
| 292 | $ownerDocument = $this->node->ownerDocument; |
|
| 293 | if ($ownerDocument !== null) { |
|
| 294 | $newElement = $ownerDocument->createTextNode($string); |
|
| 295 | $newNode = $ownerDocument->importNode($newElement, true); |
|
| 296 | $this->node->parentNode->replaceChild($newNode, $this->node); |
|
| 297 | $this->node = $newNode; |
|
| 298 | } |
|
| 299 | ||
| 300 | return $this; |
|
| 301 | } |
|
| 302 | ||
| 303 | /** |
|
| 304 | * Set attribute value. |
|
| @@ 246-263 (lines=18) @@ | ||
| 243 | * |
|
| 244 | * @return SimpleXmlDomInterface |
|
| 245 | */ |
|
| 246 | protected function replaceTextWithString($string): SimpleXmlDomInterface |
|
| 247 | { |
|
| 248 | if (empty($string)) { |
|
| 249 | $this->node->parentNode->removeChild($this->node); |
|
| 250 | ||
| 251 | return $this; |
|
| 252 | } |
|
| 253 | ||
| 254 | $ownerDocument = $this->node->ownerDocument; |
|
| 255 | if ($ownerDocument !== null) { |
|
| 256 | $newElement = $ownerDocument->createTextNode($string); |
|
| 257 | $newNode = $ownerDocument->importNode($newElement, true); |
|
| 258 | $this->node->parentNode->replaceChild($newNode, $this->node); |
|
| 259 | $this->node = $newNode; |
|
| 260 | } |
|
| 261 | ||
| 262 | return $this; |
|
| 263 | } |
|
| 264 | ||
| 265 | /** |
|
| 266 | * Set attribute value. |
|