Redaxscript\Filter\Html::_cleanDocument PHP Метод

_cleanDocument() защищенный Метод

clean the document
С версии: 2.6.0
protected _cleanDocument ( DOMDocument $doc ) : DOMDocument
$doc DOMDocument target document
Результат DOMDocument
    protected function _cleanDocument(DOMDocument $doc)
    {
        /* clean document */
        if ($doc->firstChild->nodeType === XML_DOCUMENT_TYPE_NODE) {
            /* remove doctype */
            $doc->removeChild($doc->firstChild);
            /* remove head and body */
            if ($doc->firstChild->firstChild->nodeName === 'head' || $doc->firstChild->firstChild->nodeName === 'body') {
                $doc->replaceChild($doc->firstChild->firstChild->firstChild, $doc->firstChild);
            }
        }
        return $doc;
    }