Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Feb 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/Names.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ trait Names
/** Get an array of case names. */
public static function names(): array
{
return array_map(function ($case) {
return $case->name;
}, static::cases());
return array_column(static::cases(), 'name');
}
}
6 changes: 1 addition & 5 deletions src/Options.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}
4 changes: 1 addition & 3 deletions src/Values.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ trait Values
/** Get an array of case values. */
public static function values(): array
{
return array_map(function ($case) {
return $case->value;
}, static::cases());
return array_column(static::cases(), 'value');
}
}