summaryrefslogtreecommitdiff
path: root/src/Configuration.php
diff options
context:
space:
mode:
authorAndres Rey <[email protected]>2018-03-18 19:36:53 +0000
committerAndres Rey <[email protected]>2018-03-18 19:36:53 +0000
commit1093b0a804ba48c146367b0bec45e33eb9b77116 (patch)
tree2d2f9fc245142a8fe71d7ba959ac0f063dd07a56 /src/Configuration.php
parent765466aec50e17ce3c0a4c138f712b76b8124305 (diff)
parentf0f69065301d640ccf7308cff7c1eb006d03ef45 (diff)
Merge branch 'master' into update-to-8525c6a
Diffstat (limited to 'src/Configuration.php')
-rw-r--r--src/Configuration.php52
1 files changed, 47 insertions, 5 deletions
diff --git a/src/Configuration.php b/src/Configuration.php
index b7f1f85..951740e 100644
--- a/src/Configuration.php
+++ b/src/Configuration.php
@@ -17,44 +17,91 @@ class Configuration
* @var int
*/
protected $maxTopCandidates = 5;
+
/**
* @var int
*/
protected $wordThreshold = 500;
+
/**
* @var bool
*/
protected $articleByLine = false;
+
/**
* @var bool
*/
protected $stripUnlikelyCandidates = true;
+
/**
* @var bool
*/
protected $cleanConditionally = true;
+
/**
* @var bool
*/
protected $weightClasses = true;
+
/**
* @var bool
*/
protected $fixRelativeURLs = false;
+
/**
* @var bool
*/
protected $substituteEntities = false;
+
/**
* @var bool
*/
protected $normalizeEntities = false;
+
+ /**
+ * @var bool
+ */
+ protected $summonCthulhu = false;
+
/**
* @var string
*/
protected $originalURL = 'http://fakehost';
/**
+ * Configuration constructor.
+ *
+ * @param array $params
+ */
+ public function __construct(array $params = [])
+ {
+ foreach ($params as $key => $value) {
+ $setter = sprintf('set%s', $key);
+ if (method_exists($this, $setter)) {
+ call_user_func([$this, $setter], $value);
+ }
+ }
+ }
+
+ /**
+ * Returns an array-representation of configuration.
+ *
+ * @return array
+ */
+ public function toArray()
+ {
+ $out = [];
+ foreach ($this as $key => $value) {
+ $getter = sprintf('get%s', $key);
+ if (!is_object($value) && method_exists($this, $getter)) {
+ $out[$key] = call_user_func([$this, $getter]);
+ }
+ }
+
+ return $out;
+ }
+
+ /**
* @return LoggerInterface
*/
public function getLogger()
@@ -298,9 +345,4 @@ class Configuration
return $this;
}
-
- /**
- * @var bool
- */
- protected $summonCthulhu = false;
}