@@ -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: |