mirror of
https://github.com/pestphp/pest.git
synced 2026-03-07 00:07:22 +01:00
Migrates to Pint
This commit is contained in:
@ -12,7 +12,7 @@ final class Arr
|
||||
/**
|
||||
* Checks if the given array has the given key.
|
||||
*
|
||||
* @param array<array-key, mixed> $array
|
||||
* @param array<array-key, mixed> $array
|
||||
*/
|
||||
public static function has(array $array, string|int $key): bool
|
||||
{
|
||||
@ -36,7 +36,7 @@ final class Arr
|
||||
/**
|
||||
* Gets the given key value.
|
||||
*
|
||||
* @param array<array-key, mixed> $array
|
||||
* @param array<array-key, mixed> $array
|
||||
*/
|
||||
public static function get(array $array, string|int $key, mixed $default = null): mixed
|
||||
{
|
||||
@ -46,7 +46,7 @@ final class Arr
|
||||
return $array[$key];
|
||||
}
|
||||
|
||||
if (!str_contains($key, '.')) {
|
||||
if (! str_contains($key, '.')) {
|
||||
return $array[$key] ?? $default;
|
||||
}
|
||||
|
||||
@ -64,8 +64,7 @@ final class Arr
|
||||
/**
|
||||
* Flatten a multi-dimensional associative array with dots.
|
||||
*
|
||||
* @param array<array-key, mixed> $array
|
||||
*
|
||||
* @param array<array-key, mixed> $array
|
||||
* @return array<int|string, mixed>
|
||||
*/
|
||||
public static function dot(array $array, string $prepend = ''): array
|
||||
@ -74,9 +73,9 @@ final class Arr
|
||||
|
||||
foreach ($array as $key => $value) {
|
||||
if (is_array($value) && count($value) > 0) {
|
||||
$results = array_merge($results, static::dot($value, $prepend . $key . '.'));
|
||||
$results = array_merge($results, static::dot($value, $prepend.$key.'.'));
|
||||
} else {
|
||||
$results[$prepend . $value] = $value;
|
||||
$results[$prepend.$value] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user