1
0
Fork 0
mirror of https://github.com/archtechx/enums.git synced 2025-12-12 22:14:04 +00:00

use array_column() to get the names, values, and options (#3)

This commit is contained in:
Eric Junker 2022-02-21 06:32:07 -06:00 committed by GitHub
parent c733871aaa
commit 54bedefb79
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 11 deletions

View file

@ -9,10 +9,6 @@ trait Options
/** Get an associative array of [case name => case value]. */
public static function options(): array
{
return array_reduce(static::cases(), function ($options, $case) {
$options[$case->name] = $case->value;
return $options;
}, []);
return array_column(static::cases(), 'value', 'name');
}
}