@@ -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 { |
@@ -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; |
@@ -116,7 +116,7 @@ |
||
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | if ($this instanceof TransmutableTypeInterface) { |
| 119 | - return $this(Type::ARRAY); |
|
| 119 | + return $this(Type::array); |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | throw $this->createInvalidTransformationException('array'); |
@@ -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 | /** |
@@ -194,7 +190,7 @@ discard block |
||
| 194 | 190 | return $this->gamma((string) $operand); |
| 195 | 191 | } |
| 196 | 192 | |
| 197 | - $factorial = function (string $num) use (&$factorial) { |
|
| 193 | + $factorial = function(string $num) use (&$factorial) { |
|
| 198 | 194 | if ($num < 2) { |
| 199 | 195 | return 1; |
| 200 | 196 | } |
@@ -215,7 +211,7 @@ discard block |
||
| 215 | 211 | */ |
| 216 | 212 | public function gcd(string $leftOperand, string $rightOperand) : string |
| 217 | 213 | { |
| 218 | - $gcd = function (string $a, string $b) use (&$gcd) { |
|
| 214 | + $gcd = function(string $a, string $b) use (&$gcd) { |
|
| 219 | 215 | return $b ? $gcd($b, strval($a % $b)) : $a; |
| 220 | 216 | }; |
| 221 | 217 | |
@@ -253,7 +249,7 @@ discard block |
||
| 253 | 249 | public function nextPrime(string $operand) : string |
| 254 | 250 | { |
| 255 | 251 | $operand = (intval($operand) + 1); |
| 256 | - for ($i = $operand;; ++$i) { |
|
| 252 | + for ($i = $operand; ; ++$i) { |
|
| 257 | 253 | if ($this->isPrime(strval($i))) { |
| 258 | 254 | break; |
| 259 | 255 | } |