| Total Complexity | 13 |
| Total Lines | 63 |
| Duplicated Lines | 0 % |
| Coverage | 95.83% |
| Changes | 0 | ||
| 1 | <?php |
||
| 19 | abstract class Enum |
||
| 20 | { |
||
| 21 | /** |
||
| 22 | * @return Generator<int|string> |
||
| 23 | */ |
||
| 24 | 4 | final public static function getIterator(): Generator |
|
| 36 | } |
||
| 37 | 2 | } |
|
| 38 | |||
| 39 | 4 | final public static function has(string $key): bool |
|
| 50 | } |
||
| 51 | |||
| 52 | final public static function isValid(int|string $value): bool |
||
| 53 | { |
||
| 54 | foreach (static::getIterator() as $valueConst) { |
||
| 55 | 4 | if ($value !== $valueConst) { |
|
| 56 | continue; |
||
| 57 | 4 | } |
|
| 58 | 4 | ||
| 59 | 4 | return true; |
|
| 60 | } |
||
| 61 | |||
| 62 | 4 | return false; |
|
| 63 | } |
||
| 64 | |||
| 65 | 1 | /** |
|
| 66 | * @throws Exception |
||
| 67 | */ |
||
| 68 | final public static function key(int|string $value): string |
||
| 77 | 4 | } |
|
| 78 | |||
| 79 | final public static function value(string $value): int|string |
||
| 82 | } |
||
| 83 | } |
||
| 84 |