Skip to content

Commit ae11606

Browse files
Merge pull request #2 from Laravel-Lang/1.x
Added get an associative array of [case value => case value]
2 parents 7684714 + f4c4bfa commit ae11606

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/Locale.php

+11
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use ArchTech\Enums\Names;
99
use ArchTech\Enums\Options;
1010
use ArchTech\Enums\Values;
11+
use BackedEnum;
1112

1213
enum Locale: string
1314
{
@@ -95,4 +96,14 @@ enum Locale: string
9596
case UzbekLatin = 'uz_Latn';
9697
case Vietnamese = 'vi';
9798
case Welsh = 'cy';
99+
100+
/** Get an associative array of [case value => case value]. */
101+
public static function onlyValues(): array
102+
{
103+
$cases = self::cases();
104+
105+
return isset($cases[0]) && $cases[0] instanceof BackedEnum
106+
? array_column($cases, 'value', 'value')
107+
: array_column($cases, 'value');
108+
}
98109
}

0 commit comments

Comments
 (0)