diff options
author | Alexander 'NeonXP' Kiryukhin <frei@neonxp.info> | 2013-03-17 07:30:25 +0400 |
---|---|---|
committer | Alexander 'NeonXP' Kiryukhin <frei@neonxp.info> | 2013-03-17 07:30:25 +0400 |
commit | 253fb694a3fcafa3f9ea6da6681f0b176cdec1f4 (patch) | |
tree | 46a8257f11a8610ea5f8390be516949d088c9c45 | |
parent | 12ee083b5e7dc1737aeb9377012815528f468d08 (diff) |
+ Some comments
-rw-r--r-- | NXP/MathExecutor.php | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/NXP/MathExecutor.php b/NXP/MathExecutor.php index cb1c7b5..cc1c187 100644 --- a/NXP/MathExecutor.php +++ b/NXP/MathExecutor.php @@ -53,16 +53,30 @@ class MathExecutor { $this->addFunction(new Func('atn', function ($arg) { return atan($arg); })); } + /** + * Add operator to executor + * @param Operand $operator + */ public function addOperator(Operand $operator) { $this->operators[$operator->getSymbol()] = $operator; } + /** + * Add function to executor + * @param Func $function + */ public function addFunction(Func $function) { $this->functions[$function->getName()] = $function->getCallback(); } + /** + * Add variable to executor + * @param $variable + * @param $value + * @throws \Exception + */ public function setVar($variable, $value) { if (!is_numeric($value)) { @@ -90,7 +104,7 @@ class MathExecutor { * @return \SplQueue * @throws \Exception */ - protected function convertToReversePolishNotation($expression) + private function convertToReversePolishNotation($expression) { $this->stack = new \SplStack(); $this->queue = new \SplQueue(); @@ -113,6 +127,10 @@ class MathExecutor { return $this->queue; } + /** + * @param Token $token + * @throws \Exception + */ private function categorizeToken(Token $token) { switch ($token->getType()) { @@ -161,6 +179,10 @@ class MathExecutor { } } + /** + * @param $token + * @throws \Exception + */ private function proceedOperator($token) { if (!array_key_exists($token->getValue(), $this->operators)) { @@ -193,7 +215,12 @@ class MathExecutor { } } - protected function calculateReversePolishNotation(\SplQueue $expression) + /** + * @param \SplQueue $expression + * @return mixed + * @throws \Exception + */ + private function calculateReversePolishNotation(\SplQueue $expression) { $this->stack = new \SplStack(); /** @val Token $token */ |