diff options
author | Andres Rey <[email protected]> | 2016-11-04 19:07:53 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2016-11-04 19:07:53 +0000 |
commit | 14d5e061833fdf8de4254c7c3a94fb43acd1b13f (patch) | |
tree | 6e6a4b40288386bff0c0230f060a2b91f14a4531 /src/Readability.php | |
parent | 891568a88b24b82d1388c6fe73b3722980bfc1d7 (diff) | |
parent | 0b45ceb23a135364275ad5ce20045d0a204a5e57 (diff) |
Merge pull request #5 from andreskrey/analysis-zRYB7D
Applied fixes from StyleCI
Diffstat (limited to 'src/Readability.php')
-rw-r--r-- | src/Readability.php | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/Readability.php b/src/Readability.php index 39e1a28..ed1d2be 100644 --- a/src/Readability.php +++ b/src/Readability.php @@ -146,8 +146,9 @@ class Readability extends Element implements ReadabilityInterface } else { $links = []; foreach ($this->node->getElementsByTagName('a') as $link) { - $links[] = new Readability($link); - }; + $links[] = new self($link); + } + return $links; } } @@ -259,7 +260,7 @@ class Readability extends Element implements ReadabilityInterface if (get_class($this->node) !== 'DOMDocument') { // To prevent the -0 value - $this->contentScore = ($score === (double)-0) ? 0 : $score; + $this->contentScore = ($score === (float) -0) ? 0 : $score; // Set score in an attribute of the tag to prevent losing it while creating new Readability objects. $this->node->setAttribute('readability', $this->contentScore); @@ -283,11 +284,12 @@ class Readability extends Element implements ReadabilityInterface if ($normalize) { $nodeValue = trim(preg_replace('/\s{2,}/', ' ', $nodeValue)); } + return $nodeValue; } /** - * Sets the node name + * Sets the node name. * * @param string $value */ @@ -297,7 +299,7 @@ class Readability extends Element implements ReadabilityInterface } /** - * Returns the current DOMNode + * Returns the current DOMNode. * * @return \DOMNode */ @@ -310,12 +312,13 @@ class Readability extends Element implements ReadabilityInterface { $nextNode = $this->getNextNode($node, true); $nextNode->node->parentNode->removeChild($node->node); + return $nextNode; } public function getNextNode($originalNode, $ignoreSelfAndKids = false) { - /** + /* * Traverse the DOM from node to node, starting at the node passed in. * Pass true for the second parameter to indicate this node itself * (and its kids) are going away, and we want the next node over. |