From 460e936bff25821ecb2685be54468390c8ddb4de Mon Sep 17 00:00:00 2001 From: Andres Rey Date: Fri, 1 Dec 2017 17:46:38 +0000 Subject: Minor cleanup --- src/NodeClass/NodeClassTrait.php | 2 +- src/Readability.php | 11 ++++------- 2 files changed, 5 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/NodeClass/NodeClassTrait.php b/src/NodeClass/NodeClassTrait.php index f2df51a..4c1442b 100644 --- a/src/NodeClass/NodeClassTrait.php +++ b/src/NodeClass/NodeClassTrait.php @@ -286,7 +286,7 @@ trait NodeClassTrait /** * Creates a new node based on the text content of the original node. * - * @param $originalNode DOMElement + * @param $originalNode DOMNode * @param $tagName string * * @return DOMElement diff --git a/src/Readability.php b/src/Readability.php index 10235df..ea1595a 100644 --- a/src/Readability.php +++ b/src/Readability.php @@ -596,14 +596,14 @@ class Readability /* * Check if the byline is already set */ - if (isset($this->metadata['byline'])) { + if ($this->getAuthor()) { return false; } $rel = $node->getAttribute('rel'); if ($rel === 'author' || preg_match(NodeUtility::$regexps['byline'], $matchString) && $this->isValidByline($node->getTextContent())) { - $this->metadata['byline'] = trim($node->getTextContent()); + $this->setAuthor(trim($node->getTextContent())); return true; } @@ -817,7 +817,6 @@ class Readability } $topCandidate = isset($topCandidates[0]) ? $topCandidates[0] : null; - $neededToCreateTopCandidate = false; $parentOfTopCandidate = null; /* @@ -923,7 +922,7 @@ class Readability $hasContent = false; - /** @var Readability $sibling */ + /** @var DOMElement $sibling */ foreach ($siblings as $sibling) { $append = false; @@ -1137,7 +1136,7 @@ class Readability * Remove the style attribute on every e and under. * TODO: To be moved to Readability. * - * @param $node \DOMDocument|\DOMNode + * @param $node DOMDocument|DOMNode **/ public function _cleanStyles($node) { @@ -1213,7 +1212,6 @@ class Readability $totalCount = $imgCount + $embedCount + $objectCount + $iframeCount; if ($totalCount === 0 && !preg_replace(NodeUtility::$regexps['onlyWhitespace'], '', $paragraph->textContent)) { - // TODO must be done via readability $paragraph->parentNode->removeChild($paragraph); } } @@ -1268,7 +1266,6 @@ class Readability * ominous signs, remove the element. */ - // TODO Horrible hack, must be removed once this function is inside Readability $p = $node->getElementsByTagName('p')->length; $img = $node->getElementsByTagName('img')->length; $li = $node->getElementsByTagName('li')->length - 100; -- cgit v1.2.3