private function addHeadElementIfMissing(): bool
    {
        if ($this->getElementsByTagName('head')->length === 0) {
            $htmlElement = $this->getElementsByTagName('html')->item(0);
            if (!isset(self::$newObjectsCache['headelement'])) {
                self::$newObjectsCache['headelement'] = new \DOMElement('head');
            }
            $headElement = clone(self::$newObjectsCache['headelement']);
            if ($htmlElement->firstChild === null) {
                $htmlElement->appendChild($headElement);
            } else {
                $htmlElement->insertBefore($headElement, $htmlElement->firstChild);
            }
            return true;
        }
        return false;
    }
private function addHeadElementIfMissing(): bool
    {
        if ($this->getElementsByTagName('head')->length === 0) {
            $htmlElement = $this->getElementsByTagName('html')->item(0);
            if (!isset(self::$newObjectsCache['headelement'])) {
                self::$newObjectsCache['headelement'] = new \DOMElement('head');
            }
            $headElement = clone(self::$newObjectsCache['headelement']);
            if ($htmlElement->firstChild === null) {
                $htmlElement->appendChild($headElement);
            } else {
                $htmlElement->insertBefore($headElement, $htmlElement->firstChild);
            }
            return true;
        }
        return false;
    }
private function addHeadElementIfMissing ( ) : bool { if ( $ this -> getElementsByTagName ( 'head' ) -> length === 0 ) { $ htmlElement = $ this -> getElementsByTagName ( 'html' ) -> item ( 0 ) ; if ( ! isset ( self :: $ newObjectsCache [ 'headelement' ] ) ) { self :: $ newObjectsCache [ 'headelement' ] = new \ DOMElement ( 'head' ) ; } $ headElement = clone ( self :: $ newObjectsCache [ 'headelement' ] ) ; if ( $ htmlElement -> firstChild === null ) { $ htmlElement -> appendChild ( $ headElement ) ; } else { $ htmlElement -> insertBefore ( $ headElement , $ htmlElement -> firstChild ) ; } return true ; } return false ; }
Adds the HEAD tag to the document if missing.

@return boolean TRUE on success, FALSE otherwise.
Adds the HEAD tag to the document if missing .