mirror of
https://github.com/archtechx/enums.git
synced 2025-12-12 12:34:04 +00:00
add options() method, resolve #2
This commit is contained in:
parent
7c02bbaa73
commit
e01edd128f
4 changed files with 34 additions and 9 deletions
16
src/Options.php
Normal file
16
src/Options.php
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
|
||||
namespace ArchTech\Enums;
|
||||
|
||||
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;
|
||||
}, []);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue