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

add names() and values() methods, resolve #1

This commit is contained in:
Samuel Štancl 2022-02-20 21:53:21 +01:00
parent e01edd128f
commit b50d001374
5 changed files with 41 additions and 1 deletions

14
src/Names.php Normal file
View file

@ -0,0 +1,14 @@
<?php
namespace ArchTech\Enums;
trait Names
{
/** Get an array of case names. */
public static function names(): array
{
return array_map(function ($case) {
return $case->name;
}, static::cases());
}
}

14
src/Values.php Normal file
View file

@ -0,0 +1,14 @@
<?php
namespace ArchTech\Enums;
trait Values
{
/** Get an array of case values. */
public static function values(): array
{
return array_map(function ($case) {
return $case->value;
}, static::cases());
}
}