Code Duplication    Length = 15-19 lines in 2 locations

src/voku/helper/SimpleHtmlDom.php 2 locations

@@ 606-620 (lines=15) @@
603
        $this->node = $newNode;
604
605
        // Remove head element, preserving child nodes. (again)
606
        if ($newDocument->getIsDOMDocumentCreatedWithoutHeadWrapper() === true) {
607
            $html = $this->node->parentNode->getElementsByTagName('head')[0];
608
            if ($this->node->parentNode->ownerDocument !== null) {
609
                $fragment = $this->node->parentNode->ownerDocument->createDocumentFragment();
610
                if ($html !== null) {
611
                    /** @var DOMNode $html */
612
                    while ($html->childNodes->length > 0) {
613
                        /** @noinspection UnusedFunctionResultInspection */
614
                        $fragment->appendChild($html->childNodes->item(0));
615
                    }
616
                    /** @noinspection UnusedFunctionResultInspection */
617
                    $html->parentNode->replaceChild($fragment, $html);
618
                }
619
            }
620
        }
621
622
        return $this;
623
    }
@@ 723-741 (lines=19) @@
720
        }
721
722
        // Remove head element, preserving child nodes.
723
        if (
724
            $removeExtraHeadTag === true
725
            &&
726
            $newDocument->getIsDOMDocumentCreatedWithoutHeadWrapper() === true
727
        ) {
728
            $html = $this->node->parentNode->getElementsByTagName('head')[0];
729
            if ($this->node->parentNode->ownerDocument !== null) {
730
                $fragment = $this->node->parentNode->ownerDocument->createDocumentFragment();
731
                if ($html !== null) {
732
                    /** @var DOMNode $html */
733
                    while ($html->childNodes->length > 0) {
734
                        /** @noinspection UnusedFunctionResultInspection */
735
                        $fragment->appendChild($html->childNodes->item(0));
736
                    }
737
                    /** @noinspection UnusedFunctionResultInspection */
738
                    $html->parentNode->replaceChild($fragment, $html);
739
                }
740
            }
741
        }
742
743
        return $newDocument;
744
    }