| @@ -59,7 +59,7 @@ | ||
| 59 | 59 | public static function option(string $option) : mixed | 
| 60 | 60 |      { | 
| 61 | 61 | // Get config file | 
| 62 | -        if (!static::$options) { | |
| 62 | +        if ( ! static::$options) { | |
| 63 | 63 | static::$options = include __DIR__.'/../config/underscore.php'; | 
| 64 | 64 | } | 
| 65 | 65 | |
| @@ -160,11 +160,11 @@ | ||
| 160 | 160 | public static function randomStrings(int $words, int $length = 10) : string | 
| 161 | 161 |      { | 
| 162 | 162 |          return Strings::from('0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ') | 
| 163 | - ->shuffle() | |
| 164 | - ->split($length) | |
| 165 | - ->slice(0, $words) | |
| 166 | -                      ->implode(' ') | |
| 167 | - ->obtain(); | |
| 163 | + ->shuffle() | |
| 164 | + ->split($length) | |
| 165 | + ->slice(0, $words) | |
| 166 | +                        ->implode(' ') | |
| 167 | + ->obtain(); | |
| 168 | 168 | } | 
| 169 | 169 | |
| 170 | 170 | //////////////////////////////////////////////////////////////////// | 
| @@ -170,10 +170,10 @@ discard block | ||
| 170 | 170 | * | 
| 171 | 171 | * | 
| 172 | 172 | */ | 
| 173 | - public static function endsWith(string $haystack, array|string $needles) : bool | |
| 173 | + public static function endsWith(string $haystack, array | string $needles) : bool | |
| 174 | 174 |      { | 
| 175 | -        foreach ((array) $needles as $needle) { | |
| 176 | -            if (str_ends_with($haystack, (string) $needle)) { | |
| 175 | +        foreach ((array)$needles as $needle) { | |
| 176 | +            if (str_ends_with($haystack, (string)$needle)) { | |
| 177 | 177 | return true; | 
| 178 | 178 | } | 
| 179 | 179 | } | 
| @@ -218,10 +218,10 @@ discard block | ||
| 218 | 218 | * | 
| 219 | 219 | * | 
| 220 | 220 | */ | 
| 221 | - public static function startsWith(string $haystack, array|string $needles) : bool | |
| 221 | + public static function startsWith(string $haystack, array | string $needles) : bool | |
| 222 | 222 |      { | 
| 223 | -        foreach ((array) $needles as $needle) { | |
| 224 | -            if ($needle !== '' && str_starts_with($haystack, (string) $needle)) { | |
| 223 | +        foreach ((array)$needles as $needle) { | |
| 224 | +            if ($needle !== '' && str_starts_with($haystack, (string)$needle)) { | |
| 225 | 225 | return true; | 
| 226 | 226 | } | 
| 227 | 227 | } | 
| @@ -244,8 +244,8 @@ discard block | ||
| 244 | 244 | * @return bool Found or not | 
| 245 | 245 | */ | 
| 246 | 246 | public static function find( | 
| 247 | - array|string $string, | |
| 248 | - array|string $needle, | |
| 247 | + array | string $string, | |
| 248 | + array | string $needle, | |
| 249 | 249 | bool $caseSensitive = false, | 
| 250 | 250 | bool $absolute = false | 
| 251 | 251 | ) : bool | 
| @@ -271,7 +271,7 @@ discard block | ||
| 271 | 271 | } | 
| 272 | 272 | |
| 273 | 273 | // If not case sensitive | 
| 274 | -        if (!$caseSensitive) { | |
| 274 | +        if ( ! $caseSensitive) { | |
| 275 | 275 | $string = strtolower($string); | 
| 276 | 276 | $needle = strtolower($needle); | 
| 277 | 277 | } | 
| @@ -304,11 +304,11 @@ discard block | ||
| 304 | 304 | * | 
| 305 | 305 | * @return false|string | 
| 306 | 306 | */ | 
| 307 | - public static function sliceFrom($string, $slice) : bool|string | |
| 307 | + public static function sliceFrom($string, $slice) : bool | string | |
| 308 | 308 |      { | 
| 309 | - $slice = strpos((string) $string, (string) $slice); | |
| 309 | + $slice = strpos((string)$string, (string)$slice); | |
| 310 | 310 | |
| 311 | - return substr((string) $string, $slice); | |
| 311 | + return substr((string)$string, $slice); | |
| 312 | 312 | } | 
| 313 | 313 | |
| 314 | 314 | /** | 
| @@ -319,11 +319,11 @@ discard block | ||
| 319 | 319 | * | 
| 320 | 320 | * @return false|string | 
| 321 | 321 | */ | 
| 322 | - public static function sliceTo($string, $slice) : bool|string | |
| 322 | + public static function sliceTo($string, $slice) : bool | string | |
| 323 | 323 |      { | 
| 324 | - $slice = strpos((string) $string, (string) $slice); | |
| 324 | + $slice = strpos((string)$string, (string)$slice); | |
| 325 | 325 | |
| 326 | - return substr((string) $string, 0, $slice); | |
| 326 | + return substr((string)$string, 0, $slice); | |
| 327 | 327 | } | 
| 328 | 328 | |
| 329 | 329 | /** | 
| @@ -388,7 +388,7 @@ discard block | ||
| 388 | 388 | public static function remove($string, $remove) : string | 
| 389 | 389 |      { | 
| 390 | 390 |          if (\is_array($remove)) { | 
| 391 | -            $string = preg_replace('#('.implode('|', $remove).')#', '', (string) $string); | |
| 391 | +            $string = preg_replace('#('.implode('|', $remove).')#', '', (string)$string); | |
| 392 | 392 | } | 
| 393 | 393 | |
| 394 | 394 | // Trim and return | 
| @@ -404,7 +404,7 @@ discard block | ||
| 404 | 404 | * | 
| 405 | 405 | * @return string|string[] | 
| 406 | 406 | */ | 
| 407 | - public static function replace($string, $replace, $with) : array|string | |
| 407 | + public static function replace($string, $replace, $with) : array | string | |
| 408 | 408 |      { | 
| 409 | 409 | return str_replace($replace, $with, $string); | 
| 410 | 410 | } | 
| @@ -445,12 +445,12 @@ discard block | ||
| 445 | 445 |          $title = preg_replace('!['.preg_quote($flip).']+!u', $separator, $title); | 
| 446 | 446 | |
| 447 | 447 | // Remove all characters that are not the separator, letters, numbers, or whitespace. | 
| 448 | -        $title = preg_replace('![^'.preg_quote($separator).'\pL\pN\s]+!u', '', mb_strtolower((string) $title)); | |
| 448 | +        $title = preg_replace('![^'.preg_quote($separator).'\pL\pN\s]+!u', '', mb_strtolower((string)$title)); | |
| 449 | 449 | |
| 450 | 450 | // Replace all separator characters and whitespace by a single separator | 
| 451 | -        $title = preg_replace('!['.preg_quote($separator).'\s]+!u', $separator, (string) $title); | |
| 451 | +        $title = preg_replace('!['.preg_quote($separator).'\s]+!u', $separator, (string)$title); | |
| 452 | 452 | |
| 453 | - return trim((string) $title, $separator); | |
| 453 | + return trim((string)$title, $separator); | |
| 454 | 454 | } | 
| 455 | 455 | |
| 456 | 456 | /** | 
| @@ -476,10 +476,10 @@ discard block | ||
| 476 | 476 | public static function explode($string, $with, $limit = null) : array | 
| 477 | 477 |      { | 
| 478 | 478 |          if ( ! $limit) { | 
| 479 | - return explode($with, (string) $string); | |
| 479 | + return explode($with, (string)$string); | |
| 480 | 480 | } | 
| 481 | 481 | |
| 482 | - return explode($with, (string) $string, $limit); | |
| 482 | + return explode($with, (string)$string, $limit); | |
| 483 | 483 | } | 
| 484 | 484 | |
| 485 | 485 | /** | 
| @@ -29,7 +29,7 @@ | ||
| 29 | 29 | */ | 
| 30 | 30 | public static function padding(mixed $number, int $padding = 1, int $direction = STR_PAD_BOTH) : string | 
| 31 | 31 |      { | 
| 32 | - return str_pad((string) $number, $padding, '0', $direction); | |
| 32 | + return str_pad((string)$number, $padding, '0', $direction); | |
| 33 | 33 | } | 
| 34 | 34 | |
| 35 | 35 | /** | 
| @@ -74,7 +74,7 @@ discard block | ||
| 74 | 74 | * | 
| 75 | 75 | * @return bool|string The correct function to call | 
| 76 | 76 | */ | 
| 77 | - public static function toNative(string $class, string $method) : bool|string | |
| 77 | + public static function toNative(string $class, string $method) : bool | string | |
| 78 | 78 |      { | 
| 79 | 79 | // Aliased native function | 
| 80 | 80 | $native = Method::getNative($method); | 
| @@ -94,7 +94,7 @@ discard block | ||
| 94 | 94 | } | 
| 95 | 95 | |
| 96 | 96 | // If no function prefix found, return false | 
| 97 | -        if (!isset($prefix)) { | |
| 97 | +        if ( ! isset($prefix)) { | |
| 98 | 98 | return false; | 
| 99 | 99 | } | 
| 100 | 100 | |
| @@ -145,7 +145,7 @@ | ||
| 145 | 145 | * | 
| 146 | 146 | * @return string|false The native function | 
| 147 | 147 | */ | 
| 148 | - public static function getNative(string $method) : bool|string | |
| 148 | + public static function getNative(string $method) : bool | string | |
| 149 | 149 |      { | 
| 150 | 150 | // If a defered method exist | 
| 151 | 151 |          if (\in_array($method, static::$defer, true)) { | 
| @@ -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 | } | 
| @@ -113,7 +113,7 @@ discard block | ||
| 113 | 113 | |
| 114 | 114 | // Convert objects to arrays | 
| 115 | 115 |          if (\is_object($data)) { | 
| 116 | - $data = (array) $data; | |
| 116 | + $data = (array)$data; | |
| 117 | 117 | } | 
| 118 | 118 | |
| 119 | 119 | // Don't convert if it's not an array | 
| @@ -137,7 +137,7 @@ discard block | ||
| 137 | 137 | |
| 138 | 138 | // Else add values | 
| 139 | 139 |              foreach ($row as $key => $value) { | 
| 140 | - $row[$key] = '"'.stripslashes((string) $value).'"'; | |
| 140 | + $row[$key] = '"'.stripslashes((string)$value).'"'; | |
| 141 | 141 | } | 
| 142 | 142 | |
| 143 | 143 | $csv[] = implode($delimiter, $row); | 
| @@ -161,7 +161,7 @@ discard block | ||
| 161 | 161 | $data = $data->toArray(); | 
| 162 | 162 | } | 
| 163 | 163 | |
| 164 | - return (array) $data; | |
| 164 | + return (array)$data; | |
| 165 | 165 | } | 
| 166 | 166 | |
| 167 | 167 | /** | 
| @@ -177,7 +177,7 @@ discard block | ||
| 177 | 177 | return static::toJSON($data); | 
| 178 | 178 | } | 
| 179 | 179 | |
| 180 | - return (string) $data; | |
| 180 | + return (string)$data; | |
| 181 | 181 | } | 
| 182 | 182 | |
| 183 | 183 | /** | 
| @@ -197,7 +197,7 @@ discard block | ||
| 197 | 197 | return \strlen($data); | 
| 198 | 198 | } | 
| 199 | 199 | |
| 200 | - return (int) $data; | |
| 200 | + return (int)$data; | |
| 201 | 201 | } | 
| 202 | 202 | |
| 203 | 203 | /** | 
| @@ -207,7 +207,7 @@ discard block | ||
| 207 | 207 | */ | 
| 208 | 208 | public static function toBoolean(mixed $data) : bool | 
| 209 | 209 |      { | 
| 210 | - return (bool) $data; | |
| 210 | + return (bool)$data; | |
| 211 | 211 | } | 
| 212 | 212 | |
| 213 | 213 | /** | 
| @@ -217,7 +217,7 @@ discard block | ||
| 217 | 217 | */ | 
| 218 | 218 | public static function toObject(mixed $data) : object | 
| 219 | 219 |      { | 
| 220 | - return (object) $data; | |
| 220 | + return (object)$data; | |
| 221 | 221 | } | 
| 222 | 222 | |
| 223 | 223 | //////////////////////////////////////////////////////////////////// | 
| @@ -66,7 +66,7 @@ discard block | ||
| 66 | 66 | * @param string $value | 
| 67 | 67 | * | 
| 68 | 68 | */ | 
| 69 | - public static function search(array $array, mixed $value) : int|string|bool | |
| 69 | + public static function search(array $array, mixed $value) : int | string | bool | |
| 70 | 70 |      { | 
| 71 | 71 | return array_search($value, $array, true); | 
| 72 | 72 | } | 
| @@ -199,7 +199,7 @@ discard block | ||
| 199 | 199 | */ | 
| 200 | 200 | public static function clean(array $array) : mixed | 
| 201 | 201 |      { | 
| 202 | - return static::filter($array, fn($value) : bool => (bool) $value); | |
| 202 | + return static::filter($array, fn($value) : bool => (bool)$value); | |
| 203 | 203 | } | 
| 204 | 204 | |
| 205 | 205 | /** | 
| @@ -224,7 +224,7 @@ discard block | ||
| 224 | 224 | */ | 
| 225 | 225 | public static function without(...$arguments): mixed | 
| 226 | 226 |      { | 
| 227 | - $array = array_shift($arguments); | |
| 227 | + $array = array_shift($arguments); | |
| 228 | 228 | // if singular argument and is an array treat this AS the array to run without agains | 
| 229 | 229 |          if (\is_array($arguments[0]) && \count($arguments) === 1) { | 
| 230 | 230 | $arguments = $arguments[0]; | 
| @@ -332,7 +332,7 @@ discard block | ||
| 332 | 332 | */ | 
| 333 | 333 | public static function replaceValue(array $array, string $replace, string $with) : array | 
| 334 | 334 |      { | 
| 335 | - return static::each($array, fn($value) : string|array => str_replace($replace, $with, (string) $value)); | |
| 335 | + return static::each($array, fn($value) : string | array => str_replace($replace, $with, (string)$value)); | |
| 336 | 336 | } | 
| 337 | 337 | |
| 338 | 338 | /** | 
| @@ -458,7 +458,7 @@ discard block | ||
| 458 | 458 | * @param array $arguments | 
| 459 | 459 | * | 
| 460 | 460 | */ | 
| 461 | - public static function invoke(array $array, Closure|string $callable, mixed $arguments = []) : array | |
| 461 | + public static function invoke(array $array, Closure | string $callable, mixed $arguments = []) : array | |
| 462 | 462 |      { | 
| 463 | 463 | // If one argument given for each iteration, create an array for it | 
| 464 | 464 |          if ( ! \is_array($arguments)) { | 
| @@ -564,7 +564,7 @@ discard block | ||
| 564 | 564 | */ | 
| 565 | 565 | public static function unique(array $array) : array | 
| 566 | 566 |      { | 
| 567 | -        return array_reduce($array, function (array $resultArray, $value) : array { | |
| 567 | +        return array_reduce($array, function(array $resultArray, $value) : array { | |
| 568 | 568 |              if ( ! static::contains($resultArray, $value)) { | 
| 569 | 569 | $resultArray[] = $value; | 
| 570 | 570 | } | 
| @@ -66,9 +66,9 @@ discard block | ||
| 66 | 66 | $unique = random_int(0, mt_getrandmax()); | 
| 67 | 67 | |
| 68 | 68 | // Create a closure that check if the function was already called | 
| 69 | -        return function (...$arguments) use ($function, $canBeCalledTimes, $unique) { | |
| 69 | +        return function(...$arguments) use ($function, $canBeCalledTimes, $unique) { | |
| 70 | 70 | |
| 71 | - $signature = FunctionsMethods::getSignature((string) $unique, $function, $arguments); | |
| 71 | + $signature = FunctionsMethods::getSignature((string)$unique, $function, $arguments); | |
| 72 | 72 | |
| 73 | 73 | // Get counter | 
| 74 | 74 | $numberOfTimesCalled = FunctionsMethods::hasBeenCalledTimes($signature); | 
| @@ -77,9 +77,7 @@ discard block | ||
| 77 | 77 | // Else, increment the count | 
| 78 | 78 |              if ($numberOfTimesCalled >= $canBeCalledTimes) { | 
| 79 | 79 | return false; | 
| 80 | - } | |
| 81 | - | |
| 82 | - ++FunctionsMethods::$canBeCalledTimes[$signature]; | |
| 80 | + }++FunctionsMethods::$canBeCalledTimes[$signature]; | |
| 83 | 81 | |
| 84 | 82 | return \call_user_func_array($function, $arguments); | 
| 85 | 83 | }; | 
| @@ -97,16 +95,15 @@ discard block | ||
| 97 | 95 | $unique = random_int(0, mt_getrandmax()); | 
| 98 | 96 | |
| 99 | 97 | // Create a closure that check if the function was already called | 
| 100 | -        return function (...$arguments) use ($function, $times, $unique) { | |
| 98 | +        return function(...$arguments) use ($function, $times, $unique) { | |
| 101 | 99 | |
| 102 | - $signature = FunctionsMethods::getSignature((string) $unique, $function, $arguments); | |
| 100 | + $signature = FunctionsMethods::getSignature((string)$unique, $function, $arguments); | |
| 103 | 101 | |
| 104 | 102 | // Get counter | 
| 105 | 103 | $called = FunctionsMethods::hasBeenCalledTimes($signature); | 
| 106 | 104 | |
| 107 | 105 | // Prevent calling before a certain number | 
| 108 | -            if ($called < $times) { | |
| 109 | - ++FunctionsMethods::$canBeCalledTimes[$signature]; | |
| 106 | +            if ($called < $times) {++FunctionsMethods::$canBeCalledTimes[$signature]; | |
| 110 | 107 | |
| 111 | 108 | return false; | 
| 112 | 109 | } | 
| @@ -126,9 +123,9 @@ discard block | ||
| 126 | 123 |      { | 
| 127 | 124 | $unique = random_int(0, mt_getrandmax()); | 
| 128 | 125 | |
| 129 | -        return function (...$arguments) use ($function, $unique) { | |
| 126 | +        return function(...$arguments) use ($function, $unique) { | |
| 130 | 127 | |
| 131 | - $signature = FunctionsMethods::getSignature((string) $unique, $function, $arguments); | |
| 128 | + $signature = FunctionsMethods::getSignature((string)$unique, $function, $arguments); | |
| 132 | 129 | |
| 133 | 130 |              if (isset(FunctionsMethods::$cached[$signature])) { | 
| 134 | 131 | return FunctionsMethods::$cached[$signature]; | 
| @@ -152,9 +149,9 @@ discard block | ||
| 152 | 149 |      { | 
| 153 | 150 | $unique = random_int(0, mt_getrandmax()); | 
| 154 | 151 | |
| 155 | -        return function (...$arguments) use ($function, $ms, $unique) { | |
| 152 | +        return function(...$arguments) use ($function, $ms, $unique) { | |
| 156 | 153 | |
| 157 | - $signature = FunctionsMethods::getSignature((string) $unique, $function, $arguments); | |
| 154 | + $signature = FunctionsMethods::getSignature((string)$unique, $function, $arguments); | |
| 158 | 155 | |
| 159 | 156 | // Check last called time and update it if necessary | 
| 160 | 157 | $last = FunctionsMethods::getLastCalledTime($signature); | 
| @@ -227,7 +224,7 @@ discard block | ||
| 227 | 224 | */ | 
| 228 | 225 | public static function getSignature(string $unique, Closure $function, array $arguments) : string | 
| 229 | 226 |      { | 
| 230 | - $function = var_export($function, true); | |
| 227 | + $function = var_export($function, true); | |
| 231 | 228 | $argumentsStr = var_export($arguments, true); | 
| 232 | 229 | |
| 233 | 230 | return md5($unique.'_'.$function.'_'.$argumentsStr); |