| @@ -40,11 +40,11 @@ | ||
| 40 | 40 | */ | 
| 41 | 41 | public static function unpack(object $object, mixed $attribute = null) : object | 
| 42 | 42 |      { | 
| 43 | - $object = (array) $object; | |
| 43 | + $object = (array)$object; | |
| 44 | 44 | $object = $attribute | 
| 45 | 45 | ? ArraysMethods::get($object, $attribute) | 
| 46 | 46 | : ArraysMethods::first($object); | 
| 47 | 47 | |
| 48 | - return (object) $object; | |
| 48 | + return (object)$object; | |
| 49 | 49 | } | 
| 50 | 50 | } | 
| @@ -58,17 +58,17 @@ discard block | ||
| 58 | 58 | return $collection; | 
| 59 | 59 | } | 
| 60 | 60 | |
| 61 | - $collection = (array) $collection; | |
| 61 | + $collection = (array)$collection; | |
| 62 | 62 | |
| 63 | 63 |          if (isset($collection[$key])) { | 
| 64 | 64 | return $collection[$key]; | 
| 65 | 65 | } | 
| 66 | 66 | |
| 67 | 67 | // Crawl through collection, get key according to object or not | 
| 68 | -        foreach (explode('.', (string) $key) as $segment) { | |
| 69 | - $collection = (array) $collection; | |
| 68 | +        foreach (explode('.', (string)$key) as $segment) { | |
| 69 | + $collection = (array)$collection; | |
| 70 | 70 | |
| 71 | -            if (!isset($collection[$segment])) { | |
| 71 | +            if ( ! isset($collection[$segment])) { | |
| 72 | 72 | return $default instanceof Closure ? $default() : $default; | 
| 73 | 73 | } | 
| 74 | 74 | |
| @@ -106,7 +106,7 @@ discard block | ||
| 106 | 106 | public static function setAndGet(mixed &$collection, string $key, mixed $default = null) : mixed | 
| 107 | 107 |      { | 
| 108 | 108 | // If the key doesn't exist, set it | 
| 109 | -        if (!static::has($collection, $key)) { | |
| 109 | +        if ( ! static::has($collection, $key)) { | |
| 110 | 110 | $collection = static::set($collection, $key, $default); | 
| 111 | 111 | } | 
| 112 | 112 | |
| @@ -121,7 +121,7 @@ discard block | ||
| 121 | 121 | * | 
| 122 | 122 | * @return mixed | 
| 123 | 123 | */ | 
| 124 | - public static function remove(mixed $collection, string|array $key) : mixed | |
| 124 | + public static function remove(mixed $collection, string | array $key) : mixed | |
| 125 | 125 |      { | 
| 126 | 126 | // Recursive call | 
| 127 | 127 |          if (\is_array($key)) { | 
| @@ -145,13 +145,13 @@ discard block | ||
| 145 | 145 | * | 
| 146 | 146 | * @return array|object | 
| 147 | 147 | */ | 
| 148 | - public static function pluck($collection, $property) : object|array | |
| 148 | + public static function pluck($collection, $property) : object | array | |
| 149 | 149 |      { | 
| 150 | - $plucked = array_map(fn($value) => ArraysMethods::get($value, $property), (array) $collection); | |
| 150 | + $plucked = array_map(fn($value) => ArraysMethods::get($value, $property), (array)$collection); | |
| 151 | 151 | |
| 152 | 152 | // Convert back to object if necessary | 
| 153 | 153 |          if (\is_object($collection)) { | 
| 154 | - return (object) $plucked; | |
| 154 | + return (object)$plucked; | |
| 155 | 155 | } | 
| 156 | 156 | |
| 157 | 157 | return $plucked; | 
| @@ -169,9 +169,9 @@ discard block | ||
| 169 | 169 | * @return array|object | 
| 170 | 170 | */ | 
| 171 | 171 | public static function filterBy($collection, string $property, mixed $value, string $comparisonOp = null) : | 
| 172 | - object|array | |
| 172 | + object | array | |
| 173 | 173 |      { | 
| 174 | -        if (!$comparisonOp) { | |
| 174 | +        if ( ! $comparisonOp) { | |
| 175 | 175 | $comparisonOp = \is_array($value) ? 'contains' : 'eq'; | 
| 176 | 176 | } | 
| 177 | 177 | |
| @@ -182,32 +182,32 @@ discard block | ||
| 182 | 182 | 'lt' => fn($item, $prop, $value) : bool => $item[$prop] < $value, | 
| 183 | 183 | 'lte' => fn($item, $prop, $value) : bool => $item[$prop] <= $value, | 
| 184 | 184 | 'ne' => fn($item, $prop, $value) : bool => $item[$prop] !== $value, | 
| 185 | - 'contains' => fn($item, $prop, $value) : bool => \in_array($item[$prop], (array) $value, true), | |
| 186 | - 'notContains' => fn($item, $prop, $value) : bool => ! \in_array($item[$prop], (array) $value, true), | |
| 185 | + 'contains' => fn($item, $prop, $value) : bool => \in_array($item[$prop], (array)$value, true), | |
| 186 | + 'notContains' => fn($item, $prop, $value) : bool => ! \in_array($item[$prop], (array)$value, true), | |
| 187 | 187 | 'newer' => fn( | 
| 188 | 188 | $item, | 
| 189 | 189 | $prop, | 
| 190 | 190 | $value | 
| 191 | - ) : bool => strtotime((string) $item[$prop]) > strtotime((string) $value), | |
| 191 | + ) : bool => strtotime((string)$item[$prop]) > strtotime((string)$value), | |
| 192 | 192 | 'older' => fn( | 
| 193 | 193 | $item, | 
| 194 | 194 | $prop, | 
| 195 | 195 | $value | 
| 196 | - ) : bool => strtotime((string) $item[$prop]) < strtotime((string) $value), | |
| 196 | + ) : bool => strtotime((string)$item[$prop]) < strtotime((string)$value), | |
| 197 | 197 | ]; | 
| 198 | - $result = array_values(array_filter((array) $collection, function ($item) use ( | |
| 198 | + $result = array_values(array_filter((array)$collection, function($item) use ( | |
| 199 | 199 | $property, | 
| 200 | 200 | $value, | 
| 201 | 201 | $ops, | 
| 202 | 202 | $comparisonOp | 
| 203 | 203 |          ) { | 
| 204 | - $item = (array) $item; | |
| 204 | + $item = (array)$item; | |
| 205 | 205 | $item[$property] = static::get($item, $property, []); | 
| 206 | 206 | |
| 207 | 207 | return $ops[$comparisonOp]($item, $property, $value); | 
| 208 | 208 | })); | 
| 209 | 209 |          if (\is_object($collection)) { | 
| 210 | - return (object) $result; | |
| 210 | + return (object)$result; | |
| 211 | 211 | } | 
| 212 | 212 | |
| 213 | 213 | return $result; | 
| @@ -225,7 +225,7 @@ discard block | ||
| 225 | 225 |      { | 
| 226 | 226 | $filtered = static::filterBy($collection, $property, $value, $comparisonOp); | 
| 227 | 227 | |
| 228 | - return ArraysMethods::first(\is_array($filtered) ? $filtered : (array) $filtered); | |
| 228 | + return ArraysMethods::first(\is_array($filtered) ? $filtered : (array)$filtered); | |
| 229 | 229 | } | 
| 230 | 230 | |
| 231 | 231 | //////////////////////////////////////////////////////////////////// | 
| @@ -240,7 +240,7 @@ discard block | ||
| 240 | 240 | */ | 
| 241 | 241 | public static function keys($collection) : array | 
| 242 | 242 |      { | 
| 243 | - return array_keys((array) $collection); | |
| 243 | + return array_keys((array)$collection); | |
| 244 | 244 | } | 
| 245 | 245 | |
| 246 | 246 | /** | 
| @@ -252,7 +252,7 @@ discard block | ||
| 252 | 252 | */ | 
| 253 | 253 | public static function values($collection) : array | 
| 254 | 254 |      { | 
| 255 | - return array_values((array) $collection); | |
| 255 | + return array_values((array)$collection); | |
| 256 | 256 | } | 
| 257 | 257 | |
| 258 | 258 | //////////////////////////////////////////////////////////////////// | 
| @@ -269,7 +269,7 @@ discard block | ||
| 269 | 269 | * | 
| 270 | 270 | * @return mixed | 
| 271 | 271 | */ | 
| 272 | - public static function replace(array|object $collection, string $replace, string $key, mixed $value) : mixed | |
| 272 | + public static function replace(array | object $collection, string $replace, string $key, mixed $value) : mixed | |
| 273 | 273 |      { | 
| 274 | 274 | $collection = static::remove($collection, $replace); | 
| 275 | 275 | |
| @@ -286,10 +286,10 @@ discard block | ||
| 286 | 286 | * | 
| 287 | 287 | * @return array | 
| 288 | 288 | */ | 
| 289 | - public static function sort(array|object $collection, string|callable $sorter = null, string $direction = 'asc') : | |
| 289 | + public static function sort(array | object $collection, string | callable $sorter = null, string $direction = 'asc') : | |
| 290 | 290 | array | 
| 291 | 291 |      { | 
| 292 | - $collection = (array) $collection; | |
| 292 | + $collection = (array)$collection; | |
| 293 | 293 | |
| 294 | 294 | // Get correct PHP constant for direction | 
| 295 | 295 | $directionNumber = (strtolower($direction) === 'desc') ? SORT_DESC : SORT_ASC; | 
| @@ -319,9 +319,9 @@ discard block | ||
| 319 | 319 | * | 
| 320 | 320 | * @return array | 
| 321 | 321 | */ | 
| 322 | - public static function group(mixed $collection, callable|string $grouper, bool $saveKeys = false) : array | |
| 322 | + public static function group(mixed $collection, callable | string $grouper, bool $saveKeys = false) : array | |
| 323 | 323 |      { | 
| 324 | - $collection = (array) $collection; | |
| 324 | + $collection = (array)$collection; | |
| 325 | 325 | $result = []; | 
| 326 | 326 | |
| 327 | 327 | // Iterate over values, group by property/results from closure | 
| @@ -362,7 +362,7 @@ discard block | ||
| 362 | 362 | } | 
| 363 | 363 | |
| 364 | 364 | // Explode the keys | 
| 365 | -        $keys = explode('.', (string) $key); | |
| 365 | +        $keys = explode('.', (string)$key); | |
| 366 | 366 | |
| 367 | 367 | // Crawl through the keys | 
| 368 | 368 |          while (\count($keys) > 1) { | 
| @@ -398,7 +398,7 @@ discard block | ||
| 398 | 398 | * | 
| 399 | 399 | * @return mixed | 
| 400 | 400 | */ | 
| 401 | - protected static function internalRemove(array|object &$collection, mixed $key) : bool | |
| 401 | + protected static function internalRemove(array | object &$collection, mixed $key) : bool | |
| 402 | 402 |      { | 
| 403 | 403 | // Explode keys | 
| 404 | 404 |          $keys = explode('.', $key); | 
| @@ -69,7 +69,7 @@ discard block | ||
| 69 | 69 | * | 
| 70 | 70 | * @return int|string|bool | 
| 71 | 71 | */ | 
| 72 | - public static function search(array $array, mixed $value) : int|string|bool | |
| 72 | + public static function search(array $array, mixed $value) : int | string | bool | |
| 73 | 73 |      { | 
| 74 | 74 | return array_search($value, $array, true); | 
| 75 | 75 | } | 
| @@ -207,7 +207,7 @@ discard block | ||
| 207 | 207 | */ | 
| 208 | 208 | public static function clean(array $array) : mixed | 
| 209 | 209 |      { | 
| 210 | - return static::filter($array, fn($value) : bool => (bool) $value); | |
| 210 | + return static::filter($array, fn($value) : bool => (bool)$value); | |
| 211 | 211 | } | 
| 212 | 212 | |
| 213 | 213 | /** | 
| @@ -232,7 +232,7 @@ discard block | ||
| 232 | 232 | */ | 
| 233 | 233 | public static function without(...$arguments) | 
| 234 | 234 |      { | 
| 235 | - $array = array_shift($arguments); | |
| 235 | + $array = array_shift($arguments); | |
| 236 | 236 | // if singular argument and is an array treat this AS the array to run without agains | 
| 237 | 237 |          if (\is_array($arguments[0]) && \count($arguments) === 1) { | 
| 238 | 238 | $arguments = $arguments[0]; | 
| @@ -345,7 +345,7 @@ discard block | ||
| 345 | 345 | */ | 
| 346 | 346 | public static function replaceValue(array $array, string $replace, string $with) : array | 
| 347 | 347 |      { | 
| 348 | - return static::each($array, fn($value) : string|array => str_replace($replace, $with, (string) $value)); | |
| 348 | + return static::each($array, fn($value) : string | array => str_replace($replace, $with, (string)$value)); | |
| 349 | 349 | } | 
| 350 | 350 | |
| 351 | 351 | /** | 
| @@ -475,7 +475,7 @@ discard block | ||
| 475 | 475 | * | 
| 476 | 476 | * @return array | 
| 477 | 477 | */ | 
| 478 | - public static function invoke(array $array, Closure|string $callable, mixed $arguments = []) : array | |
| 478 | + public static function invoke(array $array, Closure | string $callable, mixed $arguments = []) : array | |
| 479 | 479 |      { | 
| 480 | 480 | // If one argument given for each iteration, create an array for it | 
| 481 | 481 |          if ( ! \is_array($arguments)) { | 
| @@ -585,7 +585,7 @@ discard block | ||
| 585 | 585 | */ | 
| 586 | 586 | public static function unique(array $array) : array | 
| 587 | 587 |      { | 
| 588 | -        return array_reduce($array, function (array $resultArray, $value) : array { | |
| 588 | +        return array_reduce($array, function(array $resultArray, $value) : array { | |
| 589 | 589 |              if ( ! static::contains($resultArray, $value)) { | 
| 590 | 590 | $resultArray[] = $value; | 
| 591 | 591 | } |