| @@ 85-98 (lines=14) @@ | ||
| 82 | /** |
|
| 83 | * @internal |
|
| 84 | */ |
|
| 85 | private static function autodiscoveredReadables(): array |
|
| 86 | { |
|
| 87 | $enumType = static::class; |
|
| 88 | ||
| 89 | if (!isset(self::$guessedReadables[$enumType])) { |
|
| 90 | $constants = (new \ReflectionClass($enumType))->getConstants(); |
|
| 91 | foreach (self::autodiscoveredValues() as $value) { |
|
| 92 | $constantName = array_search($value, $constants, true); |
|
| 93 | self::$guessedReadables[$enumType][$value] = ucfirst(strtolower(str_replace('_', ' ', $constantName))); |
|
| 94 | } |
|
| 95 | } |
|
| 96 | ||
| 97 | return self::$guessedReadables[$enumType]; |
|
| 98 | } |
|
| 99 | } |
|
| 100 | ||
| @@ 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} |
|