@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | { |
| 53 | 53 | $languageSpecific = static::languageSpecificCharsArray($language); |
| 54 | 54 | |
| 55 | - if (! is_null($languageSpecific)) { |
|
| 55 | + if (!is_null($languageSpecific)) { |
|
| 56 | 56 | $value = str_replace($languageSpecific[0], $languageSpecific[1], $value); |
| 57 | 57 | } |
| 58 | 58 | |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | { |
| 246 | 246 | preg_match('/^\s*+(?:\S++\s*+){1,'.$words.'}/u', $value, $matches); |
| 247 | 247 | |
| 248 | - if (! isset($matches[0]) || static::length($value) === static::length($matches[0])) { |
|
| 248 | + if (!isset($matches[0]) || static::length($value) === static::length($matches[0])) { |
|
| 249 | 249 | return $value; |
| 250 | 250 | } |
| 251 | 251 | |
@@ -447,7 +447,7 @@ discard block |
||
| 447 | 447 | return static::$snakeCache[$key][$delimiter]; |
| 448 | 448 | } |
| 449 | 449 | |
| 450 | - if (! ctype_lower($value)) { |
|
| 450 | + if (!ctype_lower($value)) { |
|
| 451 | 451 | $value = preg_replace('/\s+/u', '', ucwords($value)); |
| 452 | 452 | |
| 453 | 453 | $value = static::lower(preg_replace('/(.)(?=[A-Z])/u', '$1'.$delimiter, $value)); |
@@ -665,14 +665,14 @@ discard block |
||
| 665 | 665 | { |
| 666 | 666 | static $languageSpecific; |
| 667 | 667 | |
| 668 | - if (! isset($languageSpecific)) { |
|
| 668 | + if (!isset($languageSpecific)) { |
|
| 669 | 669 | $languageSpecific = [ |
| 670 | 670 | 'bg' => [ |
| 671 | 671 | ['х', 'Х', 'щ', 'Щ', 'ъ', 'Ъ', 'ь', 'Ь'], |
| 672 | 672 | ['h', 'H', 'sht', 'SHT', 'a', 'А', 'y', 'Y'], |
| 673 | 673 | ], |
| 674 | 674 | 'de' => [ |
| 675 | - ['ä', 'ö', 'ü', 'Ä', 'Ö', 'Ü'], |
|
| 675 | + ['ä', 'ö', 'ü', 'Ä', 'Ö', 'Ü'], |
|
| 676 | 676 | ['ae', 'oe', 'ue', 'AE', 'OE', 'UE'], |
| 677 | 677 | ], |
| 678 | 678 | ]; |
@@ -2,11 +2,11 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace IlluminateAgnostic\Str\Support; |
| 4 | 4 | |
| 5 | -use Ramsey\Uuid\Uuid; |
|
| 6 | -use Ramsey\Uuid\UuidFactory; |
|
| 7 | 5 | use IlluminateAgnostic\Str\Support\Traits\Macroable; |
| 8 | -use Ramsey\Uuid\Generator\CombGenerator; |
|
| 9 | 6 | use Ramsey\Uuid\Codec\TimestampFirstCombCodec; |
| 7 | +use Ramsey\Uuid\Generator\CombGenerator; |
|
| 8 | +use Ramsey\Uuid\Uuid; |
|
| 9 | +use Ramsey\Uuid\UuidFactory; |
|
| 10 | 10 | |
| 11 | 11 | class Str |
| 12 | 12 | { |
@@ -8,7 +8,7 @@ |
||
| 8 | 8 | ]; |
| 9 | 9 | |
| 10 | 10 | foreach ($aliases as $illuminate => $tighten) { |
| 11 | - if (class_exists($illuminate) && ! interface_exists($illuminate) && ! trait_exists($illuminate)) { |
|
| 11 | + if (class_exists($illuminate) && !interface_exists($illuminate) && !trait_exists($illuminate)) { |
|
| 12 | 12 | class_alias($illuminate, $tighten); |
| 13 | 13 | } |
| 14 | 14 | } |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | */ |
| 71 | 71 | public static function __callStatic($method, $parameters) |
| 72 | 72 | { |
| 73 | - if (! static::hasMacro($method)) { |
|
| 73 | + if (!static::hasMacro($method)) { |
|
| 74 | 74 | throw new BadMethodCallException(sprintf( |
| 75 | 75 | 'Method %s::%s does not exist.', static::class, $method |
| 76 | 76 | )); |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | */ |
| 95 | 95 | public function __call($method, $parameters) |
| 96 | 96 | { |
| 97 | - if (! static::hasMacro($method)) { |
|
| 97 | + if (!static::hasMacro($method)) { |
|
| 98 | 98 | throw new BadMethodCallException(sprintf( |
| 99 | 99 | 'Method %s::%s does not exist.', static::class, $method |
| 100 | 100 | )); |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | /** |
| 210 | 210 | * Determine if an item exists in the collection. |
| 211 | 211 | * |
| 212 | - * @param mixed $key |
|
| 212 | + * @param \Closure $key |
|
| 213 | 213 | * @param mixed $operator |
| 214 | 214 | * @param mixed $value |
| 215 | 215 | * @return bool |
@@ -488,7 +488,7 @@ discard block |
||
| 488 | 488 | * Filter items by the given key value pair. |
| 489 | 489 | * |
| 490 | 490 | * @param string $key |
| 491 | - * @param mixed $operator |
|
| 491 | + * @param string $operator |
|
| 492 | 492 | * @param mixed $value |
| 493 | 493 | * @return static |
| 494 | 494 | */ |
@@ -627,7 +627,7 @@ discard block |
||
| 627 | 627 | * Get the first item from the collection. |
| 628 | 628 | * |
| 629 | 629 | * @param callable|null $callback |
| 630 | - * @param mixed $default |
|
| 630 | + * @param stdClass $default |
|
| 631 | 631 | * @return mixed |
| 632 | 632 | */ |
| 633 | 633 | public function first(callable $callback = null, $default = null) |
@@ -687,7 +687,7 @@ discard block |
||
| 687 | 687 | /** |
| 688 | 688 | * Get an item from the collection by key. |
| 689 | 689 | * |
| 690 | - * @param mixed $key |
|
| 690 | + * @param integer $key |
|
| 691 | 691 | * @param mixed $default |
| 692 | 692 | * @return mixed |
| 693 | 693 | */ |
@@ -1283,7 +1283,7 @@ discard block |
||
| 1283 | 1283 | * Reduce the collection to a single value. |
| 1284 | 1284 | * |
| 1285 | 1285 | * @param callable $callback |
| 1286 | - * @param mixed $initial |
|
| 1286 | + * @param integer $initial |
|
| 1287 | 1287 | * @return mixed |
| 1288 | 1288 | */ |
| 1289 | 1289 | public function reduce(callable $callback, $initial = null) |
@@ -1294,7 +1294,7 @@ discard block |
||
| 1294 | 1294 | /** |
| 1295 | 1295 | * Create a collection of all elements that do not pass a given truth test. |
| 1296 | 1296 | * |
| 1297 | - * @param callable|mixed $callback |
|
| 1297 | + * @param \Closure $callback |
|
| 1298 | 1298 | * @return static |
| 1299 | 1299 | */ |
| 1300 | 1300 | public function reject($callback) |
@@ -1857,7 +1857,7 @@ discard block |
||
| 1857 | 1857 | * Dynamically access collection proxies. |
| 1858 | 1858 | * |
| 1859 | 1859 | * @param string $key |
| 1860 | - * @return mixed |
|
| 1860 | + * @return HigherOrderCollectionProxy |
|
| 1861 | 1861 | * |
| 1862 | 1862 | * @throws \Exception |
| 1863 | 1863 | */ |
@@ -2,19 +2,19 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace IlluminateAgnostic\Str\Support; |
| 4 | 4 | |
| 5 | -use stdClass; |
|
| 6 | -use Countable; |
|
| 7 | -use Exception; |
|
| 8 | 5 | use ArrayAccess; |
| 9 | -use Traversable; |
|
| 10 | 6 | use ArrayIterator; |
| 11 | 7 | use CachingIterator; |
| 12 | -use JsonSerializable; |
|
| 13 | -use IteratorAggregate; |
|
| 8 | +use Countable; |
|
| 9 | +use Exception; |
|
| 10 | +use IlluminateAgnostic\Str\Contracts\Support\Arrayable; |
|
| 11 | +use IlluminateAgnostic\Str\Contracts\Support\Jsonable; |
|
| 14 | 12 | use IlluminateAgnostic\Str\Support\Debug\Dumper; |
| 15 | 13 | use IlluminateAgnostic\Str\Support\Traits\Macroable; |
| 16 | -use IlluminateAgnostic\Str\Contracts\Support\Jsonable; |
|
| 17 | -use IlluminateAgnostic\Str\Contracts\Support\Arrayable; |
|
| 14 | +use IteratorAggregate; |
|
| 15 | +use JsonSerializable; |
|
| 16 | +use Traversable; |
|
| 17 | +use stdClass; |
|
| 18 | 18 | |
| 19 | 19 | class Collection implements ArrayAccess, Arrayable, Countable, IteratorAggregate, Jsonable, JsonSerializable |
| 20 | 20 | { |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | |
| 184 | 184 | $counts = new self; |
| 185 | 185 | |
| 186 | - $collection->each(function ($value) use ($counts) { |
|
| 186 | + $collection->each(function($value) use ($counts) { |
|
| 187 | 187 | $counts[$value] = isset($counts[$value]) ? $counts[$value] + 1 : 1; |
| 188 | 188 | }); |
| 189 | 189 | |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | |
| 192 | 192 | $highestValue = $sorted->last(); |
| 193 | 193 | |
| 194 | - return $sorted->filter(function ($value) use ($highestValue) { |
|
| 194 | + return $sorted->filter(function($value) use ($highestValue) { |
|
| 195 | 195 | return $value == $highestValue; |
| 196 | 196 | })->sort()->keys()->all(); |
| 197 | 197 | } |
@@ -239,13 +239,13 @@ discard block |
||
| 239 | 239 | public function containsStrict($key, $value = null) |
| 240 | 240 | { |
| 241 | 241 | if (func_num_args() == 2) { |
| 242 | - return $this->contains(function ($item) use ($key, $value) { |
|
| 242 | + return $this->contains(function($item) use ($key, $value) { |
|
| 243 | 243 | return data_get($item, $key) === $value; |
| 244 | 244 | }); |
| 245 | 245 | } |
| 246 | 246 | |
| 247 | 247 | if ($this->useAsCallable($key)) { |
| 248 | - return ! is_null($this->first($key)); |
|
| 248 | + return !is_null($this->first($key)); |
|
| 249 | 249 | } |
| 250 | 250 | |
| 251 | 251 | return in_array($key, $this->items, true); |
@@ -287,7 +287,7 @@ discard block |
||
| 287 | 287 | { |
| 288 | 288 | (new static(func_get_args())) |
| 289 | 289 | ->push($this) |
| 290 | - ->each(function ($item) { |
|
| 290 | + ->each(function($item) { |
|
| 291 | 291 | (new Dumper)->dump($item); |
| 292 | 292 | }); |
| 293 | 293 | |
@@ -388,7 +388,7 @@ discard block |
||
| 388 | 388 | */ |
| 389 | 389 | public function eachSpread(callable $callback) |
| 390 | 390 | { |
| 391 | - return $this->each(function ($chunk, $key) use ($callback) { |
|
| 391 | + return $this->each(function($chunk, $key) use ($callback) { |
|
| 392 | 392 | $chunk[] = $key; |
| 393 | 393 | |
| 394 | 394 | return $callback(...$chunk); |
@@ -409,7 +409,7 @@ discard block |
||
| 409 | 409 | $callback = $this->valueRetriever($key); |
| 410 | 410 | |
| 411 | 411 | foreach ($this->items as $k => $v) { |
| 412 | - if (! $callback($v, $k)) { |
|
| 412 | + if (!$callback($v, $k)) { |
|
| 413 | 413 | return false; |
| 414 | 414 | } |
| 415 | 415 | } |
@@ -430,7 +430,7 @@ discard block |
||
| 430 | 430 | { |
| 431 | 431 | if ($keys instanceof self) { |
| 432 | 432 | $keys = $keys->all(); |
| 433 | - } elseif (! is_array($keys)) { |
|
| 433 | + } elseif (!is_array($keys)) { |
|
| 434 | 434 | $keys = func_get_args(); |
| 435 | 435 | } |
| 436 | 436 | |
@@ -481,7 +481,7 @@ discard block |
||
| 481 | 481 | */ |
| 482 | 482 | public function unless($value, callable $callback, callable $default = null) |
| 483 | 483 | { |
| 484 | - return $this->when(! $value, $callback, $default); |
|
| 484 | + return $this->when(!$value, $callback, $default); |
|
| 485 | 485 | } |
| 486 | 486 | |
| 487 | 487 | /** |
@@ -513,10 +513,10 @@ discard block |
||
| 513 | 513 | $operator = '='; |
| 514 | 514 | } |
| 515 | 515 | |
| 516 | - return function ($item) use ($key, $operator, $value) { |
|
| 516 | + return function($item) use ($key, $operator, $value) { |
|
| 517 | 517 | $retrieved = data_get($item, $key); |
| 518 | 518 | |
| 519 | - $strings = array_filter([$retrieved, $value], function ($value) { |
|
| 519 | + $strings = array_filter([$retrieved, $value], function($value) { |
|
| 520 | 520 | return is_string($value) || (is_object($value) && method_exists($value, '__toString')); |
| 521 | 521 | }); |
| 522 | 522 | |
@@ -564,7 +564,7 @@ discard block |
||
| 564 | 564 | { |
| 565 | 565 | $values = $this->getArrayableItems($values); |
| 566 | 566 | |
| 567 | - return $this->filter(function ($item) use ($key, $values, $strict) { |
|
| 567 | + return $this->filter(function($item) use ($key, $values, $strict) { |
|
| 568 | 568 | return in_array(data_get($item, $key), $values, $strict); |
| 569 | 569 | }); |
| 570 | 570 | } |
@@ -593,7 +593,7 @@ discard block |
||
| 593 | 593 | { |
| 594 | 594 | $values = $this->getArrayableItems($values); |
| 595 | 595 | |
| 596 | - return $this->reject(function ($item) use ($key, $values, $strict) { |
|
| 596 | + return $this->reject(function($item) use ($key, $values, $strict) { |
|
| 597 | 597 | return in_array(data_get($item, $key), $values, $strict); |
| 598 | 598 | }); |
| 599 | 599 | } |
@@ -618,7 +618,7 @@ discard block |
||
| 618 | 618 | */ |
| 619 | 619 | public function whereInstanceOf($type) |
| 620 | 620 | { |
| 621 | - return $this->filter(function ($value) use ($type) { |
|
| 621 | + return $this->filter(function($value) use ($type) { |
|
| 622 | 622 | return $value instanceof $type; |
| 623 | 623 | }); |
| 624 | 624 | } |
@@ -722,14 +722,14 @@ discard block |
||
| 722 | 722 | foreach ($this->items as $key => $value) { |
| 723 | 723 | $groupKeys = $groupBy($value, $key); |
| 724 | 724 | |
| 725 | - if (! is_array($groupKeys)) { |
|
| 725 | + if (!is_array($groupKeys)) { |
|
| 726 | 726 | $groupKeys = [$groupKeys]; |
| 727 | 727 | } |
| 728 | 728 | |
| 729 | 729 | foreach ($groupKeys as $groupKey) { |
| 730 | 730 | $groupKey = is_bool($groupKey) ? (int) $groupKey : $groupKey; |
| 731 | 731 | |
| 732 | - if (! array_key_exists($groupKey, $results)) { |
|
| 732 | + if (!array_key_exists($groupKey, $results)) { |
|
| 733 | 733 | $results[$groupKey] = new static; |
| 734 | 734 | } |
| 735 | 735 | |
@@ -739,7 +739,7 @@ discard block |
||
| 739 | 739 | |
| 740 | 740 | $result = new static($results); |
| 741 | 741 | |
| 742 | - if (! empty($nextGroups)) { |
|
| 742 | + if (!empty($nextGroups)) { |
|
| 743 | 743 | return $result->map->groupBy($nextGroups, $preserveKeys); |
| 744 | 744 | } |
| 745 | 745 | |
@@ -782,7 +782,7 @@ discard block |
||
| 782 | 782 | $keys = is_array($key) ? $key : func_get_args(); |
| 783 | 783 | |
| 784 | 784 | foreach ($keys as $value) { |
| 785 | - if (! $this->offsetExists($value)) { |
|
| 785 | + if (!$this->offsetExists($value)) { |
|
| 786 | 786 | return false; |
| 787 | 787 | } |
| 788 | 788 | } |
@@ -849,7 +849,7 @@ discard block |
||
| 849 | 849 | */ |
| 850 | 850 | public function isNotEmpty() |
| 851 | 851 | { |
| 852 | - return ! $this->isEmpty(); |
|
| 852 | + return !$this->isEmpty(); |
|
| 853 | 853 | } |
| 854 | 854 | |
| 855 | 855 | /** |
@@ -860,7 +860,7 @@ discard block |
||
| 860 | 860 | */ |
| 861 | 861 | protected function useAsCallable($value) |
| 862 | 862 | { |
| 863 | - return ! is_string($value) && is_callable($value); |
|
| 863 | + return !is_string($value) && is_callable($value); |
|
| 864 | 864 | } |
| 865 | 865 | |
| 866 | 866 | /** |
@@ -920,7 +920,7 @@ discard block |
||
| 920 | 920 | */ |
| 921 | 921 | public function mapSpread(callable $callback) |
| 922 | 922 | { |
| 923 | - return $this->map(function ($chunk, $key) use ($callback) { |
|
| 923 | + return $this->map(function($chunk, $key) use ($callback) { |
|
| 924 | 924 | $chunk[] = $key; |
| 925 | 925 | |
| 926 | 926 | return $callback(...$chunk); |
@@ -946,7 +946,7 @@ discard block |
||
| 946 | 946 | |
| 947 | 947 | $value = reset($pair); |
| 948 | 948 | |
| 949 | - if (! isset($dictionary[$key])) { |
|
| 949 | + if (!isset($dictionary[$key])) { |
|
| 950 | 950 | $dictionary[$key] = []; |
| 951 | 951 | } |
| 952 | 952 | |
@@ -1013,7 +1013,7 @@ discard block |
||
| 1013 | 1013 | */ |
| 1014 | 1014 | public function mapInto($class) |
| 1015 | 1015 | { |
| 1016 | - return $this->map(function ($value, $key) use ($class) { |
|
| 1016 | + return $this->map(function($value, $key) use ($class) { |
|
| 1017 | 1017 | return new $class($value, $key); |
| 1018 | 1018 | }); |
| 1019 | 1019 | } |
@@ -1028,9 +1028,9 @@ discard block |
||
| 1028 | 1028 | { |
| 1029 | 1029 | $callback = $this->valueRetriever($callback); |
| 1030 | 1030 | |
| 1031 | - return $this->filter(function ($value) { |
|
| 1032 | - return ! is_null($value); |
|
| 1033 | - })->reduce(function ($result, $item) use ($callback) { |
|
| 1031 | + return $this->filter(function($value) { |
|
| 1032 | + return !is_null($value); |
|
| 1033 | + })->reduce(function($result, $item) use ($callback) { |
|
| 1034 | 1034 | $value = $callback($item); |
| 1035 | 1035 | |
| 1036 | 1036 | return is_null($result) || $value > $result ? $value : $result; |
@@ -1080,9 +1080,9 @@ discard block |
||
| 1080 | 1080 | { |
| 1081 | 1081 | $callback = $this->valueRetriever($callback); |
| 1082 | 1082 | |
| 1083 | - return $this->filter(function ($value) { |
|
| 1084 | - return ! is_null($value); |
|
| 1085 | - })->reduce(function ($result, $item) use ($callback) { |
|
| 1083 | + return $this->filter(function($value) { |
|
| 1084 | + return !is_null($value); |
|
| 1085 | + })->reduce(function($result, $item) use ($callback) { |
|
| 1086 | 1086 | $value = $callback($item); |
| 1087 | 1087 | |
| 1088 | 1088 | return is_null($result) || $value < $result ? $value : $result; |
@@ -1165,7 +1165,7 @@ discard block |
||
| 1165 | 1165 | : $this->operatorForWhere(...func_get_args()); |
| 1166 | 1166 | |
| 1167 | 1167 | foreach ($this->items as $key => $item) { |
| 1168 | - $partitions[(int) ! $callback($item, $key)][$key] = $item; |
|
| 1168 | + $partitions[(int) !$callback($item, $key)][$key] = $item; |
|
| 1169 | 1169 | } |
| 1170 | 1170 | |
| 1171 | 1171 | return new static($partitions); |
@@ -1300,12 +1300,12 @@ discard block |
||
| 1300 | 1300 | public function reject($callback) |
| 1301 | 1301 | { |
| 1302 | 1302 | if ($this->useAsCallable($callback)) { |
| 1303 | - return $this->filter(function ($value, $key) use ($callback) { |
|
| 1304 | - return ! $callback($value, $key); |
|
| 1303 | + return $this->filter(function($value, $key) use ($callback) { |
|
| 1304 | + return !$callback($value, $key); |
|
| 1305 | 1305 | }); |
| 1306 | 1306 | } |
| 1307 | 1307 | |
| 1308 | - return $this->filter(function ($item) use ($callback) { |
|
| 1308 | + return $this->filter(function($item) use ($callback) { |
|
| 1309 | 1309 | return $item != $callback; |
| 1310 | 1310 | }); |
| 1311 | 1311 | } |
@@ -1329,7 +1329,7 @@ discard block |
||
| 1329 | 1329 | */ |
| 1330 | 1330 | public function search($value, $strict = false) |
| 1331 | 1331 | { |
| 1332 | - if (! $this->useAsCallable($value)) { |
|
| 1332 | + if (!$this->useAsCallable($value)) { |
|
| 1333 | 1333 | return array_search($value, $this->items, $strict); |
| 1334 | 1334 | } |
| 1335 | 1335 | |
@@ -1534,7 +1534,7 @@ discard block |
||
| 1534 | 1534 | |
| 1535 | 1535 | $callback = $this->valueRetriever($callback); |
| 1536 | 1536 | |
| 1537 | - return $this->reduce(function ($result, $item) use ($callback) { |
|
| 1537 | + return $this->reduce(function($result, $item) use ($callback) { |
|
| 1538 | 1538 | return $result + $callback($item); |
| 1539 | 1539 | }, 0); |
| 1540 | 1540 | } |
@@ -1593,7 +1593,7 @@ discard block |
||
| 1593 | 1593 | |
| 1594 | 1594 | $exists = []; |
| 1595 | 1595 | |
| 1596 | - return $this->reject(function ($item, $key) use ($callback, $strict, &$exists) { |
|
| 1596 | + return $this->reject(function($item, $key) use ($callback, $strict, &$exists) { |
|
| 1597 | 1597 | if (in_array($id = $callback($item, $key), $exists, $strict)) { |
| 1598 | 1598 | return true; |
| 1599 | 1599 | } |
@@ -1635,7 +1635,7 @@ discard block |
||
| 1635 | 1635 | return $value; |
| 1636 | 1636 | } |
| 1637 | 1637 | |
| 1638 | - return function ($item) use ($value) { |
|
| 1638 | + return function($item) use ($value) { |
|
| 1639 | 1639 | return data_get($item, $value); |
| 1640 | 1640 | }; |
| 1641 | 1641 | } |
@@ -1651,11 +1651,11 @@ discard block |
||
| 1651 | 1651 | */ |
| 1652 | 1652 | public function zip($items) |
| 1653 | 1653 | { |
| 1654 | - $arrayableItems = array_map(function ($items) { |
|
| 1654 | + $arrayableItems = array_map(function($items) { |
|
| 1655 | 1655 | return $this->getArrayableItems($items); |
| 1656 | 1656 | }, func_get_args()); |
| 1657 | 1657 | |
| 1658 | - $params = array_merge([function () { |
|
| 1658 | + $params = array_merge([function() { |
|
| 1659 | 1659 | return new static(func_get_args()); |
| 1660 | 1660 | }, $this->items], $arrayableItems); |
| 1661 | 1661 | |
@@ -1681,7 +1681,7 @@ discard block |
||
| 1681 | 1681 | */ |
| 1682 | 1682 | public function toArray() |
| 1683 | 1683 | { |
| 1684 | - return array_map(function ($value) { |
|
| 1684 | + return array_map(function($value) { |
|
| 1685 | 1685 | return $value instanceof Arrayable ? $value->toArray() : $value; |
| 1686 | 1686 | }, $this->items); |
| 1687 | 1687 | } |
@@ -1693,7 +1693,7 @@ discard block |
||
| 1693 | 1693 | */ |
| 1694 | 1694 | public function jsonSerialize() |
| 1695 | 1695 | { |
| 1696 | - return array_map(function ($value) { |
|
| 1696 | + return array_map(function($value) { |
|
| 1697 | 1697 | if ($value instanceof JsonSerializable) { |
| 1698 | 1698 | return $value->jsonSerialize(); |
| 1699 | 1699 | } elseif ($value instanceof Jsonable) { |
@@ -1863,7 +1863,7 @@ discard block |
||
| 1863 | 1863 | */ |
| 1864 | 1864 | public function __get($key) |
| 1865 | 1865 | { |
| 1866 | - if (! in_array($key, static::$proxies)) { |
|
| 1866 | + if (!in_array($key, static::$proxies)) { |
|
| 1867 | 1867 | throw new Exception("Property [{$key}] does not exist on this collection instance."); |
| 1868 | 1868 | } |
| 1869 | 1869 | |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | */ |
| 43 | 43 | public function __get($key) |
| 44 | 44 | { |
| 45 | - return $this->collection->{$this->method}(function ($value) use ($key) { |
|
| 45 | + return $this->collection->{$this->method}(function($value) use ($key) { |
|
| 46 | 46 | return is_array($value) ? $value[$key] : $value->{$key}; |
| 47 | 47 | }); |
| 48 | 48 | } |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | */ |
| 57 | 57 | public function __call($method, $parameters) |
| 58 | 58 | { |
| 59 | - return $this->collection->{$this->method}(function ($value) use ($method, $parameters) { |
|
| 59 | + return $this->collection->{$this->method}(function($value) use ($method, $parameters) { |
|
| 60 | 60 | return $value->{$method}(...$parameters); |
| 61 | 61 | }); |
| 62 | 62 | } |
@@ -30,7 +30,7 @@ |
||
| 30 | 30 | |
| 31 | 31 | $carbon = $this; |
| 32 | 32 | |
| 33 | - return call_user_func(function () use ($carbon) { |
|
| 33 | + return call_user_func(function() use ($carbon) { |
|
| 34 | 34 | return get_object_vars($carbon); |
| 35 | 35 | }); |
| 36 | 36 | } |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | foreach ($array as $values) { |
| 52 | 52 | if ($values instanceof Collection) { |
| 53 | 53 | $values = $values->all(); |
| 54 | - } elseif (! is_array($values)) { |
|
| 54 | + } elseif (!is_array($values)) { |
|
| 55 | 55 | continue; |
| 56 | 56 | } |
| 57 | 57 | |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | $results = []; |
| 112 | 112 | |
| 113 | 113 | foreach ($array as $key => $value) { |
| 114 | - if (is_array($value) && ! empty($value)) { |
|
| 114 | + if (is_array($value) && !empty($value)) { |
|
| 115 | 115 | $results = array_merge($results, static::dot($value, $prepend.$key.'.')); |
| 116 | 116 | } else { |
| 117 | 117 | $results[$prepend.$key] = $value; |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | foreach ($array as $item) { |
| 212 | 212 | $item = $item instanceof Collection ? $item->all() : $item; |
| 213 | 213 | |
| 214 | - if (! is_array($item)) { |
|
| 214 | + if (!is_array($item)) { |
|
| 215 | 215 | $result[] = $item; |
| 216 | 216 | } elseif ($depth === 1) { |
| 217 | 217 | $result = array_merge($result, array_values($item)); |
@@ -277,7 +277,7 @@ discard block |
||
| 277 | 277 | */ |
| 278 | 278 | public static function get($array, $key, $default = null) |
| 279 | 279 | { |
| 280 | - if (! static::accessible($array)) { |
|
| 280 | + if (!static::accessible($array)) { |
|
| 281 | 281 | return value($default); |
| 282 | 282 | } |
| 283 | 283 | |
@@ -319,7 +319,7 @@ discard block |
||
| 319 | 319 | |
| 320 | 320 | $keys = (array) $keys; |
| 321 | 321 | |
| 322 | - if (! $array) { |
|
| 322 | + if (!$array) { |
|
| 323 | 323 | return false; |
| 324 | 324 | } |
| 325 | 325 | |
@@ -525,7 +525,7 @@ discard block |
||
| 525 | 525 | // If the key doesn't exist at this depth, we will just create an empty array |
| 526 | 526 | // to hold the next value, allowing us to create the arrays to hold final |
| 527 | 527 | // values at the correct depth. Then we'll keep digging into the array. |
| 528 | - if (! isset($array[$key]) || ! is_array($array[$key])) { |
|
| 528 | + if (!isset($array[$key]) || !is_array($array[$key])) { |
|
| 529 | 529 | $array[$key] = []; |
| 530 | 530 | } |
| 531 | 531 | |
@@ -551,7 +551,7 @@ discard block |
||
| 551 | 551 | } else { |
| 552 | 552 | srand($seed); |
| 553 | 553 | |
| 554 | - usort($array, function () { |
|
| 554 | + usort($array, function() { |
|
| 555 | 555 | return rand(-1, 1); |
| 556 | 556 | }); |
| 557 | 557 | } |
@@ -618,6 +618,6 @@ discard block |
||
| 618 | 618 | return []; |
| 619 | 619 | } |
| 620 | 620 | |
| 621 | - return ! is_array($value) ? [$value] : $value; |
|
| 621 | + return !is_array($value) ? [$value] : $value; |
|
| 622 | 622 | } |
| 623 | 623 | } |
@@ -1,9 +1,9 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | use IlluminateAgnostic\Str\Support\Arr; |
| 4 | -use IlluminateAgnostic\Str\Support\Str; |
|
| 5 | 4 | use IlluminateAgnostic\Str\Support\Collection; |
| 6 | 5 | use IlluminateAgnostic\Str\Support\Debug\Dumper; |
| 6 | +use IlluminateAgnostic\Str\Support\Str; |
|
| 7 | 7 | |
| 8 | 8 | if (! class_exists(Illuminate\Support\Collection::class)) { |
| 9 | 9 | if (! function_exists('camel_case')) { |
@@ -5,8 +5,8 @@ discard block |
||
| 5 | 5 | use IlluminateAgnostic\Str\Support\Collection; |
| 6 | 6 | use IlluminateAgnostic\Str\Support\Debug\Dumper; |
| 7 | 7 | |
| 8 | -if (! class_exists(Illuminate\Support\Collection::class)) { |
|
| 9 | - if (! function_exists('camel_case')) { |
|
| 8 | +if (!class_exists(Illuminate\Support\Collection::class)) { |
|
| 9 | + if (!function_exists('camel_case')) { |
|
| 10 | 10 | /** |
| 11 | 11 | * Convert a value to camel case. |
| 12 | 12 | * |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | } |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | - if (! function_exists('collect')) { |
|
| 22 | + if (!function_exists('collect')) { |
|
| 23 | 23 | /** |
| 24 | 24 | * Create a collection from the given value. |
| 25 | 25 | * |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | } |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - if (! function_exists('data_get')) { |
|
| 35 | + if (!function_exists('data_get')) { |
|
| 36 | 36 | /** |
| 37 | 37 | * Get an item from an array or object using "dot" notation. |
| 38 | 38 | * |
@@ -49,11 +49,11 @@ discard block |
||
| 49 | 49 | |
| 50 | 50 | $key = is_array($key) ? $key : explode('.', $key); |
| 51 | 51 | |
| 52 | - while (! is_null($segment = array_shift($key))) { |
|
| 52 | + while (!is_null($segment = array_shift($key))) { |
|
| 53 | 53 | if ($segment === '*') { |
| 54 | 54 | if ($target instanceof Collection) { |
| 55 | 55 | $target = $target->all(); |
| 56 | - } elseif (! is_array($target)) { |
|
| 56 | + } elseif (!is_array($target)) { |
|
| 57 | 57 | return value($default); |
| 58 | 58 | } |
| 59 | 59 | |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | } |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - if (! function_exists('ends_with')) { |
|
| 78 | + if (!function_exists('ends_with')) { |
|
| 79 | 79 | /** |
| 80 | 80 | * Determine if a given string ends with a given substring. |
| 81 | 81 | * |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | } |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | - if (! function_exists('kebab_case')) { |
|
| 92 | + if (!function_exists('kebab_case')) { |
|
| 93 | 93 | /** |
| 94 | 94 | * Convert a string to kebab case. |
| 95 | 95 | * |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | |
| 106 | - if (! function_exists('snake_case')) { |
|
| 106 | + if (!function_exists('snake_case')) { |
|
| 107 | 107 | /** |
| 108 | 108 | * Convert a string to snake case. |
| 109 | 109 | * |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | } |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | - if (! function_exists('starts_with')) { |
|
| 120 | + if (!function_exists('starts_with')) { |
|
| 121 | 121 | /** |
| 122 | 122 | * Determine if a given string starts with a given substring. |
| 123 | 123 | * |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | } |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | - if (! function_exists('str_after')) { |
|
| 134 | + if (!function_exists('str_after')) { |
|
| 135 | 135 | /** |
| 136 | 136 | * Return the remainder of a string after a given value. |
| 137 | 137 | * |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | } |
| 146 | 146 | } |
| 147 | 147 | |
| 148 | - if (! function_exists('str_before')) { |
|
| 148 | + if (!function_exists('str_before')) { |
|
| 149 | 149 | /** |
| 150 | 150 | * Get the portion of a string before a given value. |
| 151 | 151 | * |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | } |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | - if (! function_exists('str_contains')) { |
|
| 162 | + if (!function_exists('str_contains')) { |
|
| 163 | 163 | /** |
| 164 | 164 | * Determine if a given string contains a given substring. |
| 165 | 165 | * |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | } |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | - if (! function_exists('str_finish')) { |
|
| 176 | + if (!function_exists('str_finish')) { |
|
| 177 | 177 | /** |
| 178 | 178 | * Cap a string with a single instance of a given value. |
| 179 | 179 | * |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | } |
| 188 | 188 | } |
| 189 | 189 | |
| 190 | - if (! function_exists('str_is')) { |
|
| 190 | + if (!function_exists('str_is')) { |
|
| 191 | 191 | /** |
| 192 | 192 | * Determine if a given string matches a given pattern. |
| 193 | 193 | * |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | } |
| 202 | 202 | } |
| 203 | 203 | |
| 204 | - if (! function_exists('str_limit')) { |
|
| 204 | + if (!function_exists('str_limit')) { |
|
| 205 | 205 | /** |
| 206 | 206 | * Limit the number of characters in a string. |
| 207 | 207 | * |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | } |
| 217 | 217 | } |
| 218 | 218 | |
| 219 | - if (! function_exists('str_plural')) { |
|
| 219 | + if (!function_exists('str_plural')) { |
|
| 220 | 220 | /** |
| 221 | 221 | * Get the plural form of an English word. |
| 222 | 222 | * |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | } |
| 231 | 231 | } |
| 232 | 232 | |
| 233 | - if (! function_exists('str_random')) { |
|
| 233 | + if (!function_exists('str_random')) { |
|
| 234 | 234 | /** |
| 235 | 235 | * Generate a more truly "random" alpha-numeric string. |
| 236 | 236 | * |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | } |
| 246 | 246 | } |
| 247 | 247 | |
| 248 | - if (! function_exists('str_replace_array')) { |
|
| 248 | + if (!function_exists('str_replace_array')) { |
|
| 249 | 249 | /** |
| 250 | 250 | * Replace a given value in the string sequentially with an array. |
| 251 | 251 | * |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | } |
| 261 | 261 | } |
| 262 | 262 | |
| 263 | - if (! function_exists('str_replace_first')) { |
|
| 263 | + if (!function_exists('str_replace_first')) { |
|
| 264 | 264 | /** |
| 265 | 265 | * Replace the first occurrence of a given value in the string. |
| 266 | 266 | * |
@@ -275,7 +275,7 @@ discard block |
||
| 275 | 275 | } |
| 276 | 276 | } |
| 277 | 277 | |
| 278 | - if (! function_exists('str_replace_last')) { |
|
| 278 | + if (!function_exists('str_replace_last')) { |
|
| 279 | 279 | /** |
| 280 | 280 | * Replace the last occurrence of a given value in the string. |
| 281 | 281 | * |
@@ -290,7 +290,7 @@ discard block |
||
| 290 | 290 | } |
| 291 | 291 | } |
| 292 | 292 | |
| 293 | - if (! function_exists('str_singular')) { |
|
| 293 | + if (!function_exists('str_singular')) { |
|
| 294 | 294 | /** |
| 295 | 295 | * Get the singular form of an English word. |
| 296 | 296 | * |
@@ -303,7 +303,7 @@ discard block |
||
| 303 | 303 | } |
| 304 | 304 | } |
| 305 | 305 | |
| 306 | - if (! function_exists('str_slug')) { |
|
| 306 | + if (!function_exists('str_slug')) { |
|
| 307 | 307 | /** |
| 308 | 308 | * Generate a URL friendly "slug" from a given string. |
| 309 | 309 | * |
@@ -318,7 +318,7 @@ discard block |
||
| 318 | 318 | } |
| 319 | 319 | } |
| 320 | 320 | |
| 321 | - if (! function_exists('str_start')) { |
|
| 321 | + if (!function_exists('str_start')) { |
|
| 322 | 322 | /** |
| 323 | 323 | * Begin a string with a single instance of a given value. |
| 324 | 324 | * |
@@ -332,7 +332,7 @@ discard block |
||
| 332 | 332 | } |
| 333 | 333 | } |
| 334 | 334 | |
| 335 | - if (! function_exists('studly_case')) { |
|
| 335 | + if (!function_exists('studly_case')) { |
|
| 336 | 336 | /** |
| 337 | 337 | * Convert a value to studly caps case. |
| 338 | 338 | * |
@@ -346,7 +346,7 @@ discard block |
||
| 346 | 346 | } |
| 347 | 347 | |
| 348 | 348 | |
| 349 | - if (! function_exists('title_case')) { |
|
| 349 | + if (!function_exists('title_case')) { |
|
| 350 | 350 | /** |
| 351 | 351 | * Convert a value to title case. |
| 352 | 352 | * |
@@ -360,7 +360,7 @@ discard block |
||
| 360 | 360 | } |
| 361 | 361 | |
| 362 | 362 | |
| 363 | - if (! function_exists('value')) { |
|
| 363 | + if (!function_exists('value')) { |
|
| 364 | 364 | /** |
| 365 | 365 | * Return the default value of the given value. |
| 366 | 366 | * |
@@ -374,7 +374,7 @@ discard block |
||
| 374 | 374 | } |
| 375 | 375 | |
| 376 | 376 | |
| 377 | - if (! function_exists('dd')) { |
|
| 377 | + if (!function_exists('dd')) { |
|
| 378 | 378 | /** |
| 379 | 379 | * Dump the passed variables and end the script. |
| 380 | 380 | * |