mirror of
https://codeberg.org/vlw/php-xenum.git
synced 2026-02-26 02:31:59 +01:00
feat: add cases() method for retrieving all enum case instances
This commit is contained in:
parent
ba3f43a9e2
commit
54396761cc
1 changed files with 5 additions and 0 deletions
|
|
@ -40,4 +40,9 @@
|
|||
public static function entries(): array {
|
||||
return array_combine(self::names(), self::values());
|
||||
}
|
||||
|
||||
// Return an array of all enum case instances
|
||||
public static function cases(): array {
|
||||
return array_map(fn(string $name): static => static::fromName($name), self::names());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue