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