@@ -74,7 +74,7 @@ |
||
74 | 74 | return self::$classLoader; |
75 | 75 | } |
76 | 76 | |
77 | - $autoloadFunctions = (array)spl_autoload_functions(); |
|
77 | + $autoloadFunctions = (array) spl_autoload_functions(); |
|
78 | 78 | foreach ($autoloadFunctions as $loader) { |
79 | 79 | if (is_array($loader) && isset($loader[0])) { |
80 | 80 | $composerLoader = $loader[0]; |
@@ -53,8 +53,7 @@ |
||
53 | 53 | * Class Composer |
54 | 54 | * @package Platine\Stdlib\Helper |
55 | 55 | */ |
56 | -class Composer |
|
57 | -{ |
|
56 | +class Composer { |
|
58 | 57 | /** |
59 | 58 | * The composer class loader instance |
60 | 59 | * @var ClassLoader|null |
@@ -67,7 +67,7 @@ |
||
67 | 67 | if (array_key_exists('unit', $matches)) { |
68 | 68 | $unit = strtoupper($matches['unit']); |
69 | 69 | } |
70 | - return (int)(floatval($matches['size']) * pow(1024, $units[$unit])); |
|
70 | + return (int) (floatval($matches['size']) * pow(1024, $units[$unit])); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | /** |
@@ -50,8 +50,7 @@ |
||
50 | 50 | * Class Unit |
51 | 51 | * @package Platine\Stdlib\Helper |
52 | 52 | */ |
53 | -class Unit |
|
54 | -{ |
|
53 | +class Unit { |
|
55 | 54 | /** |
56 | 55 | * Convert the size like 4G, 7T, 19B to byte |
57 | 56 | * @param string $size |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | $result = $object->toArray(); |
108 | 108 | } else { |
109 | 109 | $result = []; |
110 | - foreach ((array)$object as $key => $value) { |
|
110 | + foreach ((array) $object as $key => $value) { |
|
111 | 111 | $result[$key] = $value; |
112 | 112 | } |
113 | 113 | } |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | */ |
128 | 128 | public static function merge(array ...$args): array |
129 | 129 | { |
130 | - $res = (array)array_shift($args); |
|
130 | + $res = (array) array_shift($args); |
|
131 | 131 | while (!empty($args)) { |
132 | 132 | $next = array_shift($args); |
133 | 133 | foreach ($next as $key => $value) { |
@@ -469,7 +469,7 @@ discard block |
||
469 | 469 | return; |
470 | 470 | } |
471 | 471 | |
472 | - $count = count($keys); |
|
472 | + $count = count($keys); |
|
473 | 473 | if (is_scalar($direction)) { |
474 | 474 | $direction = array_fill(0, $count, $direction); |
475 | 475 | } elseif (count($direction) !== $count) { |
@@ -936,7 +936,7 @@ discard block |
||
936 | 936 | $max = 0; |
937 | 937 | foreach ($array as $key => $value) { |
938 | 938 | if (!$expectInt || !is_numeric($key)) { |
939 | - $width = mb_strlen((string)$key, 'UTF-8'); |
|
939 | + $width = mb_strlen((string) $key, 'UTF-8'); |
|
940 | 940 | if ($width > $max) { |
941 | 941 | $max = $width; |
942 | 942 | } |
@@ -1057,7 +1057,7 @@ discard block |
||
1057 | 1057 | } else { |
1058 | 1058 | $itemKey = static::get($item, $key); |
1059 | 1059 | if (is_object($itemKey) && method_exists($itemKey, '__toString')) { |
1060 | - $itemKey = (string)$itemKey; |
|
1060 | + $itemKey = (string) $itemKey; |
|
1061 | 1061 | } |
1062 | 1062 | |
1063 | 1063 | $results[$itemKey] = $itemValue; |
@@ -1161,7 +1161,7 @@ discard block |
||
1161 | 1161 | $keys = array_rand($array, $number); |
1162 | 1162 | |
1163 | 1163 | $results = []; |
1164 | - foreach ((array)$keys as $key) { |
|
1164 | + foreach ((array) $keys as $key) { |
|
1165 | 1165 | $results[] = $array[$key]; |
1166 | 1166 | } |
1167 | 1167 | |
@@ -1211,18 +1211,18 @@ discard block |
||
1211 | 1211 | if (preg_match('/^\-\w=/', $arg)) { |
1212 | 1212 | $normalized = array_merge( |
1213 | 1213 | $normalized, |
1214 | - (array)explode('=', $arg) |
|
1214 | + (array) explode('=', $arg) |
|
1215 | 1215 | ); |
1216 | 1216 | } elseif (preg_match('/^\-\w{2,}/', $arg)) { |
1217 | 1217 | $splitArgs = implode(' -', str_split(ltrim($arg, '-'))); |
1218 | 1218 | $normalized = array_merge( |
1219 | 1219 | $normalized, |
1220 | - (array)explode(' ', '-' . $splitArgs) |
|
1220 | + (array) explode(' ', '-' . $splitArgs) |
|
1221 | 1221 | ); |
1222 | 1222 | } elseif (preg_match('/^\-\-([^\s\=]+)\=/', $arg)) { |
1223 | 1223 | $normalized = array_merge( |
1224 | 1224 | $normalized, |
1225 | - (array)explode('=', $arg) |
|
1225 | + (array) explode('=', $arg) |
|
1226 | 1226 | ); |
1227 | 1227 | } else { |
1228 | 1228 | $normalized[] = $arg; |
@@ -57,8 +57,7 @@ discard block |
||
57 | 57 | * Class Arr |
58 | 58 | * @package Platine\Stdlib\Helper |
59 | 59 | */ |
60 | -class Arr |
|
61 | -{ |
|
60 | +class Arr { |
|
62 | 61 | /** |
63 | 62 | * Convert an array, object or string to array |
64 | 63 | * @param array<mixed>|object|string $object |
@@ -158,8 +157,7 @@ discard block |
||
158 | 157 | * @return mixed If the key does not exist in the array or object, |
159 | 158 | * the default value will be returned instead. |
160 | 159 | */ |
161 | - public static function getValue($object, $key, $default = null) |
|
162 | - { |
|
160 | + public static function getValue($object, $key, $default = null) { |
|
163 | 161 | if ($key instanceof Closure) { |
164 | 162 | return $key($object, $default); |
165 | 163 | } |
@@ -219,8 +217,7 @@ discard block |
||
219 | 217 | * |
220 | 218 | * @return mixed|null |
221 | 219 | */ |
222 | - public static function remove(array &$array, $key, $default = null) |
|
223 | - { |
|
220 | + public static function remove(array &$array, $key, $default = null) { |
|
224 | 221 | if (isset($array[$key]) || array_key_exists($key, $array)) { |
225 | 222 | $value = $array[$key]; |
226 | 223 | |
@@ -295,8 +292,7 @@ discard block |
||
295 | 292 | * @param mixed $default |
296 | 293 | * @return mixed |
297 | 294 | */ |
298 | - public static function pull(array &$array, $key, $default = null) |
|
299 | - { |
|
295 | + public static function pull(array &$array, $key, $default = null) { |
|
300 | 296 | $value = static::get($array, $key, $default); |
301 | 297 | |
302 | 298 | static::forget($array, $key); |
@@ -755,8 +751,7 @@ discard block |
||
755 | 751 | * @param mixed $default |
756 | 752 | * @return mixed |
757 | 753 | */ |
758 | - public static function get($array, $key = null, $default = null) |
|
759 | - { |
|
754 | + public static function get($array, $key = null, $default = null) { |
|
760 | 755 | if ($key === null) { |
761 | 756 | return $array; |
762 | 757 | } |
@@ -1136,8 +1131,7 @@ discard block |
||
1136 | 1131 | * |
1137 | 1132 | * @return mixed |
1138 | 1133 | */ |
1139 | - public static function random(array $array, ?int $number = null) |
|
1140 | - { |
|
1134 | + public static function random(array $array, ?int $number = null) { |
|
1141 | 1135 | $requested = $number === null ? 1 : $number; |
1142 | 1136 | $count = count($array); |
1143 | 1137 |
@@ -56,8 +56,7 @@ discard block |
||
56 | 56 | * Class AbstractConfiguration |
57 | 57 | * @package Platine\Stdlib\Config |
58 | 58 | */ |
59 | -abstract class AbstractConfiguration implements ConfigurationInterface |
|
60 | -{ |
|
59 | +abstract class AbstractConfiguration implements ConfigurationInterface { |
|
61 | 60 | /** |
62 | 61 | * The raw configuration array |
63 | 62 | * @var array<string, mixed> |
@@ -67,8 +66,7 @@ discard block |
||
67 | 66 | /** |
68 | 67 | * {@inheritedoc} |
69 | 68 | */ |
70 | - public function __construct(array $config = []) |
|
71 | - { |
|
69 | + public function __construct(array $config = []) { |
|
72 | 70 | $configuration = array_merge($this->getDefault(), $config); |
73 | 71 | $this->load($configuration); |
74 | 72 | } |
@@ -76,8 +74,7 @@ discard block |
||
76 | 74 | /** |
77 | 75 | * {@inheritedoc} |
78 | 76 | */ |
79 | - public function get(string $name) |
|
80 | - { |
|
77 | + public function get(string $name) { |
|
81 | 78 | if (!$this->has($name)) { |
82 | 79 | throw new InvalidArgumentException(sprintf( |
83 | 80 | 'Configuration [%s] does not exist', |
@@ -52,8 +52,7 @@ |
||
52 | 52 | * Class Path |
53 | 53 | * @package Platine\Stdlib\Helper |
54 | 54 | */ |
55 | -class Path |
|
56 | -{ |
|
55 | +class Path { |
|
57 | 56 | /** |
58 | 57 | * normalize the path by replace the "\" to "/" |
59 | 58 | * @param string $path |
@@ -56,8 +56,7 @@ |
||
56 | 56 | * Class Str |
57 | 57 | * @package Platine\Stdlib\Helper |
58 | 58 | */ |
59 | -class Str |
|
60 | -{ |
|
59 | +class Str { |
|
61 | 60 | /** |
62 | 61 | * The cache of snake-cased words. |
63 | 62 | * |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | $value = str_replace($val, $key, $value); |
91 | 91 | } |
92 | 92 | |
93 | - return (string)preg_replace('/[^\x20-\x7E]/u', '', $value); |
|
93 | + return (string) preg_replace('/[^\x20-\x7E]/u', '', $value); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | /** |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | // pattern such as "library/*", making any string check convenient. |
258 | 258 | $cleanQuoted = str_replace('\*', '.*', $quoted); |
259 | 259 | |
260 | - return (bool)preg_match('#^' . $cleanQuoted . '\z#', $value); |
|
260 | + return (bool) preg_match('#^' . $cleanQuoted . '\z#', $value); |
|
261 | 261 | } |
262 | 262 | |
263 | 263 | /** |
@@ -569,7 +569,7 @@ discard block |
||
569 | 569 | */ |
570 | 570 | public static function isAscii(string $value): bool |
571 | 571 | { |
572 | - return (bool)!preg_match('/[^\x00-\x7F]/S', $value); |
|
572 | + return (bool) !preg_match('/[^\x00-\x7F]/S', $value); |
|
573 | 573 | } |
574 | 574 | |
575 | 575 | /** |
@@ -602,7 +602,7 @@ discard block |
||
602 | 602 | { |
603 | 603 | $bytes = random_bytes((int) ceil($length / 2)); |
604 | 604 | |
605 | - return (string)substr(bin2hex($bytes), 0, $length); |
|
605 | + return (string) substr(bin2hex($bytes), 0, $length); |
|
606 | 606 | } |
607 | 607 | |
608 | 608 | /** |
@@ -617,7 +617,7 @@ discard block |
||
617 | 617 | } |
618 | 618 | |
619 | 619 | // handle boolean, array, & html special chars |
620 | - array_walk($attributes, function (&$value, $key) { |
|
620 | + array_walk($attributes, function(&$value, $key) { |
|
621 | 621 | $value = is_bool($value) ? $value ? 'true' : 'false' : $value; |
622 | 622 | $value = is_array($value) ? implode(' ', $value) : $value; |
623 | 623 | $value = trim($value); |
@@ -625,7 +625,7 @@ discard block |
||
625 | 625 | }); |
626 | 626 | |
627 | 627 | // remove empty elements |
628 | - $emptyAttributes = array_filter($attributes, function ($value) { |
|
628 | + $emptyAttributes = array_filter($attributes, function($value) { |
|
629 | 629 | return strlen($value) > 0; |
630 | 630 | }); |
631 | 631 | |
@@ -700,7 +700,7 @@ discard block |
||
700 | 700 | $pool = '2345679ACDEFHJKLMNPRSTUVWXYZ'; |
701 | 701 | break; |
702 | 702 | default: |
703 | - $pool = (string)$type; |
|
703 | + $pool = (string) $type; |
|
704 | 704 | $utf8 = !self::isAscii($pool); |
705 | 705 | break; |
706 | 706 | } |
@@ -804,7 +804,7 @@ discard block |
||
804 | 804 | $ignoreKeys = $firstKey === 0; |
805 | 805 | |
806 | 806 | return sprintf('[%s]', implode(', ', array_map( |
807 | - function ($key, $value) use ($ignoreKeys) { |
|
807 | + function($key, $value) use ($ignoreKeys) { |
|
808 | 808 | return $ignoreKeys |
809 | 809 | ? self::stringify($value) |
810 | 810 | : sprintf( |
@@ -52,8 +52,7 @@ discard block |
||
52 | 52 | * Class Php |
53 | 53 | * @package Platine\Stdlib\Helper |
54 | 54 | */ |
55 | -class Php |
|
56 | -{ |
|
55 | +class Php { |
|
57 | 56 | /** |
58 | 57 | * Call by callback |
59 | 58 | * @param callable|array<mixed> $callback |
@@ -61,13 +60,13 @@ discard block |
||
61 | 60 | * |
62 | 61 | * @return mixed |
63 | 62 | */ |
64 | - public static function call($callback, ...$args) |
|
65 | - { |
|
63 | + public static function call($callback, ...$args) { |
|
66 | 64 | if (is_string($callback)) { |
67 | 65 | // className::method |
68 | 66 | if (strpos($callback, '::') > 0) { |
69 | 67 | $callback = explode('::', $callback, 2); |
70 | - } elseif (function_exists($callback)) { //function |
|
68 | + } elseif (function_exists($callback)) { |
|
69 | +//function |
|
71 | 70 | return $callback(...$args); |
72 | 71 | } |
73 | 72 | } elseif (is_object($callback) && method_exists($callback, '__invoke')) { |
@@ -95,8 +94,7 @@ discard block |
||
95 | 94 | * |
96 | 95 | * @return mixed |
97 | 96 | */ |
98 | - public static function callArray($callback, array $args) |
|
99 | - { |
|
97 | + public static function callArray($callback, array $args) { |
|
100 | 98 | return self::call($callback, ...$args); |
101 | 99 | } |
102 | 100 |
@@ -50,8 +50,7 @@ |
||
50 | 50 | * Class Xml |
51 | 51 | * @package Platine\Stdlib\Helper |
52 | 52 | */ |
53 | -class Xml |
|
54 | -{ |
|
53 | +class Xml { |
|
55 | 54 | /** |
56 | 55 | * Transform an XML string to array |
57 | 56 | * @param string $xml |
@@ -50,8 +50,7 @@ |
||
50 | 50 | * Class Env |
51 | 51 | * @package Platine\Stdlib\Helper |
52 | 52 | */ |
53 | -class Env |
|
54 | -{ |
|
53 | +class Env { |
|
55 | 54 | /** |
56 | 55 | * Whether the application is running on CLI |
57 | 56 | * @return bool |