From 253fb694a3fcafa3f9ea6da6681f0b176cdec1f4 Mon Sep 17 00:00:00 2001 From: Alexander 'NeonXP' Kiryukhin Date: Sun, 17 Mar 2013 07:30:25 +0400 Subject: + Some comments --- NXP/MathExecutor.php | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) (limited to 'NXP') 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 */ -- cgit v1.2.3