src/voku/helper/SimpleHtmlDom.php 1 location
|
@@ 291-308 (lines=18) @@
|
| 288 |
|
* |
| 289 |
|
* @return SimpleHtmlDomInterface |
| 290 |
|
*/ |
| 291 |
|
protected function replaceTextWithString($string): SimpleHtmlDomInterface |
| 292 |
|
{ |
| 293 |
|
if (empty($string)) { |
| 294 |
|
$this->node->parentNode->removeChild($this->node); |
| 295 |
|
|
| 296 |
|
return $this; |
| 297 |
|
} |
| 298 |
|
|
| 299 |
|
$ownerDocument = $this->node->ownerDocument; |
| 300 |
|
if ($ownerDocument) { |
| 301 |
|
$newElement = $ownerDocument->createTextNode($string); |
| 302 |
|
$newNode = $ownerDocument->importNode($newElement, true); |
| 303 |
|
$this->node->parentNode->replaceChild($newNode, $this->node); |
| 304 |
|
$this->node = $newNode; |
| 305 |
|
} |
| 306 |
|
|
| 307 |
|
return $this; |
| 308 |
|
} |
| 309 |
|
|
| 310 |
|
/** |
| 311 |
|
* Set attribute value. |
src/voku/helper/SimpleXmlDom.php 1 location
|
@@ 252-269 (lines=18) @@
|
| 249 |
|
* |
| 250 |
|
* @return SimpleXmlDomInterface |
| 251 |
|
*/ |
| 252 |
|
protected function replaceTextWithString($string): SimpleXmlDomInterface |
| 253 |
|
{ |
| 254 |
|
if (empty($string)) { |
| 255 |
|
$this->node->parentNode->removeChild($this->node); |
| 256 |
|
|
| 257 |
|
return $this; |
| 258 |
|
} |
| 259 |
|
|
| 260 |
|
$ownerDocument = $this->node->ownerDocument; |
| 261 |
|
if ($ownerDocument) { |
| 262 |
|
$newElement = $ownerDocument->createTextNode($string); |
| 263 |
|
$newNode = $ownerDocument->importNode($newElement, true); |
| 264 |
|
$this->node->parentNode->replaceChild($newNode, $this->node); |
| 265 |
|
$this->node = $newNode; |
| 266 |
|
} |
| 267 |
|
|
| 268 |
|
return $this; |
| 269 |
|
} |
| 270 |
|
|
| 271 |
|
/** |
| 272 |
|
* Set attribute value. |