| @@ 48-61 (lines=14) @@ | ||
| 45 | /** |
|
| 46 | * {@inheritdoc} |
|
| 47 | */ |
|
| 48 | public static function readables(): array |
|
| 49 | { |
|
| 50 | $enumType = static::class; |
|
| 51 | ||
| 52 | if (!isset(self::$readables[$enumType])) { |
|
| 53 | $constants = (new \ReflectionClass($enumType))->getConstants(); |
|
| 54 | foreach (static::values() as $value) { |
|
| 55 | $constantName = array_search($value, $constants, true); |
|
| 56 | self::$readables[$enumType][$value] = ucfirst(strtolower(str_replace('_', ' ', $constantName))); |
|
| 57 | } |
|
| 58 | } |
|
| 59 | ||
| 60 | return self::$readables[$enumType]; |
|
| 61 | } |
|
| 62 | ||
| 63 | /** |
|
| 64 | * {@inheritdoc} |
|
| @@ 84-97 (lines=14) @@ | ||
| 81 | /** |
|
| 82 | * @internal |
|
| 83 | */ |
|
| 84 | private static function autodiscoveredReadables(): array |
|
| 85 | { |
|
| 86 | $enumType = static::class; |
|
| 87 | ||
| 88 | if (!isset(self::$guessedReadables[$enumType])) { |
|
| 89 | $constants = (new \ReflectionClass($enumType))->getConstants(); |
|
| 90 | foreach (self::autodiscoveredValues() as $value) { |
|
| 91 | $constantName = array_search($value, $constants, true); |
|
| 92 | self::$guessedReadables[$enumType][$value] = ucfirst(strtolower(str_replace('_', ' ', $constantName))); |
|
| 93 | } |
|
| 94 | } |
|
| 95 | ||
| 96 | return self::$guessedReadables[$enumType]; |
|
| 97 | } |
|
| 98 | } |
|
| 99 | ||