From fc09c2fb5ce824adf9c0e4e53b631197c9cdc98d Mon Sep 17 00:00:00 2001 From: Andres Rey Date: Sat, 1 Sep 2018 15:32:40 +0100 Subject: Rename wordThreshold to charThreshold and throw deprecation notices --- src/Configuration.php | 36 +++++++++++++++++++++++++++++++----- src/Readability.php | 4 ++-- 2 files changed, 33 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/Configuration.php b/src/Configuration.php index 951740e..65905b8 100644 --- a/src/Configuration.php +++ b/src/Configuration.php @@ -21,7 +21,7 @@ class Configuration /** * @var int */ - protected $wordThreshold = 500; + protected $charThreshold = 500; /** * @var bool @@ -149,19 +149,45 @@ class Configuration /** * @return int */ + public function getCharThreshold() + { + return $this->charThreshold; + } + + /** + * @param int $charThreshold + * + * @return $this + */ + public function setCharThreshold($charThreshold) + { + $this->charThreshold = $charThreshold; + + return $this; + } + + /** + * @deprecated Use getCharThreshold. Will be removed in version 2.0 + * + * @return int + */ public function getWordThreshold() { - return $this->wordThreshold; + @trigger_error('getWordThreshold was replaced with getCharThreshold and will be removed in version 2.0', E_USER_DEPRECATED); + + return $this->charThreshold; } /** - * @param int $wordThreshold + * @param int $charThreshold * * @return $this */ - public function setWordThreshold($wordThreshold) + public function setWordThreshold($charThreshold) { - $this->wordThreshold = $wordThreshold; + @trigger_error('setWordThreshold was replaced with setCharThreshold and will be removed in version 2.0', E_USER_DEPRECATED); + + $this->charThreshold = $charThreshold; return $this; } diff --git a/src/Readability.php b/src/Readability.php index b8b5b5b..c7c3d50 100644 --- a/src/Readability.php +++ b/src/Readability.php @@ -164,9 +164,9 @@ class Readability $length = mb_strlen(preg_replace(NodeUtility::$regexps['onlyWhitespace'], '', $result->textContent)); - $this->logger->info(sprintf('[Parsing] Article parsed. Amount of words: %s. Current threshold is: %s', $length, $this->configuration->getWordThreshold())); + $this->logger->info(sprintf('[Parsing] Article parsed. Amount of words: %s. Current threshold is: %s', $length, $this->configuration->getCharThreshold())); - if ($result && $length < $this->configuration->getWordThreshold()) { + if ($result && $length < $this->configuration->getCharThreshold()) { $this->dom = $this->loadHTML($html); $root = $this->dom->getElementsByTagName('body')->item(0); -- cgit v1.2.3