Code Duplication    Length = 8-9 lines in 2 locations

src/voku/helper/SimpleHtmlDom.php 2 locations

@@ 633-640 (lines=8) @@
630
            // Remove html element, preserving child nodes.
631
            $html = $newDocument->getDocument()->getElementsByTagName('html')->item(0);
632
            $fragment = $newDocument->getDocument()->createDocumentFragment();
633
            if ($html !== null) {
634
                while ($html->childNodes->length > 0) {
635
                    /** @noinspection UnusedFunctionResultInspection */
636
                    $fragment->appendChild($html->childNodes->item(0));
637
                }
638
                /** @noinspection UnusedFunctionResultInspection */
639
                $html->parentNode->replaceChild($fragment, $html);
640
            }
641
642
            // Remove body element, preserving child nodes.
643
            $body = $newDocument->getDocument()->getElementsByTagName('body')->item(0);
@@ 672-680 (lines=9) @@
669
            $html = $this->node->parentNode->getElementsByTagName('head')[0];
670
            if ($this->node->parentNode->ownerDocument !== null) {
671
                $fragment = $this->node->parentNode->ownerDocument->createDocumentFragment();
672
                if ($html !== null) {
673
                    /** @var DOMNode $html */
674
                    while ($html->childNodes->length > 0) {
675
                        /** @noinspection UnusedFunctionResultInspection */
676
                        $fragment->appendChild($html->childNodes->item(0));
677
                    }
678
                    /** @noinspection UnusedFunctionResultInspection */
679
                    $html->parentNode->replaceChild($fragment, $html);
680
                }
681
            }
682
        }
683