@@ -3,33 +3,33 @@ |
||
| 3 | 3 | namespace Transphporm\TSSFunction; |
| 4 | 4 | |
| 5 | 5 | class Math implements \Transphporm\TSSFunction { |
| 6 | - private $mode; |
|
| 6 | + private $mode; |
|
| 7 | 7 | |
| 8 | - const ADD = 1; |
|
| 9 | - const SUBTRACT = 2; |
|
| 10 | - const MULTIPLY = 3; |
|
| 11 | - const DIVIDE = 4; |
|
| 8 | + const ADD = 1; |
|
| 9 | + const SUBTRACT = 2; |
|
| 10 | + const MULTIPLY = 3; |
|
| 11 | + const DIVIDE = 4; |
|
| 12 | 12 | |
| 13 | - public function __construct($mode) { |
|
| 14 | - $this->mode = $mode; |
|
| 15 | - } |
|
| 13 | + public function __construct($mode) { |
|
| 14 | + $this->mode = $mode; |
|
| 15 | + } |
|
| 16 | 16 | |
| 17 | - public function run(array $args, \DomElement $element) { |
|
| 18 | - $result = $args[0]; |
|
| 19 | - for ($i = 1; $i < count($args); $i++) $result = $this->getModeResult($args[$i], $result); |
|
| 20 | - return $result; |
|
| 21 | - } |
|
| 17 | + public function run(array $args, \DomElement $element) { |
|
| 18 | + $result = $args[0]; |
|
| 19 | + for ($i = 1; $i < count($args); $i++) $result = $this->getModeResult($args[$i], $result); |
|
| 20 | + return $result; |
|
| 21 | + } |
|
| 22 | 22 | |
| 23 | - private function getModeResult($val, $prev) { |
|
| 24 | - switch ($this->mode) { |
|
| 25 | - case Math::ADD: |
|
| 26 | - return $prev+$val; |
|
| 27 | - case Math::SUBTRACT: |
|
| 28 | - return $prev-$val; |
|
| 29 | - case Math::MULTIPLY: |
|
| 30 | - return $prev*$val; |
|
| 31 | - case MATH::DIVIDE: |
|
| 32 | - return $prev/$val; |
|
| 33 | - } |
|
| 34 | - } |
|
| 23 | + private function getModeResult($val, $prev) { |
|
| 24 | + switch ($this->mode) { |
|
| 25 | + case Math::ADD: |
|
| 26 | + return $prev+$val; |
|
| 27 | + case Math::SUBTRACT: |
|
| 28 | + return $prev-$val; |
|
| 29 | + case Math::MULTIPLY: |
|
| 30 | + return $prev*$val; |
|
| 31 | + case MATH::DIVIDE: |
|
| 32 | + return $prev/$val; |
|
| 33 | + } |
|
| 34 | + } |
|
| 35 | 35 | } |
@@ -27,9 +27,9 @@ |
||
| 27 | 27 | case Math::SUBTRACT: |
| 28 | 28 | return $prev-$val; |
| 29 | 29 | case Math::MULTIPLY: |
| 30 | - return $prev*$val; |
|
| 30 | + return $prev * $val; |
|
| 31 | 31 | case MATH::DIVIDE: |
| 32 | - return $prev/$val; |
|
| 32 | + return $prev / $val; |
|
| 33 | 33 | } |
| 34 | 34 | } |
| 35 | 35 | } |
@@ -16,7 +16,9 @@ |
||
| 16 | 16 | |
| 17 | 17 | public function run(array $args, \DomElement $element) { |
| 18 | 18 | $result = $args[0]; |
| 19 | - for ($i = 1; $i < count($args); $i++) $result = $this->getModeResult($args[$i], $result); |
|
| 19 | + for ($i = 1; $i < count($args); $i++) { |
|
| 20 | + $result = $this->getModeResult($args[$i], $result); |
|
| 21 | + } |
|
| 20 | 22 | return $result; |
| 21 | 23 | } |
| 22 | 24 | |