| @@ 359-385 (lines=27) @@ | ||
| 356 | * <p>DOMElement a new instance of class DOMElement or false |
|
| 357 | * if an error occured.</p> |
|
| 358 | */ |
|
| 359 | protected function changeElementName(\DOMNode $node, string $name) |
|
| 360 | { |
|
| 361 | $ownerDocument = $node->ownerDocument; |
|
| 362 | if ($ownerDocument) { |
|
| 363 | $newNode = $ownerDocument->createElement($name); |
|
| 364 | } else { |
|
| 365 | return false; |
|
| 366 | } |
|
| 367 | ||
| 368 | foreach ($node->childNodes as $child) { |
|
| 369 | $child = $ownerDocument->importNode($child, true); |
|
| 370 | /** @noinspection UnusedFunctionResultInspection */ |
|
| 371 | $newNode->appendChild($child); |
|
| 372 | } |
|
| 373 | ||
| 374 | foreach ($node->attributes ?? [] as $attrName => $attrNode) { |
|
| 375 | /** @noinspection UnusedFunctionResultInspection */ |
|
| 376 | $newNode->setAttribute($attrName, $attrNode); |
|
| 377 | } |
|
| 378 | ||
| 379 | if ($newNode->ownerDocument !== null) { |
|
| 380 | /** @noinspection UnusedFunctionResultInspection */ |
|
| 381 | $newNode->ownerDocument->replaceChild($newNode, $node); |
|
| 382 | } |
|
| 383 | ||
| 384 | return $newNode; |
|
| 385 | } |
|
| 386 | ||
| 387 | /** |
|
| 388 | * Returns children of node. |
|
| @@ 332-358 (lines=27) @@ | ||
| 329 | * <p>DOMElement a new instance of class DOMElement or false |
|
| 330 | * if an error occured.</p> |
|
| 331 | */ |
|
| 332 | protected function changeElementName(\DOMNode $node, string $name) |
|
| 333 | { |
|
| 334 | $ownerDocument = $node->ownerDocument; |
|
| 335 | if ($ownerDocument) { |
|
| 336 | $newNode = $ownerDocument->createElement($name); |
|
| 337 | } else { |
|
| 338 | return false; |
|
| 339 | } |
|
| 340 | ||
| 341 | foreach ($node->childNodes as $child) { |
|
| 342 | $child = $ownerDocument->importNode($child, true); |
|
| 343 | /** @noinspection UnusedFunctionResultInspection */ |
|
| 344 | $newNode->appendChild($child); |
|
| 345 | } |
|
| 346 | ||
| 347 | foreach ($node->attributes ?? [] as $attrName => $attrNode) { |
|
| 348 | /** @noinspection UnusedFunctionResultInspection */ |
|
| 349 | $newNode->setAttribute($attrName, $attrNode); |
|
| 350 | } |
|
| 351 | ||
| 352 | if ($newNode->ownerDocument !== null) { |
|
| 353 | /** @noinspection UnusedFunctionResultInspection */ |
|
| 354 | $newNode->ownerDocument->replaceChild($newNode, $node); |
|
| 355 | } |
|
| 356 | ||
| 357 | return $newNode; |
|
| 358 | } |
|
| 359 | ||
| 360 | /** |
|
| 361 | * Returns children of node. |
|