Code Duplication    Length = 15-19 lines in 2 locations

src/voku/helper/SimpleHtmlDom.php 2 locations

@@ 691-705 (lines=15) @@
688
        $this->node = $newNode;
689
690
        // Remove head element, preserving child nodes. (again)
691
        if ($newDocument->getIsDOMDocumentCreatedWithoutHeadWrapper()) {
692
            $html = $this->node->parentNode->getElementsByTagName('head')[0];
693
            if ($this->node->parentNode->ownerDocument !== null) {
694
                $fragment = $this->node->parentNode->ownerDocument->createDocumentFragment();
695
                if ($html !== null) {
696
                    /** @var DOMNode $html */
697
                    while ($html->childNodes->length > 0) {
698
                        /** @noinspection UnusedFunctionResultInspection */
699
                        $fragment->appendChild($html->childNodes->item(0));
700
                    }
701
                    /** @noinspection UnusedFunctionResultInspection */
702
                    $html->parentNode->replaceChild($fragment, $html);
703
                }
704
            }
705
        }
706
707
        return $this;
708
    }
@@ 808-826 (lines=19) @@
805
        }
806
807
        // Remove head element, preserving child nodes.
808
        if (
809
            $removeExtraHeadTag
810
            &&
811
            $newDocument->getIsDOMDocumentCreatedWithoutHeadWrapper()
812
        ) {
813
            $html = $this->node->parentNode->getElementsByTagName('head')[0];
814
            if ($this->node->parentNode->ownerDocument !== null) {
815
                $fragment = $this->node->parentNode->ownerDocument->createDocumentFragment();
816
                if ($html !== null) {
817
                    /** @var DOMNode $html */
818
                    while ($html->childNodes->length > 0) {
819
                        /** @noinspection UnusedFunctionResultInspection */
820
                        $fragment->appendChild($html->childNodes->item(0));
821
                    }
822
                    /** @noinspection UnusedFunctionResultInspection */
823
                    $html->parentNode->replaceChild($fragment, $html);
824
                }
825
            }
826
        }
827
828
        return $newDocument;
829
    }