From bb65caf864b1828a93f6844819ebf4fb0a5eeac5 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Sat, 11 May 2019 21:58:11 +0200 Subject: [PATCH] =?UTF-8?q?Fix=20=E2=80=9CA=20non=20well=20formed=20numeri?= =?UTF-8?q?c=20value=20encountered=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Readability.php | 4 ++-- tests/ReadabilityTest.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Readability.php b/src/Readability.php index 3916055..4a855ca 100644 --- a/src/Readability.php +++ b/src/Readability.php @@ -61,7 +61,7 @@ class Readability implements LoggerAwareInterface // constants const SCORE_CHARS_IN_PARAGRAPH = 100; const SCORE_WORDS_IN_PARAGRAPH = 20; - const GRANDPARENT_SCORE_DIVISOR = 2.2; + const GRANDPARENT_SCORE_DIVISOR = 2; const MIN_PARAGRAPH_LENGTH = 20; const MIN_COMMAS_IN_PARAGRAPH = 6; const MIN_ARTICLE_LENGTH = 200; @@ -1115,7 +1115,7 @@ class Readability implements LoggerAwareInterface // Add the score to the parent. The grandparent gets half. $parentNode->getAttributeNode('readability')->value += $contentScore; if ($grandParentNode) { - $grandParentNode->getAttributeNode('readability')->value += $contentScore / self::GRANDPARENT_SCORE_DIVISOR; + $grandParentNode->getAttributeNode('readability')->value += round($contentScore / self::GRANDPARENT_SCORE_DIVISOR); } } diff --git a/tests/ReadabilityTest.php b/tests/ReadabilityTest.php index dd58990..3be09c5 100644 --- a/tests/ReadabilityTest.php +++ b/tests/ReadabilityTest.php @@ -193,7 +193,7 @@ class ReadabilityTest extends \PHPUnit\Framework\TestCase $this->assertEmpty($readability->getTitle()->getInnerHtml()); $this->assertContains('This is an awesome text with some links, here there are', $readability->getContent()->getInnerHtml()); $this->assertNotContains('