aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/NXP/Classes/TokenFactory.php12
-rw-r--r--src/NXP/MathExecutor.php6
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);