| @@ 344-368 (lines=25) @@ | ||
| 341 | * <p>DOMElement a new instance of class DOMElement or false |
|
| 342 | * if an error occured.</p> |
|
| 343 | */ |
|
| 344 | protected function changeElementName(\DOMNode $node, string $name) |
|
| 345 | { |
|
| 346 | $ownerDocument = $node->ownerDocument; |
|
| 347 | if ($ownerDocument) { |
|
| 348 | $newNode = $ownerDocument->createElement($name); |
|
| 349 | } else { |
|
| 350 | return false; |
|
| 351 | } |
|
| 352 | ||
| 353 | foreach ($node->childNodes as $child) { |
|
| 354 | $child = $ownerDocument->importNode($child, true); |
|
| 355 | /** @noinspection UnusedFunctionResultInspection */ |
|
| 356 | $newNode->appendChild($child); |
|
| 357 | } |
|
| 358 | ||
| 359 | foreach ($node->attributes as $attrName => $attrNode) { |
|
| 360 | /** @noinspection UnusedFunctionResultInspection */ |
|
| 361 | $newNode->setAttribute($attrName, $attrNode); |
|
| 362 | } |
|
| 363 | ||
| 364 | /** @noinspection UnusedFunctionResultInspection */ |
|
| 365 | $newNode->ownerDocument->replaceChild($newNode, $node); |
|
| 366 | ||
| 367 | return $newNode; |
|
| 368 | } |
|
| 369 | ||
| 370 | /** |
|
| 371 | * Returns children of node. |
|
| @@ 318-342 (lines=25) @@ | ||
| 315 | * <p>DOMElement a new instance of class DOMElement or false |
|
| 316 | * if an error occured.</p> |
|
| 317 | */ |
|
| 318 | protected function changeElementName(\DOMNode $node, string $name) |
|
| 319 | { |
|
| 320 | $ownerDocument = $node->ownerDocument; |
|
| 321 | if ($ownerDocument) { |
|
| 322 | $newNode = $ownerDocument->createElement($name); |
|
| 323 | } else { |
|
| 324 | return false; |
|
| 325 | } |
|
| 326 | ||
| 327 | foreach ($node->childNodes as $child) { |
|
| 328 | $child = $ownerDocument->importNode($child, true); |
|
| 329 | /** @noinspection UnusedFunctionResultInspection */ |
|
| 330 | $newNode->appendChild($child); |
|
| 331 | } |
|
| 332 | ||
| 333 | foreach ($node->attributes as $attrName => $attrNode) { |
|
| 334 | /** @noinspection UnusedFunctionResultInspection */ |
|
| 335 | $newNode->setAttribute($attrName, $attrNode); |
|
| 336 | } |
|
| 337 | ||
| 338 | /** @noinspection UnusedFunctionResultInspection */ |
|
| 339 | $newNode->ownerDocument->replaceChild($newNode, $node); |
|
| 340 | ||
| 341 | return $newNode; |
|
| 342 | } |
|
| 343 | ||
| 344 | /** |
|
| 345 | * Returns children of node. |
|