Skip to content

Commit

Permalink
use array_column() to get the names, values, and options (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
ejunker authored Feb 21, 2022
1 parent c733871 commit 54bedef
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 11 deletions.
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');
}
}

0 comments on commit 54bedef

Please sign in to comment.