Code Duplication    Length = 16-16 lines in 2 locations

src/voku/helper/SimpleHtmlDom.php 2 locations

@@ 809-824 (lines=16) @@
806
            if ($newDocument->getIsDOMDocumentCreatedWithoutPTagWrapper()) {
807
                // Remove <p>-element, preserving child nodes.
808
                $pElement = $newDocument->getDocument()->getElementsByTagName('p')->item(0);
809
                if ($pElement instanceof \DOMElement) {
810
                    $fragment = $newDocument->getDocument()->createDocumentFragment();
811
812
                    while ($pElement->childNodes->length > 0) {
813
                        $tmpNode = $pElement->childNodes->item(0);
814
                        if ($tmpNode !== null) {
815
                            /** @noinspection UnusedFunctionResultInspection */
816
                            $fragment->appendChild($tmpNode);
817
                        }
818
                    }
819
820
                    if ($pElement->parentNode !== null) {
821
                        /** @noinspection UnusedFunctionResultInspection */
822
                        $pElement->parentNode->replaceChild($fragment, $pElement);
823
                    }
824
                }
825
            }
826
827
            // Remove <body>-element, preserving child nodes.
@@ 829-844 (lines=16) @@
826
827
            // Remove <body>-element, preserving child nodes.
828
            $body = $newDocument->getDocument()->getElementsByTagName('body')->item(0);
829
            if ($body instanceof \DOMElement) {
830
                $fragment = $newDocument->getDocument()->createDocumentFragment();
831
832
                while ($body->childNodes->length > 0) {
833
                    $tmpNode = $body->childNodes->item(0);
834
                    if ($tmpNode !== null) {
835
                        /** @noinspection UnusedFunctionResultInspection */
836
                        $fragment->appendChild($tmpNode);
837
                    }
838
                }
839
840
                if ($body->parentNode !== null) {
841
                    /** @noinspection UnusedFunctionResultInspection */
842
                    $body->parentNode->replaceChild($fragment, $body);
843
                }
844
            }
845
        }
846
847
        // Remove head element, preserving child nodes.