src/Extractor/ContentExtractor.php
private function extractAuthor($detectAuthor, \DOMNode $node)
    {
        if (false === $detectAuthor) {
            return false;
        }

        // check for time element with pubdate attribute
        $elems = $this->xpath->query(".//*[contains(concat(' ',normalize-space(@class),' '),' vcard ') and (contains(concat(' ',normalize-space(@class),' '),' author ') or contains(concat(' ',normalize-space(@class),' '),' byline '))]", $node);

        if ($elems && $elems->length > 0) {
            $author = $elems->item(0);
            $fns = $this->xpath->query(".//*[contains(concat(' ',normalize-space(@class),' '),' fn ')]", $author);

            if ($fns && $fns->length > 0) {
                foreach ($fns as $fn) {
                    if ('' !== trim($fn->textContent)) {
                        $this->addAuthor($fn->textContent);
                        $this->logger->info('hNews: found author: ' . trim($fn->textContent));
                    }
                }
            } else {
                if ('' !== trim($author->textContent)) {
                    $this->addAuthor($author->textContent);
                    $this->logger->info('hNews: found author: ' . trim($author->textContent));
                }
            }

            return empty($this->authors);
        }

        return true;
    }
private function extractAuthor($detectAuthor, \DOMNode $node)
    {
        if (false === $detectAuthor) {
            return false;
        }

        // check for time element with pubdate attribute
        $elems = $this->xpath->query(".//*[contains(concat(' ',normalize-space(@class),' '),' vcard ') and (contains(concat(' ',normalize-space(@class),' '),' author ') or contains(concat(' ',normalize-space(@class),' '),' byline '))]", $node);

        if ($elems && $elems->length > 0) {
            $author = $elems->item(0);
            $fns = $this->xpath->query(".//*[contains(concat(' ',normalize-space(@class),' '),' fn ')]", $author);

            if ($fns && $fns->length > 0) {
                foreach ($fns as $fn) {
                    if ('' !== trim($fn->textContent)) {
                        $this->addAuthor($fn->textContent);
                        $this->logger->info('hNews: found author: ' . trim($fn->textContent));
                    }
                }
            } else {
                if ('' !== trim($author->textContent)) {
                    $this->addAuthor($author->textContent);
                    $this->logger->info('hNews: found author: ' . trim($author->textContent));
                }
            }

            return empty($this->authors);
        }

        return true;
    }
private function extractAuthor ( $ detectAuthor , \ DOMNode $ node ) { if ( false === $ detectAuthor ) { return false ; } // check for time element with pubdate attribute $ elems = $ this -> xpath -> query ( ".//*[contains(concat(' ',normalize-space(@class),' '),' vcard ') and (contains(concat(' ',normalize-space(@class),' '),' author ') or contains(concat(' ',normalize-space(@class),' '),' byline '))]" , $ node ) ; if ( $ elems && $ elems -> length > 0 ) { $ author = $ elems -> item ( 0 ) ; $ fns = $ this -> xpath -> query ( ".//*[contains(concat(' ',normalize-space(@class),' '),' fn ')]" , $ author ) ; if ( $ fns && $ fns -> length > 0 ) { foreach ( $ fns as $ fn ) { if ( '' !== trim ( $ fn -> textContent ) ) { $ this -> addAuthor ( $ fn -> textContent ) ; $ this -> logger -> info ( 'hNews: found author: ' . trim ( $ fn -> textContent ) ) ; } } } else { if ( '' !== trim ( $ author -> textContent ) ) { $ this -> addAuthor ( $ author -> textContent ) ; $ this -> logger -> info ( 'hNews: found author: ' . trim ( $ author -> textContent ) ) ; } } return empty ( $ this -> authors ) ; } return true ; }
Extract author.

@param bool     $detectAuthor Do we have to detect author ?
@param \DOMNode $node         DOMNode to look into

@return bool Telling if we have to detect author again or not
Extract author .