@@ -50,8 +50,7 @@ |
||
50 | 50 | * @class ConfigurationInterface |
51 | 51 | * @package Platine\Stdlib\Contract |
52 | 52 | */ |
53 | -interface ConfigurationInterface |
|
54 | -{ |
|
53 | +interface ConfigurationInterface { |
|
55 | 54 | /** |
56 | 55 | * Create new instance |
57 | 56 | * @param array<string, mixed> $config |
@@ -50,8 +50,7 @@ |
||
50 | 50 | * @class Jsonable |
51 | 51 | * @package Platine\Stdlib\Contract |
52 | 52 | */ |
53 | -interface Jsonable |
|
54 | -{ |
|
53 | +interface Jsonable { |
|
55 | 54 | /** |
56 | 55 | * Convert the instance to JSON string |
57 | 56 | * @param int $options |
@@ -50,8 +50,7 @@ |
||
50 | 50 | * @class Arrayable |
51 | 51 | * @package Platine\Stdlib\Contract |
52 | 52 | */ |
53 | -interface Arrayable |
|
54 | -{ |
|
53 | +interface Arrayable { |
|
55 | 54 | /** |
56 | 55 | * Convert the instance to array |
57 | 56 | * @return array<mixed> |
@@ -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 | } |
@@ -94,18 +94,18 @@ |
||
94 | 94 | return (string)preg_replace('/[^\x20-\x7E]/u', '', $value); |
95 | 95 | } |
96 | 96 | |
97 | - /** |
|
98 | - * This function is used to hidden some part of the given string. Helpful |
|
99 | - * if you need hide some confidential information |
|
100 | - * like credit card number, password, etc. |
|
101 | - * |
|
102 | - * @param string $str the string you want to hide some part |
|
103 | - * @param int $startCount the length of non hidden for the beginning char |
|
104 | - * @param int $endCount the length of non hidden for the ending char |
|
105 | - * @param string $hiddenChar the char used to hide the given string |
|
106 | - * |
|
107 | - * @return string |
|
108 | - */ |
|
97 | + /** |
|
98 | + * This function is used to hidden some part of the given string. Helpful |
|
99 | + * if you need hide some confidential information |
|
100 | + * like credit card number, password, etc. |
|
101 | + * |
|
102 | + * @param string $str the string you want to hide some part |
|
103 | + * @param int $startCount the length of non hidden for the beginning char |
|
104 | + * @param int $endCount the length of non hidden for the ending char |
|
105 | + * @param string $hiddenChar the char used to hide the given string |
|
106 | + * |
|
107 | + * @return string |
|
108 | + */ |
|
109 | 109 | public static function hidden( |
110 | 110 | string $str, |
111 | 111 | int $startCount = 0, |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | $value = str_replace($val, (string) $key, $value); |
92 | 92 | } |
93 | 93 | |
94 | - return (string)preg_replace('/[^\x20-\x7E]/u', '', $value); |
|
94 | + return (string) preg_replace('/[^\x20-\x7E]/u', '', $value); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | * @param string|array<mixed> $needles |
208 | 208 | * @return bool |
209 | 209 | */ |
210 | - public static function contains(string $value, string|array $needles): bool |
|
210 | + public static function contains(string $value, string | array $needles): bool |
|
211 | 211 | { |
212 | 212 | if (!is_array($needles)) { |
213 | 213 | $needles = [$needles]; |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | * @param string|array<mixed> $needles |
229 | 229 | * @return bool |
230 | 230 | */ |
231 | - public static function endsWith(string $value, string|array $needles): bool |
|
231 | + public static function endsWith(string $value, string | array $needles): bool |
|
232 | 232 | { |
233 | 233 | if (!is_array($needles)) { |
234 | 234 | $needles = [$needles]; |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | * @param string|array<mixed> $needles |
250 | 250 | * @return bool |
251 | 251 | */ |
252 | - public static function startsWith(string $value, string|array $needles): bool |
|
252 | + public static function startsWith(string $value, string | array $needles): bool |
|
253 | 253 | { |
254 | 254 | if (!is_array($needles)) { |
255 | 255 | $needles = [$needles]; |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | // pattern such as "library/*", making any string check convenient. |
320 | 320 | $cleanQuoted = str_replace('\*', '.*', $quoted); |
321 | 321 | |
322 | - return (bool)preg_match('#^' . $cleanQuoted . '\z#', $value); |
|
322 | + return (bool) preg_match('#^' . $cleanQuoted . '\z#', $value); |
|
323 | 323 | } |
324 | 324 | |
325 | 325 | /** |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | * @param string $encode |
329 | 329 | * @return int |
330 | 330 | */ |
331 | - public static function length(string|int $value, string $encode = 'UTF-8'): int |
|
331 | + public static function length(string | int $value, string $encode = 'UTF-8'): int |
|
332 | 332 | { |
333 | 333 | if (!is_string($value)) { |
334 | 334 | $value = (string) $value; |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | * @return string |
350 | 350 | */ |
351 | 351 | public static function pad( |
352 | - string|int $value, |
|
352 | + string | int $value, |
|
353 | 353 | int $length, |
354 | 354 | string $padStr = ' ', |
355 | 355 | int $type = STR_PAD_BOTH |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | * @return string |
372 | 372 | */ |
373 | 373 | public static function padLeft( |
374 | - string|int $value, |
|
374 | + string | int $value, |
|
375 | 375 | int $length, |
376 | 376 | string $padStr = ' ' |
377 | 377 | ): string { |
@@ -386,7 +386,7 @@ discard block |
||
386 | 386 | * @return string |
387 | 387 | */ |
388 | 388 | public static function padRight( |
389 | - string|int $value, |
|
389 | + string | int $value, |
|
390 | 390 | int $length, |
391 | 391 | string $padStr = ' ' |
392 | 392 | ): string { |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | * @param int $length |
400 | 400 | * @return string |
401 | 401 | */ |
402 | - public static function repeat(string|int $value, int $length = 1): string |
|
402 | + public static function repeat(string | int $value, int $length = 1): string |
|
403 | 403 | { |
404 | 404 | if (!is_string($value)) { |
405 | 405 | $value = (string) $value; |
@@ -631,7 +631,7 @@ discard block |
||
631 | 631 | */ |
632 | 632 | public static function isAscii(string $value): bool |
633 | 633 | { |
634 | - return (bool)!preg_match('/[^\x00-\x7F]/S', $value); |
|
634 | + return (bool) !preg_match('/[^\x00-\x7F]/S', $value); |
|
635 | 635 | } |
636 | 636 | |
637 | 637 | /** |
@@ -664,7 +664,7 @@ discard block |
||
664 | 664 | { |
665 | 665 | $bytes = random_bytes((int) ceil($length / 2)); |
666 | 666 | |
667 | - return (string)substr(bin2hex($bytes), 0, $length); |
|
667 | + return (string) substr(bin2hex($bytes), 0, $length); |
|
668 | 668 | } |
669 | 669 | |
670 | 670 | /** |
@@ -679,7 +679,7 @@ discard block |
||
679 | 679 | } |
680 | 680 | |
681 | 681 | // handle boolean, array, & html special chars |
682 | - array_walk($attributes, function (&$value, $key) { |
|
682 | + array_walk($attributes, function(&$value, $key) { |
|
683 | 683 | $value = is_bool($value) ? $value ? 'true' : 'false' : $value; |
684 | 684 | $value = is_array($value) ? implode(' ', $value) : $value; |
685 | 685 | $value = trim($value); |
@@ -687,7 +687,7 @@ discard block |
||
687 | 687 | }); |
688 | 688 | |
689 | 689 | // remove empty elements |
690 | - $emptyAttributes = array_filter($attributes, function ($value) { |
|
690 | + $emptyAttributes = array_filter($attributes, function($value) { |
|
691 | 691 | return strlen($value) > 0; |
692 | 692 | }); |
693 | 693 | |
@@ -762,7 +762,7 @@ discard block |
||
762 | 762 | $pool = '2345679ACDEFHJKLMNPRSTUVWXYZ'; |
763 | 763 | break; |
764 | 764 | default: |
765 | - $pool = (string)$type; |
|
765 | + $pool = (string) $type; |
|
766 | 766 | $utf8 = !self::isAscii($pool); |
767 | 767 | break; |
768 | 768 | } |
@@ -866,7 +866,7 @@ discard block |
||
866 | 866 | $ignoreKeys = $firstKey === 0; |
867 | 867 | |
868 | 868 | return sprintf('[%s]', implode(', ', array_map( |
869 | - function ($key, $value) use ($ignoreKeys) { |
|
869 | + function($key, $value) use ($ignoreKeys) { |
|
870 | 870 | return $ignoreKeys |
871 | 871 | ? self::stringify($value) |
872 | 872 | : sprintf( |
@@ -57,8 +57,7 @@ |
||
57 | 57 | * @class Str |
58 | 58 | * @package Platine\Stdlib\Helper |
59 | 59 | */ |
60 | -class Str |
|
61 | -{ |
|
60 | +class Str { |
|
62 | 61 | /** |
63 | 62 | * The cache of snake-cased words. |
64 | 63 | * |
@@ -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 |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | * |
62 | 62 | * @return mixed |
63 | 63 | */ |
64 | - public static function call(callable|array $callback, mixed ...$args): mixed |
|
64 | + public static function call(callable | array $callback, mixed ...$args): mixed |
|
65 | 65 | { |
66 | 66 | if (is_string($callback)) { |
67 | 67 | // className::method |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | * |
96 | 96 | * @return mixed |
97 | 97 | */ |
98 | - public static function callArray(callable|array $callback, array $args): mixed |
|
98 | + public static function callArray(callable | array $callback, array $args): mixed |
|
99 | 99 | { |
100 | 100 | return self::call($callback, ...$args); |
101 | 101 | } |
@@ -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 |
@@ -67,7 +66,8 @@ discard block |
||
67 | 66 | // className::method |
68 | 67 | if (strpos($callback, '::') > 0) { |
69 | 68 | $callback = explode('::', $callback, 2); |
70 | - } elseif (function_exists($callback)) { //function |
|
69 | + } elseif (function_exists($callback)) { |
|
70 | +//function |
|
71 | 71 | return $callback(...$args); |
72 | 72 | } |
73 | 73 | } elseif (is_object($callback) && method_exists($callback, '__invoke')) { |
@@ -71,7 +71,7 @@ |
||
71 | 71 | if (array_key_exists('size', $matches)) { |
72 | 72 | $value = floatval(strtoupper($matches['size'])); |
73 | 73 | } |
74 | - return (int)($value * pow(1024, $units[$unit])); |
|
74 | + return (int) ($value * pow(1024, $units[$unit])); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | /** |
@@ -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 |
@@ -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 |