diff options
author | Bruce Wells <phpfui@users.noreply.github.com> | 2018-09-12 19:36:15 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-12 19:36:15 +0300 |
commit | 7a36e07736c04e620380fc6657888dca50ad8e31 (patch) | |
tree | 7b58c49eb788554db08ee8402bd014d10dae6b7b /src | |
parent | 00def17f0e9183544813427cddbdaed851986309 (diff) | |
parent | 76d1b4b8f02d555e4b4f4fd4d641597f0f6b5f4e (diff) |
Merge branch 'master' into support_for_double_quoted_strings
Diffstat (limited to 'src')
-rw-r--r-- | src/NXP/Classes/TokenFactory.php | 12 | ||||
-rw-r--r-- | src/NXP/MathExecutor.php | 6 |
2 files changed, 17 insertions, 1 deletions
diff --git a/src/NXP/Classes/TokenFactory.php b/src/NXP/Classes/TokenFactory.php index dbe6624..e5aa865 100644 --- a/src/NXP/Classes/TokenFactory.php +++ b/src/NXP/Classes/TokenFactory.php @@ -64,6 +64,18 @@ class TokenFactory return $this->functions; } + + /** + * get functions + * + * @return array containing callback and places indexed by + * function name + */ + public function getFunctions() + { + return $this->functions; + } + /** * Add operator * @param string $operatorClass diff --git a/src/NXP/MathExecutor.php b/src/NXP/MathExecutor.php index 56cefe5..d62d07a 100644 --- a/src/NXP/MathExecutor.php +++ b/src/NXP/MathExecutor.php @@ -117,6 +117,10 @@ class MathExecutor */ public function setVar($variable, $value) { + if (!is_numeric($value)) { + throw new \Exception("Variable ({$variable}) value must be a number ({$value}) type ({gettype($value)})"); + } + $this->variables[$variable] = $value; return $this; @@ -196,7 +200,7 @@ class MathExecutor * @param int $places Count of arguments * @return MathExecutor */ - public function addFunction($name, callable $function = null, $places = 1) + public function addFunction($name, $function = null, $places = 1) { $this->tokenFactory->addFunction($name, $function, $places); |