summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndres Rey <[email protected]>2018-09-01 15:32:40 +0100
committerAndres Rey <[email protected]>2018-09-01 15:32:40 +0100
commitfc09c2fb5ce824adf9c0e4e53b631197c9cdc98d (patch)
tree2be149bbf3787fb90483d3396349c46c367d7031 /src
parent2695ce5d4fbd424406535e06273e1ffda264f663 (diff)
Rename wordThreshold to charThreshold and throw deprecation notices
Diffstat (limited to 'src')
-rw-r--r--src/Configuration.php36
-rw-r--r--src/Readability.php4
2 files changed, 33 insertions, 7 deletions
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);