@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare(strict_types=1); |
|
| 3 | +declare(strict_types = 1); |
|
| 4 | 4 | |
| 5 | 5 | namespace Tdn\PhpTypes\Type; |
| 6 | 6 | |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | * |
| 45 | 45 | * @return string|int|float|bool|array |
| 46 | 46 | */ |
| 47 | - public function __invoke(?int $toType = Type::STRING) |
|
| 47 | + public function __invoke(? int $toType = Type::STRING) |
|
| 48 | 48 | { |
| 49 | 49 | switch ($toType) { |
| 50 | 50 | case Type::STRING: |
@@ -146,8 +146,7 @@ discard block |
||
| 146 | 146 | public function strpos(string $subStr, int $offset = 0, bool $caseSensitive = false): IntType |
| 147 | 147 | { |
| 148 | 148 | $res = ($caseSensitive) ? |
| 149 | - mb_strpos($this->str, $subStr, $offset, $this->encoding) : |
|
| 150 | - mb_stripos($this->str, $subStr, $offset, $this->encoding); |
|
| 149 | + mb_strpos($this->str, $subStr, $offset, $this->encoding) : mb_stripos($this->str, $subStr, $offset, $this->encoding); |
|
| 151 | 150 | |
| 152 | 151 | return new IntType($res); |
| 153 | 152 | } |
@@ -164,8 +163,7 @@ discard block |
||
| 164 | 163 | public function strrpos(string $subStr, int $offset = 0, bool $caseSensitive = false): IntType |
| 165 | 164 | { |
| 166 | 165 | $res = ($caseSensitive) ? |
| 167 | - mb_strrpos($this->str, $subStr, $offset, $this->encoding) : |
|
| 168 | - mb_strripos($this->str, $subStr, $offset, $this->encoding); |
|
| 166 | + mb_strrpos($this->str, $subStr, $offset, $this->encoding) : mb_strripos($this->str, $subStr, $offset, $this->encoding); |
|
| 169 | 167 | |
| 170 | 168 | return new IntType($res); |
| 171 | 169 | } |
@@ -287,7 +285,7 @@ discard block |
||
| 287 | 285 | if (!empty($toSubStr) && $str->contains($toSubStr)) { |
| 288 | 286 | $toIndex = $this->strpos($toSubStr, $fromIndex, $caseSensitive)->get(); |
| 289 | 287 | $toIndex = ($excludeToSubStr) ? |
| 290 | - $toIndex - $fromIndex : ($toIndex - $fromIndex) + mb_strlen($toSubStr, $this->encoding); |
|
| 288 | + $toIndex - $fromIndex : ($toIndex - $fromIndex) + mb_strlen($toSubStr, $this->encoding); |
|
| 291 | 289 | } |
| 292 | 290 | } |
| 293 | 291 | |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare(strict_types=1); |
|
| 3 | +declare(strict_types = 1); |
|
| 4 | 4 | |
| 5 | 5 | namespace Tdn\PhpTypes\Type; |
| 6 | 6 | |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | * |
| 50 | 50 | * @return string|DateTimeType |
| 51 | 51 | */ |
| 52 | - public function __invoke(?int $toType = null) |
|
| 52 | + public function __invoke(? int $toType = null) |
|
| 53 | 53 | { |
| 54 | 54 | if ($toType === Type::STRING) { |
| 55 | 55 | return $this->format('Y-m-d H:i:s'); |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare(strict_types=1); |
|
| 3 | +declare(strict_types = 1); |
|
| 4 | 4 | |
| 5 | 5 | namespace Tdn\PhpTypes\Type; |
| 6 | 6 | |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | * |
| 31 | 31 | * @return string|float|int |
| 32 | 32 | */ |
| 33 | - public function __invoke(?int $toType = Type::INT) |
|
| 33 | + public function __invoke(? int $toType = Type::INT) |
|
| 34 | 34 | { |
| 35 | 35 | switch ($toType) { |
| 36 | 36 | case Type::INT: |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | private static function asInt($mixed): int |
| 70 | 70 | { |
| 71 | 71 | return static::asSubType( |
| 72 | - function ($v) { |
|
| 72 | + function($v) { |
|
| 73 | 73 | return intval(round($v)); |
| 74 | 74 | }, |
| 75 | 75 | $mixed |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | public function __construct(array $elements = array(), string $type = null) |
| 45 | 45 | { |
| 46 | 46 | $this->type = $type; |
| 47 | - $this->elements = array_map(function ($element) { |
|
| 47 | + $this->elements = array_map(function($element) { |
|
| 48 | 48 | return $this->getRealValue($element); |
| 49 | 49 | }, $elements); |
| 50 | 50 | } |
@@ -378,7 +378,7 @@ discard block |
||
| 378 | 378 | */ |
| 379 | 379 | public function unique() |
| 380 | 380 | { |
| 381 | - $closure = function ($key, $value) { |
|
| 381 | + $closure = function($key, $value) { |
|
| 382 | 382 | return is_string($value); |
| 383 | 383 | }; |
| 384 | 384 | |
@@ -411,7 +411,7 @@ discard block |
||
| 411 | 411 | * |
| 412 | 412 | * @return string|array|int |
| 413 | 413 | */ |
| 414 | - public function __invoke(?int $toType = Type::ARRAY) |
|
| 414 | + public function __invoke(? int $toType = Type::ARRAY) |
|
| 415 | 415 | { |
| 416 | 416 | $e = null; |
| 417 | 417 | switch ($toType) { |
@@ -411,13 +411,13 @@ |
||
| 411 | 411 | * |
| 412 | 412 | * @return string|array|int |
| 413 | 413 | */ |
| 414 | - public function __invoke(?int $toType = Type::ARRAY) |
|
| 414 | + public function __invoke(?int $toType = Type::array) |
|
| 415 | 415 | { |
| 416 | 416 | $e = null; |
| 417 | 417 | switch ($toType) { |
| 418 | 418 | case Type::INT: |
| 419 | 419 | return $this->count(); |
| 420 | - case Type::ARRAY: |
|
| 420 | + case Type::array: |
|
| 421 | 421 | return $this->elements; |
| 422 | 422 | case Type::STRING: |
| 423 | 423 | try { |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare(strict_types=1); |
|
| 3 | +declare(strict_types = 1); |
|
| 4 | 4 | |
| 5 | 5 | namespace Tdn\PhpTypes\Type; |
| 6 | 6 | |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | * |
| 43 | 43 | * @return bool|float|int|string|array|DateTimeType |
| 44 | 44 | */ |
| 45 | - public function __invoke(?int $toType = null); |
|
| 45 | + public function __invoke(? int $toType = null); |
|
| 46 | 46 | |
| 47 | 47 | /** |
| 48 | 48 | * Returns an instance of TypeInterface from a mixed scalar/type. |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare(strict_types=1); |
|
| 3 | +declare(strict_types = 1); |
|
| 4 | 4 | |
| 5 | 5 | namespace Tdn\PhpTypes\Type; |
| 6 | 6 | |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | * |
| 32 | 32 | * @return string|int|float |
| 33 | 33 | */ |
| 34 | - public function __invoke(?int $toType = Type::FLOAT) |
|
| 34 | + public function __invoke(? int $toType = Type::FLOAT) |
|
| 35 | 35 | { |
| 36 | 36 | switch ($toType) { |
| 37 | 37 | case Type::FLOAT: |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare(strict_types=1); |
|
| 3 | +declare(strict_types = 1); |
|
| 4 | 4 | |
| 5 | 5 | namespace Tdn\PhpTypes\Type; |
| 6 | 6 | |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | * |
| 35 | 35 | * @return string|bool |
| 36 | 36 | */ |
| 37 | - public function __invoke(?int $toType = Type::BOOL) |
|
| 37 | + public function __invoke(? int $toType = Type::BOOL) |
|
| 38 | 38 | { |
| 39 | 39 | switch ($toType) { |
| 40 | 40 | case Type::STRING: |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare(strict_types=1); |
|
| 3 | +declare(strict_types = 1); |
|
| 4 | 4 | |
| 5 | 5 | namespace Tdn\PhpTypes\Math; |
| 6 | 6 | |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | * |
| 25 | 25 | * @return string |
| 26 | 26 | */ |
| 27 | - public function add(string $leftOperand, string $rightOperand, ?int $precision = 0): string |
|
| 27 | + public function add(string $leftOperand, string $rightOperand, ? int $precision = 0) : string |
|
| 28 | 28 | { |
| 29 | 29 | return $this->getDelegateResult(__FUNCTION__, $leftOperand, $rightOperand, $precision); |
| 30 | 30 | } |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | * |
| 39 | 39 | * @return string |
| 40 | 40 | */ |
| 41 | - public function subtract(string $leftOperand, string $rightOperand, ?int $precision = 0): string |
|
| 41 | + public function subtract(string $leftOperand, string $rightOperand, ? int $precision = 0) : string |
|
| 42 | 42 | { |
| 43 | 43 | return $this->getDelegateResult(__FUNCTION__, $leftOperand, $rightOperand, $precision); |
| 44 | 44 | } |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | * |
| 53 | 53 | * @return string |
| 54 | 54 | */ |
| 55 | - public function multiply(string $leftOperand, string $rightOperand, ?int $precision = 0): string |
|
| 55 | + public function multiply(string $leftOperand, string $rightOperand, ? int $precision = 0) : string |
|
| 56 | 56 | { |
| 57 | 57 | return $this->getDelegateResult(__FUNCTION__, $leftOperand, $rightOperand, $precision); |
| 58 | 58 | } |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | * |
| 69 | 69 | * @throws \DivisionByZeroError |
| 70 | 70 | */ |
| 71 | - public function divide(string $leftOperand, string $rightOperand, ?int $precision = 0): string |
|
| 71 | + public function divide(string $leftOperand, string $rightOperand, ? int $precision = 0) : string |
|
| 72 | 72 | { |
| 73 | 73 | if ($rightOperand == '0') { |
| 74 | 74 | throw new \DivisionByZeroError(); |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | * |
| 87 | 87 | * @return string |
| 88 | 88 | */ |
| 89 | - public function compare(string $leftOperand, string $rightOperand, ?int $precision = 0): string |
|
| 89 | + public function compare(string $leftOperand, string $rightOperand, ? int $precision = 0) : string |
|
| 90 | 90 | { |
| 91 | 91 | return $this->getDelegateResult(__FUNCTION__, $leftOperand, $rightOperand, $precision); |
| 92 | 92 | } |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | * |
| 101 | 101 | * @return string |
| 102 | 102 | */ |
| 103 | - public function modulus(string $operand, string $modulus, ?int $precision = 0): string |
|
| 103 | + public function modulus(string $operand, string $modulus, ? int $precision = 0) : string |
|
| 104 | 104 | { |
| 105 | 105 | return $this->getDelegateResult(__FUNCTION__, $operand, $modulus, $precision); |
| 106 | 106 | } |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | * |
| 115 | 115 | * @return string |
| 116 | 116 | */ |
| 117 | - public function power(string $leftOperand, string $rightOperand, ?int $precision = 0): string |
|
| 117 | + public function power(string $leftOperand, string $rightOperand, ? int $precision = 0) : string |
|
| 118 | 118 | { |
| 119 | 119 | return $this->getDelegateResult(__FUNCTION__, $leftOperand, $rightOperand, $precision); |
| 120 | 120 | } |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | * |
| 128 | 128 | * @return string |
| 129 | 129 | */ |
| 130 | - public function squareRoot(string $operand, ?int $precision = 0): string |
|
| 130 | + public function squareRoot(string $operand, ? int $precision = 0) : string |
|
| 131 | 131 | { |
| 132 | 132 | return $this->getDelegateResult(__FUNCTION__, $operand, null, $precision); |
| 133 | 133 | } |
@@ -239,7 +239,7 @@ discard block |
||
| 239 | 239 | * |
| 240 | 240 | * @return bool |
| 241 | 241 | */ |
| 242 | - public function isPrime(string $operand, ?int $reps = 10): bool |
|
| 242 | + public function isPrime(string $operand, ? int $reps = 10) : bool |
|
| 243 | 243 | { |
| 244 | 244 | $type = $this->getOperationType($operand); |
| 245 | 245 | $exception = null; |
@@ -273,7 +273,7 @@ discard block |
||
| 273 | 273 | * |
| 274 | 274 | * @return bool |
| 275 | 275 | */ |
| 276 | - public function isPerfectSquare(string $operand, ?int $precision = 0): bool |
|
| 276 | + public function isPerfectSquare(string $operand, ? int $precision = 0) : bool |
|
| 277 | 277 | { |
| 278 | 278 | return $this->getDelegateResult(__FUNCTION__, $operand, null, $precision); |
| 279 | 279 | } |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare(strict_types=1); |
|
| 3 | +declare(strict_types = 1); |
|
| 4 | 4 | |
| 5 | 5 | namespace Tdn\PhpTypes\Math; |
| 6 | 6 | |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | * |
| 29 | 29 | * @return string |
| 30 | 30 | */ |
| 31 | - public function add(string $leftOperand, string $rightOperand, ?int $precision = 0): string; |
|
| 31 | + public function add(string $leftOperand, string $rightOperand, ? int $precision = 0) : string; |
|
| 32 | 32 | |
| 33 | 33 | /** |
| 34 | 34 | * Subtract two arbitrary precision numbers. |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | * |
| 40 | 40 | * @return string |
| 41 | 41 | */ |
| 42 | - public function subtract(string $leftOperand, string $rightOperand, ?int $precision = 0): string; |
|
| 42 | + public function subtract(string $leftOperand, string $rightOperand, ? int $precision = 0) : string; |
|
| 43 | 43 | |
| 44 | 44 | /** |
| 45 | 45 | * Multiply two arbitrary precision numbers. |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | * |
| 51 | 51 | * @return string |
| 52 | 52 | */ |
| 53 | - public function multiply(string $leftOperand, string $rightOperand, ?int $precision = 0): string; |
|
| 53 | + public function multiply(string $leftOperand, string $rightOperand, ? int $precision = 0) : string; |
|
| 54 | 54 | |
| 55 | 55 | /** |
| 56 | 56 | * Divide two arbitrary precision numbers. |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | * |
| 62 | 62 | * @return string |
| 63 | 63 | */ |
| 64 | - public function divide(string $leftOperand, string $rightOperand, ?int $precision = 0): string; |
|
| 64 | + public function divide(string $leftOperand, string $rightOperand, ? int $precision = 0) : string; |
|
| 65 | 65 | |
| 66 | 66 | /** |
| 67 | 67 | * Compare two arbitrary precision numbers. |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | * |
| 73 | 73 | * @return string |
| 74 | 74 | */ |
| 75 | - public function compare(string $leftOperand, string $rightOperand, ?int $precision = 0): string; |
|
| 75 | + public function compare(string $leftOperand, string $rightOperand, ? int $precision = 0) : string; |
|
| 76 | 76 | |
| 77 | 77 | /** |
| 78 | 78 | * Get modulus of an arbitrary precision number. |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | * |
| 84 | 84 | * @return string |
| 85 | 85 | */ |
| 86 | - public function modulus(string $operand, string $modulus, ?int $precision = 0): string; |
|
| 86 | + public function modulus(string $operand, string $modulus, ? int $precision = 0) : string; |
|
| 87 | 87 | |
| 88 | 88 | /** |
| 89 | 89 | * Raise an arbitrary precision number to another. |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | * |
| 95 | 95 | * @return string |
| 96 | 96 | */ |
| 97 | - public function power(string $leftOperand, string $rightOperand, ?int $precision = 0): string; |
|
| 97 | + public function power(string $leftOperand, string $rightOperand, ? int $precision = 0) : string; |
|
| 98 | 98 | |
| 99 | 99 | /** |
| 100 | 100 | * Get the square root of an arbitrary precision number. |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | * |
| 105 | 105 | * @return string |
| 106 | 106 | */ |
| 107 | - public function squareRoot(string $operand, ?int $precision = 0): string; |
|
| 107 | + public function squareRoot(string $operand, ? int $precision = 0) : string; |
|
| 108 | 108 | |
| 109 | 109 | /** |
| 110 | 110 | * Returns absolute value of operand. |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | * |
| 169 | 169 | * @return bool |
| 170 | 170 | */ |
| 171 | - public function isPrime(string $operand, ?int $reps = 10): bool; |
|
| 171 | + public function isPrime(string $operand, ? int $reps = 10) : bool; |
|
| 172 | 172 | |
| 173 | 173 | /** |
| 174 | 174 | * Checks if operand is perfect square. |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | * |
| 179 | 179 | * @return bool |
| 180 | 180 | */ |
| 181 | - public function isPerfectSquare(string $operand, ?int $precision = null): bool; |
|
| 181 | + public function isPerfectSquare(string $operand, ? int $precision = null) : bool; |
|
| 182 | 182 | |
| 183 | 183 | /** |
| 184 | 184 | * The gamma function. |