@@ 72-82 (lines=11) @@ | ||
69 | return array_keys(self::getEnumReflection(static::class)->getConstants()); |
|
70 | } |
|
71 | ||
72 | private static function getConstantReflection(string $class, string $name): \ReflectionClassConstant |
|
73 | { |
|
74 | $key = self::getConstKey($class, $name); |
|
75 | if (!array_key_exists($key, self::$constReflections)) { |
|
76 | $refl = self::getEnumReflection(static::class); |
|
77 | ||
78 | self::$constReflections[$key] = $refl->getReflectionConstant($name); |
|
79 | } |
|
80 | ||
81 | return self::$constReflections[$key]; |
|
82 | } |
|
83 | ||
84 | private static function getConstKey(string $class, string $name): string |
|
85 | { |
|
@@ 116-127 (lines=12) @@ | ||
113 | * |
|
114 | * @return static |
|
115 | */ |
|
116 | private static function createNamedInstance(string $name) |
|
117 | { |
|
118 | $class = self::findParentClassForConst($name); |
|
119 | ||
120 | $key = self::getConstKey($class, $name); |
|
121 | ||
122 | if (!array_key_exists($key, self::$instances)) { |
|
123 | self::$instances[$key] = new static($name); |
|
124 | } |
|
125 | ||
126 | return self::$instances[$key]; |
|
127 | } |
|
128 | ||
129 | final public function getName(): string |
|
130 | { |