aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlexander Kiryukhin <a.kiryukhin@mail.ru>2020-06-01 03:50:39 +0300
committerGitHub <noreply@github.com>2020-06-01 03:50:39 +0300
commitea898d7a7b85aeb677f81f13784232c99b61808a (patch)
treea1f6985aa44e3af0296989435427d57bc5219add /src
parent7852fc7d04bcdb3aa60384a1f6dddfd637fedd70 (diff)
Code style fixes & Github Actions (#65)V2.0.2
* Code style fixes Up phpunit to v8 New CI * Remove travis * Fix CI badge * Added php-cs-fixer action
Diffstat (limited to 'src')
-rw-r--r--src/NXP/Classes/Calculator.php4
-rw-r--r--src/NXP/Classes/CustomFunction.php5
-rw-r--r--src/NXP/Classes/Operator.php3
-rw-r--r--src/NXP/Classes/Tokenizer.php2
-rw-r--r--src/NXP/MathExecutor.php9
5 files changed, 10 insertions, 13 deletions
diff --git a/src/NXP/Classes/Calculator.php b/src/NXP/Classes/Calculator.php
index c6ccff1..94c6933 100644
--- a/src/NXP/Classes/Calculator.php
+++ b/src/NXP/Classes/Calculator.php
@@ -56,14 +56,14 @@ class Calculator
foreach ($tokens as $token) {
if ($token->type === Token::Literal || $token->type === Token::String) {
$stack[] = $token;
- } else if ($token->type === Token::Variable) {
+ } elseif ($token->type === Token::Variable) {
$variable = $token->value;
if (!array_key_exists($variable, $variables)) {
throw new UnknownVariableException($variable);
}
$value = $variables[$variable];
$stack[] = new Token(Token::Literal, $value);
- } else if ($token->type === Token::Function) {
+ } elseif ($token->type === Token::Function) {
if (!array_key_exists($token->value, $this->functions)) {
throw new UnknownFunctionException($token->value);
}
diff --git a/src/NXP/Classes/CustomFunction.php b/src/NXP/Classes/CustomFunction.php
index bf36405..06e21ef 100644
--- a/src/NXP/Classes/CustomFunction.php
+++ b/src/NXP/Classes/CustomFunction.php
@@ -3,7 +3,6 @@
namespace NXP\Classes;
-
use NXP\Exception\IncorrectExpressionException;
use ReflectionException;
use ReflectionFunction;
@@ -58,6 +57,4 @@ class CustomFunction
return new Token(Token::Literal, $result);
}
-
-
-} \ No newline at end of file
+}
diff --git a/src/NXP/Classes/Operator.php b/src/NXP/Classes/Operator.php
index c3762ea..86df549 100644
--- a/src/NXP/Classes/Operator.php
+++ b/src/NXP/Classes/Operator.php
@@ -3,7 +3,6 @@
namespace NXP\Classes;
-
use NXP\Exception\IncorrectExpressionException;
use ReflectionFunction;
@@ -66,4 +65,4 @@ class Operator
return new Token(Token::Literal, $result);
}
-} \ No newline at end of file
+}
diff --git a/src/NXP/Classes/Tokenizer.php b/src/NXP/Classes/Tokenizer.php
index caf395f..6b14677 100644
--- a/src/NXP/Classes/Tokenizer.php
+++ b/src/NXP/Classes/Tokenizer.php
@@ -106,6 +106,7 @@ class Tokenizer
$this->allowNegative = true;
break;
}
+ // no break
case $this->isAlpha($ch):
if ($this->numberBuffer != "") {
$this->emptyNumberBufferAsLiteral();
@@ -299,4 +300,3 @@ class Tokenizer
return $tokens;
}
}
-
diff --git a/src/NXP/MathExecutor.php b/src/NXP/MathExecutor.php
index 9a45589..8f876dc 100644
--- a/src/NXP/MathExecutor.php
+++ b/src/NXP/MathExecutor.php
@@ -15,8 +15,9 @@ use NXP\Classes\Calculator;
use NXP\Classes\CustomFunction;
use NXP\Classes\Operator;
use NXP\Classes\Tokenizer;
-use NXP\MathExecutorException;
+use NXP\Exception\MathExecutorException;
use NXP\Exception\DivisionByZeroException;
+use NXP\Exception\UnknownVariableException;
use ReflectionException;
/**
@@ -403,7 +404,7 @@ class MathExecutor
public function getVar(string $variable)
{
if (!isset($this->variables[$variable])) {
- throw new UnknownVariableException("Variable ({$variable}) not set");
+ throw new UnknownVariableException("Variable ({$variable}) not set");
}
return $this->variables[$variable];
}
@@ -444,7 +445,7 @@ class MathExecutor
return $this;
}
- /**
+ /**
* Remove variable from executor
*
* @param string $variable
@@ -452,7 +453,7 @@ class MathExecutor
*/
public function removeVar(string $variable) : self
{
- unset ($this->variables[$variable]);
+ unset($this->variables[$variable]);
return $this;
}