summaryrefslogtreecommitdiff
path: root/src/Configuration.php
diff options
context:
space:
mode:
authorAndres Rey <[email protected]>2018-03-12 11:25:40 +0000
committerAndres Rey <[email protected]>2018-03-12 11:25:40 +0000
commitbe43476deba57236480929b9f9100633d2678e67 (patch)
treeabd919eb3faab7dbb974ced4642a41dde1b8b791 /src/Configuration.php
parent3dead0a9e4864ab19903cc452c502014a9c4e48b (diff)
parent081f66134e464082de0299494e0adb4160cb536a (diff)
Merge branch 'master' into development
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 de3d16a..a0f363f 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()
@@ -286,9 +333,4 @@ class Configuration
return $this;
}
-
- /**
- * @var bool
- */
- protected $summonCthulhu = false;
}