| @@ 276-293 (lines=18) @@ | ||
| 273 | * |
|
| 274 | * @return SimpleHtmlDomInterface |
|
| 275 | */ |
|
| 276 | protected function replaceTextWithString($string): SimpleHtmlDomInterface |
|
| 277 | { |
|
| 278 | if (empty($string)) { |
|
| 279 | $this->node->parentNode->removeChild($this->node); |
|
| 280 | ||
| 281 | return $this; |
|
| 282 | } |
|
| 283 | ||
| 284 | $ownerDocument = $this->node->ownerDocument; |
|
| 285 | if ($ownerDocument !== null) { |
|
| 286 | $newElement = $ownerDocument->createTextNode($string); |
|
| 287 | $newNode = $ownerDocument->importNode($newElement, true); |
|
| 288 | $this->node->parentNode->replaceChild($newNode, $this->node); |
|
| 289 | $this->node = $newNode; |
|
| 290 | } |
|
| 291 | ||
| 292 | return $this; |
|
| 293 | } |
|
| 294 | ||
| 295 | /** |
|
| 296 | * Set attribute value. |
|
| @@ 238-255 (lines=18) @@ | ||
| 235 | * |
|
| 236 | * @return SimpleXmlDomInterface |
|
| 237 | */ |
|
| 238 | protected function replaceTextWithString($string): SimpleXmlDomInterface |
|
| 239 | { |
|
| 240 | if (empty($string)) { |
|
| 241 | $this->node->parentNode->removeChild($this->node); |
|
| 242 | ||
| 243 | return $this; |
|
| 244 | } |
|
| 245 | ||
| 246 | $ownerDocument = $this->node->ownerDocument; |
|
| 247 | if ($ownerDocument !== null) { |
|
| 248 | $newElement = $ownerDocument->createTextNode($string); |
|
| 249 | $newNode = $ownerDocument->importNode($newElement, true); |
|
| 250 | $this->node->parentNode->replaceChild($newNode, $this->node); |
|
| 251 | $this->node = $newNode; |
|
| 252 | } |
|
| 253 | ||
| 254 | return $this; |
|
| 255 | } |
|
| 256 | ||
| 257 | /** |
|
| 258 | * Set attribute value. |
|