diff options
author | Bruce Wells <bruce.wells@simparel.com> | 2018-08-31 19:22:58 +0300 |
---|---|---|
committer | Bruce Wells <bruce.wells@simparel.com> | 2018-08-31 19:22:58 +0300 |
commit | 29d32a155f9956d1041a4420c19986565f695040 (patch) | |
tree | 6f8641bf3ec152a2de579cc6c9a8a9424538cfd2 /src/NXP | |
parent | b04cf54aa3e4d31bcea43011b371c75d168ac7f6 (diff) |
Add ability to get functions and operators that have been registered
Diffstat (limited to 'src/NXP')
-rw-r--r-- | src/NXP/Classes/TokenFactory.php | 22 | ||||
-rw-r--r-- | src/NXP/MathExecutor.php | 21 |
2 files changed, 43 insertions, 0 deletions
diff --git a/src/NXP/Classes/TokenFactory.php b/src/NXP/Classes/TokenFactory.php index 19ba1cf..2b1e00e 100644 --- a/src/NXP/Classes/TokenFactory.php +++ b/src/NXP/Classes/TokenFactory.php @@ -51,6 +51,18 @@ class TokenFactory $this->functions[$name] = array($places, $function); } + + /** + * get functions + * + * @return array containing callback and places indexed by + * function name + */ + public function getFunctions() + { + return $this->functions; + } + /** * Add operator * @param string $operatorClass @@ -69,6 +81,16 @@ class TokenFactory } /** + * Get registered operators + * + * @return array of operator class names + */ + public function getOperators() + { + return $this->operators; + } + + /** * Add variable * @param string $name * @param mixed $value diff --git a/src/NXP/MathExecutor.php b/src/NXP/MathExecutor.php index f348355..0c3d185 100644 --- a/src/NXP/MathExecutor.php +++ b/src/NXP/MathExecutor.php @@ -157,6 +157,16 @@ class MathExecutor } /** + * Get all registered operators to executor + * + * @return array of operator class names + */ + public function getOperators() + { + return $this->tokenFactory->getOperators(); + } + + /** * Add function to executor * * @param string $name Name of function @@ -172,6 +182,17 @@ class MathExecutor } /** + * Get all registered functions + * + * @return array containing callback and places indexed by + * function name + */ + public function getFunctions() + { + return $this->tokenFactory->getFunctions(); + } + + /** * Execute expression * * @param $expression |