Code Duplication    Length = 15-19 lines in 2 locations

src/voku/helper/SimpleHtmlDom.php 2 locations

@@ 667-681 (lines=15) @@
664
        $this->node = $newNode;
665
666
        // Remove head element, preserving child nodes. (again)
667
        if ($newDocument->getIsDOMDocumentCreatedWithoutHeadWrapper()) {
668
            $html = $this->node->parentNode->getElementsByTagName('head')[0];
669
            if ($this->node->parentNode->ownerDocument !== null) {
670
                $fragment = $this->node->parentNode->ownerDocument->createDocumentFragment();
671
                if ($html !== null) {
672
                    /** @var DOMNode $html */
673
                    while ($html->childNodes->length > 0) {
674
                        /** @noinspection UnusedFunctionResultInspection */
675
                        $fragment->appendChild($html->childNodes->item(0));
676
                    }
677
                    /** @noinspection UnusedFunctionResultInspection */
678
                    $html->parentNode->replaceChild($fragment, $html);
679
                }
680
            }
681
        }
682
683
        return $this;
684
    }
@@ 784-802 (lines=19) @@
781
        }
782
783
        // Remove head element, preserving child nodes.
784
        if (
785
            $removeExtraHeadTag
786
            &&
787
            $newDocument->getIsDOMDocumentCreatedWithoutHeadWrapper()
788
        ) {
789
            $html = $this->node->parentNode->getElementsByTagName('head')[0];
790
            if ($this->node->parentNode->ownerDocument !== null) {
791
                $fragment = $this->node->parentNode->ownerDocument->createDocumentFragment();
792
                if ($html !== null) {
793
                    /** @var DOMNode $html */
794
                    while ($html->childNodes->length > 0) {
795
                        /** @noinspection UnusedFunctionResultInspection */
796
                        $fragment->appendChild($html->childNodes->item(0));
797
                    }
798
                    /** @noinspection UnusedFunctionResultInspection */
799
                    $html->parentNode->replaceChild($fragment, $html);
800
                }
801
            }
802
        }
803
804
        return $newDocument;
805
    }