@@ -35,8 +35,7 @@ discard block |
||
35 | 35 | */ |
36 | 36 | public function add(string $leftOperand, string $rightOperand, int $precision = 0): string |
37 | 37 | { |
38 | - return (string) ($this->isIntOperation($precision) ? (intval($leftOperand) + intval($rightOperand)) : |
|
39 | - round(floatval($leftOperand) + floatval($rightOperand), $precision, $this->roundingStrategy)); |
|
38 | + return (string) ($this->isIntOperation($precision) ? (intval($leftOperand) + intval($rightOperand)) : round(floatval($leftOperand) + floatval($rightOperand), $precision, $this->roundingStrategy)); |
|
40 | 39 | } |
41 | 40 | |
42 | 41 | /** |
@@ -50,8 +49,7 @@ discard block |
||
50 | 49 | */ |
51 | 50 | public function subtract(string $leftOperand, string $rightOperand, int $precision = 0): string |
52 | 51 | { |
53 | - return (string) ($this->isIntOperation($precision) ? (intval($leftOperand) - intval($rightOperand)) : |
|
54 | - round($leftOperand - $rightOperand, $precision, $this->roundingStrategy)); |
|
52 | + return (string) ($this->isIntOperation($precision) ? (intval($leftOperand) - intval($rightOperand)) : round($leftOperand - $rightOperand, $precision, $this->roundingStrategy)); |
|
55 | 53 | } |
56 | 54 | |
57 | 55 | /** |
@@ -65,8 +63,7 @@ discard block |
||
65 | 63 | */ |
66 | 64 | public function multiply(string $leftOperand, string $rightOperand, int $precision = 0): string |
67 | 65 | { |
68 | - return (string) ($this->isIntOperation($precision) ? (intval($leftOperand) * intval($rightOperand)) : |
|
69 | - round($leftOperand * $rightOperand, ($precision ?? 0), $this->roundingStrategy)); |
|
66 | + return (string) ($this->isIntOperation($precision) ? (intval($leftOperand) * intval($rightOperand)) : round($leftOperand * $rightOperand, ($precision ?? 0), $this->roundingStrategy)); |
|
70 | 67 | } |
71 | 68 | |
72 | 69 | /** |
@@ -80,8 +77,7 @@ discard block |
||
80 | 77 | */ |
81 | 78 | public function divide(string $leftOperand, string $rightOperand, int $precision = 0): string |
82 | 79 | { |
83 | - return (string) ($this->isIntOperation($precision) ? (intval($leftOperand) / intval($rightOperand)) : |
|
84 | - round($leftOperand / $rightOperand, $precision, $this->roundingStrategy)); |
|
80 | + return (string) ($this->isIntOperation($precision) ? (intval($leftOperand) / intval($rightOperand)) : round($leftOperand / $rightOperand, $precision, $this->roundingStrategy)); |
|
85 | 81 | } |
86 | 82 | |
87 | 83 | /** |
@@ -192,7 +188,7 @@ discard block |
||
192 | 188 | return $this->gamma((string) $operand); |
193 | 189 | } |
194 | 190 | |
195 | - $factorial = function (string $num) use (&$factorial) { |
|
191 | + $factorial = function(string $num) use (&$factorial) { |
|
196 | 192 | if ($num < 2) { |
197 | 193 | return 1; |
198 | 194 | } |
@@ -213,7 +209,7 @@ discard block |
||
213 | 209 | */ |
214 | 210 | public function gcd(string $leftOperand, string $rightOperand): string |
215 | 211 | { |
216 | - $gcd = function (string $a, string $b) use (&$gcd) { |
|
212 | + $gcd = function(string $a, string $b) use (&$gcd) { |
|
217 | 213 | return $b ? $gcd($b, strval($a % $b)) : $a; |
218 | 214 | }; |
219 | 215 | |
@@ -251,7 +247,7 @@ discard block |
||
251 | 247 | public function nextPrime(string $operand): string |
252 | 248 | { |
253 | 249 | $operand = (intval($operand) + 1); |
254 | - for ($i = $operand;; ++$i) { |
|
250 | + for ($i = $operand; ; ++$i) { |
|
255 | 251 | if ($this->isPrime(strval($i))) { |
256 | 252 | break; |
257 | 253 | } |
@@ -133,7 +133,7 @@ |
||
133 | 133 | */ |
134 | 134 | protected function getOperationType(string $a, string $b = null): string |
135 | 135 | { |
136 | - $getType = function ($v, $previousType = null) { |
|
136 | + $getType = function($v, $previousType = null) { |
|
137 | 137 | $previousType = $previousType ?? self::TYPE_INT; |
138 | 138 | |
139 | 139 | return (strpos($v, '.') !== false) ? self::TYPE_FLOAT : $previousType; |
@@ -144,8 +144,7 @@ discard block |
||
144 | 144 | public function strpos(string $subStr, int $offset = 0, bool $caseSensitive = false): IntType |
145 | 145 | { |
146 | 146 | $res = ($caseSensitive) ? |
147 | - mb_strpos($this->str, $subStr, $offset, $this->encoding) : |
|
148 | - mb_stripos($this->str, $subStr, $offset, $this->encoding); |
|
147 | + mb_strpos($this->str, $subStr, $offset, $this->encoding) : mb_stripos($this->str, $subStr, $offset, $this->encoding); |
|
149 | 148 | |
150 | 149 | return new IntType($res); |
151 | 150 | } |
@@ -162,8 +161,7 @@ discard block |
||
162 | 161 | public function strrpos(string $subStr, int $offset = 0, bool $caseSensitive = false): IntType |
163 | 162 | { |
164 | 163 | $res = ($caseSensitive) ? |
165 | - mb_strrpos($this->str, $subStr, $offset, $this->encoding) : |
|
166 | - mb_strripos($this->str, $subStr, $offset, $this->encoding); |
|
164 | + mb_strrpos($this->str, $subStr, $offset, $this->encoding) : mb_strripos($this->str, $subStr, $offset, $this->encoding); |
|
167 | 165 | |
168 | 166 | return new IntType($res); |
169 | 167 | } |
@@ -285,7 +283,7 @@ discard block |
||
285 | 283 | if (!empty($toSubStr) && $str->contains($toSubStr)) { |
286 | 284 | $toIndex = $this->strpos($toSubStr, $fromIndex, $caseSensitive)->get(); |
287 | 285 | $toIndex = ($excludeToSubStr) ? |
288 | - $toIndex - $fromIndex : ($toIndex - $fromIndex) + mb_strlen($toSubStr, $this->encoding); |
|
286 | + $toIndex - $fromIndex : ($toIndex - $fromIndex) + mb_strlen($toSubStr, $this->encoding); |
|
289 | 287 | } |
290 | 288 | } |
291 | 289 |
@@ -67,7 +67,7 @@ |
||
67 | 67 | private static function asInt($mixed): int |
68 | 68 | { |
69 | 69 | return static::asSubType( |
70 | - function ($v) { |
|
70 | + function($v) { |
|
71 | 71 | return intval(round($v)); |
72 | 72 | }, |
73 | 73 | $mixed |
@@ -37,7 +37,7 @@ |
||
37 | 37 | if ($pointer !== null) { |
38 | 38 | throw new \LogicException( |
39 | 39 | sprintf( |
40 | - 'The identifier of type %s is defined more than once. '. |
|
40 | + 'The identifier of type %s is defined more than once. ' . |
|
41 | 41 | 'First argument of %s() must be null or undefined.', |
42 | 42 | gettype($pointer), |
43 | 43 | __METHOD__ |