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