@@ -101,8 +101,7 @@ discard block |
||
| 101 | 101 | public function strpos(string $subStr, int $offset = 0, bool $caseSensitive = false) : IntType |
| 102 | 102 | { |
| 103 | 103 | $res = ($caseSensitive) ? |
| 104 | - mb_strpos($this->str, $subStr, $offset, $this->encoding) : |
|
| 105 | - mb_stripos($this->str, $subStr, $offset, $this->encoding); |
|
| 104 | + mb_strpos($this->str, $subStr, $offset, $this->encoding) : mb_stripos($this->str, $subStr, $offset, $this->encoding); |
|
| 106 | 105 | |
| 107 | 106 | return new IntType($res); |
| 108 | 107 | } |
@@ -119,8 +118,7 @@ discard block |
||
| 119 | 118 | public function strrpos(string $subStr, int $offset = 0, bool $caseSensitive = false) : IntType |
| 120 | 119 | { |
| 121 | 120 | $res = ($caseSensitive) ? |
| 122 | - mb_strrpos($this->str, $subStr, $offset, $this->encoding) : |
|
| 123 | - mb_strripos($this->str, $subStr, $offset, $this->encoding); |
|
| 121 | + mb_strrpos($this->str, $subStr, $offset, $this->encoding) : mb_strripos($this->str, $subStr, $offset, $this->encoding); |
|
| 124 | 122 | |
| 125 | 123 | return new IntType($res); |
| 126 | 124 | } |
@@ -57,7 +57,7 @@ |
||
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | break; |
| 60 | - case Type::ARRAY: |
|
| 60 | + case Type::array: |
|
| 61 | 61 | if ($this->contains(',')) { |
| 62 | 62 | return $this->explode(',')->toArray(); |
| 63 | 63 | } |
@@ -52,7 +52,7 @@ |
||
| 52 | 52 | private static function asInt($mixed) : int |
| 53 | 53 | { |
| 54 | 54 | return static::asSubType( |
| 55 | - function ($v) { |
|
| 55 | + function($v) { |
|
| 56 | 56 | return intval(round($v)); |
| 57 | 57 | }, |
| 58 | 58 | $mixed |
@@ -11,7 +11,7 @@ |
||
| 11 | 11 | const BOOL = 1; |
| 12 | 12 | const INT = 2; |
| 13 | 13 | const FLOAT = 3; |
| 14 | - const ARRAY = 4; |
|
| 14 | + const array = 4; |
|
| 15 | 15 | |
| 16 | 16 | /** |
| 17 | 17 | * @return mixed |
@@ -139,7 +139,7 @@ |
||
| 139 | 139 | Type::BOOL => 'bool', |
| 140 | 140 | Type::INT => 'int', |
| 141 | 141 | Type::FLOAT => 'float', |
| 142 | - Type::ARRAY => 'array', |
|
| 142 | + Type::array => 'array', |
|
| 143 | 143 | ]; |
| 144 | 144 | } |
| 145 | 145 | } |
@@ -98,8 +98,7 @@ discard block |
||
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | self::$collection[$address] = &$pointer; |
| 101 | - self::$lastAddress = $address; |
|
| 102 | - ++self::$entriesCount; |
|
| 101 | + self::$lastAddress = $address;++self::$entriesCount; |
|
| 103 | 102 | } |
| 104 | 103 | |
| 105 | 104 | /** |
@@ -119,8 +118,7 @@ discard block |
||
| 119 | 118 | } |
| 120 | 119 | |
| 121 | 120 | $address = self::createAddress(); |
| 122 | - self::$collection[$address] = &$pointer; |
|
| 123 | - ++self::$entriesCount; |
|
| 121 | + self::$collection[$address] = &$pointer;++self::$entriesCount; |
|
| 124 | 122 | |
| 125 | 123 | return $address; |
| 126 | 124 | } |
@@ -154,8 +152,7 @@ discard block |
||
| 154 | 152 | return false; |
| 155 | 153 | } |
| 156 | 154 | |
| 157 | - unset(self::$collection[$address]); |
|
| 158 | - --self::$entriesCount; |
|
| 155 | + unset(self::$collection[$address]);--self::$entriesCount; |
|
| 159 | 156 | |
| 160 | 157 | return true; |
| 161 | 158 | } |
@@ -28,12 +28,12 @@ |
||
| 28 | 28 | * |
| 29 | 29 | * @return string|array|int |
| 30 | 30 | */ |
| 31 | - public function __invoke(int $toType = Type::ARRAY) |
|
| 31 | + public function __invoke(int $toType = Type::array) |
|
| 32 | 32 | { |
| 33 | 33 | switch ($toType) { |
| 34 | 34 | case Type::INT: |
| 35 | 35 | return $this->count(); |
| 36 | - case Type::ARRAY: |
|
| 36 | + case Type::array: |
|
| 37 | 37 | return $this->toArray(); |
| 38 | 38 | case Type::STRING: |
| 39 | 39 | try { |
@@ -37,8 +37,7 @@ discard block |
||
| 37 | 37 | */ |
| 38 | 38 | public function add(string $leftOperand, string $rightOperand, int $precision = 0) : string |
| 39 | 39 | { |
| 40 | - return (string)($this->isIntOperation($precision) ? (intval($leftOperand) + intval($rightOperand)) : |
|
| 41 | - round(floatval($leftOperand) + floatval($rightOperand), $precision, $this->roundingStrategy)); |
|
| 40 | + return (string) ($this->isIntOperation($precision) ? (intval($leftOperand) + intval($rightOperand)) : round(floatval($leftOperand) + floatval($rightOperand), $precision, $this->roundingStrategy)); |
|
| 42 | 41 | } |
| 43 | 42 | |
| 44 | 43 | /** |
@@ -52,8 +51,7 @@ discard block |
||
| 52 | 51 | */ |
| 53 | 52 | public function subtract(string $leftOperand, string $rightOperand, int $precision = 0) : string |
| 54 | 53 | { |
| 55 | - return (string)($this->isIntOperation($precision) ? (intval($leftOperand) - intval($rightOperand)) : |
|
| 56 | - round($leftOperand - $rightOperand, $precision, $this->roundingStrategy)); |
|
| 54 | + return (string) ($this->isIntOperation($precision) ? (intval($leftOperand) - intval($rightOperand)) : round($leftOperand - $rightOperand, $precision, $this->roundingStrategy)); |
|
| 57 | 55 | } |
| 58 | 56 | |
| 59 | 57 | /** |
@@ -67,8 +65,7 @@ discard block |
||
| 67 | 65 | */ |
| 68 | 66 | public function multiply(string $leftOperand, string $rightOperand, int $precision = 0) : string |
| 69 | 67 | { |
| 70 | - return (string)($this->isIntOperation($precision) ? (intval($leftOperand) * intval($rightOperand)) : |
|
| 71 | - round($leftOperand * $rightOperand, ($precision ?? 0), $this->roundingStrategy)); |
|
| 68 | + return (string) ($this->isIntOperation($precision) ? (intval($leftOperand) * intval($rightOperand)) : round($leftOperand * $rightOperand, ($precision ?? 0), $this->roundingStrategy)); |
|
| 72 | 69 | } |
| 73 | 70 | |
| 74 | 71 | /** |
@@ -82,8 +79,7 @@ discard block |
||
| 82 | 79 | */ |
| 83 | 80 | public function divide(string $leftOperand, string $rightOperand, int $precision = 0) : string |
| 84 | 81 | { |
| 85 | - return (string)($this->isIntOperation($precision) ? (intval($leftOperand) / intval($rightOperand)) : |
|
| 86 | - round($leftOperand / $rightOperand, $precision, $this->roundingStrategy)); |
|
| 82 | + return (string) ($this->isIntOperation($precision) ? (intval($leftOperand) / intval($rightOperand)) : round($leftOperand / $rightOperand, $precision, $this->roundingStrategy)); |
|
| 87 | 83 | } |
| 88 | 84 | |
| 89 | 85 | /** |
@@ -111,7 +107,7 @@ discard block |
||
| 111 | 107 | */ |
| 112 | 108 | public function modulus(string $operand, string $modulus, int $precision = 0) : string |
| 113 | 109 | { |
| 114 | - return (string)round( |
|
| 110 | + return (string) round( |
|
| 115 | 111 | fmod( |
| 116 | 112 | floatval($operand), |
| 117 | 113 | floatval($modulus) |
@@ -132,7 +128,7 @@ discard block |
||
| 132 | 128 | */ |
| 133 | 129 | public function power(string $leftOperand, string $rightOperand, int $precision = 0) : string |
| 134 | 130 | { |
| 135 | - return (string)round( |
|
| 131 | + return (string) round( |
|
| 136 | 132 | pow( |
| 137 | 133 | floatval($leftOperand), |
| 138 | 134 | floatval($rightOperand) |
@@ -152,7 +148,7 @@ discard block |
||
| 152 | 148 | */ |
| 153 | 149 | public function squareRoot(string $operand, int $precision = 0) : string |
| 154 | 150 | { |
| 155 | - return (string)round(sqrt(floatval($operand)), ($precision ?? 0), $this->roundingStrategy); |
|
| 151 | + return (string) round(sqrt(floatval($operand)), ($precision ?? 0), $this->roundingStrategy); |
|
| 156 | 152 | } |
| 157 | 153 | |
| 158 | 154 | /** |
@@ -164,7 +160,7 @@ discard block |
||
| 164 | 160 | */ |
| 165 | 161 | public function absolute(string $operand) : string |
| 166 | 162 | { |
| 167 | - return (string)abs($operand); |
|
| 163 | + return (string) abs($operand); |
|
| 168 | 164 | } |
| 169 | 165 | |
| 170 | 166 | /** |
@@ -193,7 +189,7 @@ discard block |
||
| 193 | 189 | return $this->gamma((string) $operand); |
| 194 | 190 | } |
| 195 | 191 | |
| 196 | - $factorial = function (string $num) use (&$factorial) { |
|
| 192 | + $factorial = function(string $num) use (&$factorial) { |
|
| 197 | 193 | if ($num < 2) { |
| 198 | 194 | return 1; |
| 199 | 195 | } |
@@ -201,7 +197,7 @@ discard block |
||
| 201 | 197 | return $factorial(strval($num - 1)) * $num; |
| 202 | 198 | }; |
| 203 | 199 | |
| 204 | - return (string)$factorial($operand); |
|
| 200 | + return (string) $factorial($operand); |
|
| 205 | 201 | } |
| 206 | 202 | |
| 207 | 203 | /** |
@@ -214,13 +210,13 @@ discard block |
||
| 214 | 210 | */ |
| 215 | 211 | public function gcd(string $leftOperand, string $rightOperand) : string |
| 216 | 212 | { |
| 217 | - $gcd = function (string $a, string $b) use (&$gcd) { |
|
| 213 | + $gcd = function(string $a, string $b) use (&$gcd) { |
|
| 218 | 214 | return $b ? $gcd($b, strval($a % $b)) : $a; |
| 219 | 215 | }; |
| 220 | 216 | |
| 221 | 217 | $exponent = $this->getSmallestDecimalPlaceCount($leftOperand, $rightOperand); |
| 222 | 218 | |
| 223 | - return (string)( |
|
| 219 | + return (string) ( |
|
| 224 | 220 | $gcd( |
| 225 | 221 | strval($leftOperand * (pow(10, $exponent))), |
| 226 | 222 | strval($rightOperand * (pow(10, $exponent))) |
@@ -258,7 +254,7 @@ discard block |
||
| 258 | 254 | } |
| 259 | 255 | } |
| 260 | 256 | |
| 261 | - return (string)$i; |
|
| 257 | + return (string) $i; |
|
| 262 | 258 | } |
| 263 | 259 | |
| 264 | 260 | /** |
@@ -349,7 +345,7 @@ discard block |
||
| 349 | 345 | if ($arg_was_less_than_one) { |
| 350 | 346 | $y += 1.0; |
| 351 | 347 | } else { |
| 352 | - $n = floor($y) - 1; # will use n later |
|
| 348 | + $n = floor($y) - 1; # will use n later |
|
| 353 | 349 | $y -= $n; |
| 354 | 350 | } |
| 355 | 351 | |
@@ -134,7 +134,7 @@ |
||
| 134 | 134 | */ |
| 135 | 135 | protected function getOperationType(string $a, string $b = null) : string |
| 136 | 136 | { |
| 137 | - $getType = function ($v, $previousType = null) { |
|
| 137 | + $getType = function($v, $previousType = null) { |
|
| 138 | 138 | $previousType = $previousType ?? self::TYPE_INT; |
| 139 | 139 | |
| 140 | 140 | return (strpos($v, '.') !== false) ? self::TYPE_FLOAT : $previousType; |