Code Duplication    Length = 15-19 lines in 2 locations

src/voku/helper/SimpleHtmlDom.php 2 locations

@@ 618-632 (lines=15) @@
615
        $this->node = $newNode;
616
617
        // Remove head element, preserving child nodes. (again)
618
        if ($newDocument->getIsDOMDocumentCreatedWithoutHeadWrapper()) {
619
            $html = $this->node->parentNode->getElementsByTagName('head')[0];
620
            if ($this->node->parentNode->ownerDocument !== null) {
621
                $fragment = $this->node->parentNode->ownerDocument->createDocumentFragment();
622
                if ($html !== null) {
623
                    /** @var DOMNode $html */
624
                    while ($html->childNodes->length > 0) {
625
                        /** @noinspection UnusedFunctionResultInspection */
626
                        $fragment->appendChild($html->childNodes->item(0));
627
                    }
628
                    /** @noinspection UnusedFunctionResultInspection */
629
                    $html->parentNode->replaceChild($fragment, $html);
630
                }
631
            }
632
        }
633
634
        return $this;
635
    }
@@ 735-753 (lines=19) @@
732
        }
733
734
        // Remove head element, preserving child nodes.
735
        if (
736
            $removeExtraHeadTag
737
            &&
738
            $newDocument->getIsDOMDocumentCreatedWithoutHeadWrapper()
739
        ) {
740
            $html = $this->node->parentNode->getElementsByTagName('head')[0];
741
            if ($this->node->parentNode->ownerDocument !== null) {
742
                $fragment = $this->node->parentNode->ownerDocument->createDocumentFragment();
743
                if ($html !== null) {
744
                    /** @var DOMNode $html */
745
                    while ($html->childNodes->length > 0) {
746
                        /** @noinspection UnusedFunctionResultInspection */
747
                        $fragment->appendChild($html->childNodes->item(0));
748
                    }
749
                    /** @noinspection UnusedFunctionResultInspection */
750
                    $html->parentNode->replaceChild($fragment, $html);
751
                }
752
            }
753
        }
754
755
        return $newDocument;
756
    }