summaryrefslogtreecommitdiff
path: root/src/Readability.php
diff options
context:
space:
mode:
authorAndres Rey <[email protected]>2016-11-13 10:01:58 +0000
committerAndres Rey <[email protected]>2016-11-13 10:01:58 +0000
commit1490fc0ed8422f117fbc2a1a99039993a2161297 (patch)
tree1200f09e21a92531c8c7a34288601f373000566f /src/Readability.php
parent95d03a8f87144227d4d2c8676970e650dd450ad9 (diff)
Fixed a small bug where content score was set directly to the object property instead through the proper function.
Diffstat (limited to 'src/Readability.php')
-rw-r--r--src/Readability.php14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/Readability.php b/src/Readability.php
index d99ab29..37ac790 100644
--- a/src/Readability.php
+++ b/src/Readability.php
@@ -49,7 +49,7 @@ class Readability extends Element implements ReadabilityInterface
$score = 0;
if (!in_array(get_class($node), ['DOMDocument', 'DOMComment'])) {
- $score = $node->getAttribute('readability');
+ $score = $node->getAttribute('readability');
}
$this->setContentScore(($score) ? $score : 0);
@@ -160,15 +160,17 @@ class Readability extends Element implements ReadabilityInterface
*/
public function initializeNode()
{
+ $contentScore = 0;
+
switch ($this->getTagName()) {
case 'div':
- $this->contentScore += 5;
+ $contentScore += 5;
break;
case 'pre':
case 'td':
case 'blockquote':
- $this->contentScore += 3;
+ $contentScore += 3;
break;
case 'address':
@@ -179,7 +181,7 @@ class Readability extends Element implements ReadabilityInterface
case 'dt':
case 'li':
case 'form':
- $this->contentScore -= 3;
+ $contentScore -= 3;
break;
case 'h1':
@@ -189,11 +191,11 @@ class Readability extends Element implements ReadabilityInterface
case 'h5':
case 'h6':
case 'th':
- $this->contentScore -= 5;
+ $contentScore -= 5;
break;
}
- $this->contentScore += $this->getClassWeight();
+ $this->setContentScore($contentScore + $this->getClassWeight());
return $this;
}