protected function getArticleTitle()
    {
        try {
            $curTitle = $origTitle = $this->getInnerText($this->dom->getElementsByTagName('title')->item(0));
        } catch (\Exception $e) {
            $curTitle = '';
            $origTitle = '';
        }

        if (preg_match('/ [\|\-] /', $curTitle)) {
            $curTitle = preg_replace('/(.*)[\|\-] .*/i', '$1', $origTitle);
            if (\count(explode(' ', $curTitle)) < 3) {
                $curTitle = preg_replace('/[^\|\-]*[\|\-](.*)/i', '$1', $origTitle);
            }
        } elseif (false !== strpos($curTitle, ': ')) {
            $curTitle = preg_replace('/.*:(.*)/i', '$1', $origTitle);
            if (\count(explode(' ', $curTitle)) < 3) {
                $curTitle = preg_replace('/[^:]*[:](.*)/i', '$1', $origTitle);
            }
        } elseif (mb_strlen($curTitle) > 150 || mb_strlen($curTitle) < 15) {
            $hOnes = $this->dom->getElementsByTagName('h1');
            if (1 === $hOnes->length) {
                $curTitle = $this->getInnerText($hOnes->item(0));
            }
        }

        $curTitle = trim($curTitle);
        if (\count(explode(' ', $curTitle)) <= 4) {
            $curTitle = $origTitle;
        }

        $articleTitle = $this->dom->createElement('h1');
        $articleTitle->setInnerHtml($curTitle);

        return $articleTitle;
    }
protected function getArticleTitle()
    {
        try {
            $curTitle = $origTitle = $this->getInnerText($this->dom->getElementsByTagName('title')->item(0));
        } catch (\Exception $e) {
            $curTitle = '';
            $origTitle = '';
        }

        if (preg_match('/ [\|\-] /', $curTitle)) {
            $curTitle = preg_replace('/(.*)[\|\-] .*/i', '$1', $origTitle);
            if (\count(explode(' ', $curTitle)) < 3) {
                $curTitle = preg_replace('/[^\|\-]*[\|\-](.*)/i', '$1', $origTitle);
            }
        } elseif (false !== strpos($curTitle, ': ')) {
            $curTitle = preg_replace('/.*:(.*)/i', '$1', $origTitle);
            if (\count(explode(' ', $curTitle)) < 3) {
                $curTitle = preg_replace('/[^:]*[:](.*)/i', '$1', $origTitle);
            }
        } elseif (mb_strlen($curTitle) > 150 || mb_strlen($curTitle) < 15) {
            $hOnes = $this->dom->getElementsByTagName('h1');
            if (1 === $hOnes->length) {
                $curTitle = $this->getInnerText($hOnes->item(0));
            }
        }

        $curTitle = trim($curTitle);
        if (\count(explode(' ', $curTitle)) <= 4) {
            $curTitle = $origTitle;
        }

        $articleTitle = $this->dom->createElement('h1');
        $articleTitle->setInnerHtml($curTitle);

        return $articleTitle;
    }
protected function getArticleTitle ( ) { try { $ curTitle = $ origTitle = $ this -> getInnerText ( $ this -> dom -> getElementsByTagName ( 'title' ) -> item ( 0 ) ) ; } catch ( \ Exception $ e ) { $ curTitle = '' ; $ origTitle = '' ; } if ( preg_match ( '/ [\|\-] /' , $ curTitle ) ) { $ curTitle = preg_replace ( '/(.*)[\|\-] .*/i' , '$1' , $ origTitle ) ; if ( \ count ( explode ( ' ' , $ curTitle ) ) < 3 ) { $ curTitle = preg_replace ( '/[^\|\-]*[\|\-](.*)/i' , '$1' , $ origTitle ) ; } } elseif ( false !== strpos ( $ curTitle , ': ' ) ) { $ curTitle = preg_replace ( '/.*:(.*)/i' , '$1' , $ origTitle ) ; if ( \ count ( explode ( ' ' , $ curTitle ) ) < 3 ) { $ curTitle = preg_replace ( '/[^:]*[:](.*)/i' , '$1' , $ origTitle ) ; } } elseif ( mb_strlen ( $ curTitle ) > 150 || mb_strlen ( $ curTitle ) < 15 ) { $ hOnes = $ this -> dom -> getElementsByTagName ( 'h1' ) ; if ( 1 === $ hOnes -> length ) { $ curTitle = $ this -> getInnerText ( $ hOnes -> item ( 0 ) ) ; } } $ curTitle = trim ( $ curTitle ) ; if ( \ count ( explode ( ' ' , $ curTitle ) ) <= 4 ) { $ curTitle = $ origTitle ; } $ articleTitle = $ this -> dom -> createElement ( 'h1' ) ; $ articleTitle -> setInnerHtml ( $ curTitle ) ; return $ articleTitle ; }
Get the article title as an H1.

@return \DOMElement
Get the article title as an H1 .