aboutsummaryrefslogtreecommitdiff
path: root/src/NXP/Classes/TokenFactory.php
diff options
context:
space:
mode:
authorBruce Wells <phpfui@users.noreply.github.com>2018-10-31 16:51:19 +0300
committerGitHub <noreply@github.com>2018-10-31 16:51:19 +0300
commit07d02e1fb0aeb9fca7174a065f61a5fa2643b12f (patch)
tree86f215d0c7187843e863e7a980ae81943e7d4a5f /src/NXP/Classes/TokenFactory.php
parent43f0ff3f28d198fbb4e36346fc5f36fa91cf3e18 (diff)
parentf0d4562b9ef3bbc64cb8353f0597e639420ede6b (diff)
Merge branch 'master' into master
Diffstat (limited to 'src/NXP/Classes/TokenFactory.php')
-rw-r--r--src/NXP/Classes/TokenFactory.php33
1 files changed, 32 insertions, 1 deletions
diff --git a/src/NXP/Classes/TokenFactory.php b/src/NXP/Classes/TokenFactory.php
index d70dd55..6956f31 100644
--- a/src/NXP/Classes/TokenFactory.php
+++ b/src/NXP/Classes/TokenFactory.php
@@ -35,6 +35,13 @@ class TokenFactory
protected $operators = [];
/**
+ * Divide by zero reporting
+ *
+ * @var bool
+ */
+ protected $divideByZeroReporting = false;
+
+ /**
* Available functions
*
* @var array
@@ -91,6 +98,29 @@ class TokenFactory
}
/**
+ * Set division by zero exception reporting
+ *
+ * @param bool $exception default true
+ *
+ * @return TokenFactory
+ */
+ public function setDivisionByZeroException($exception = true)
+ {
+ $this->divideByZeroReporting = $exception;
+ return $this;
+ }
+
+ /**
+ * Get division by zero exception status
+ *
+ * @return bool
+ */
+ public function getDivisionByZeroException()
+ {
+ return $this->divideByZeroReporting;
+ }
+
+ /**
* @return string
*/
public function getTokenParserRegex()
@@ -143,7 +173,8 @@ class TokenFactory
foreach ($this->operators as $operator) {
$regex = sprintf('/%s/i', $operator::getRegex());
if (preg_match($regex, $token)) {
- return new $operator;
+ $op = new $operator;
+ return $op->setDivisionByZeroException($this->getDivisionByZeroException());
}
}