@@ 52-62 (lines=11) @@ | ||
49 | return array_keys(self::getEnumReflection(static::class)->getConstants()); |
|
50 | } |
|
51 | ||
52 | private static function getConstantReflection(string $class, string $name): \ReflectionClassConstant |
|
53 | { |
|
54 | $key = self::getConstKey($class, $name); |
|
55 | if (!array_key_exists($key, self::$constReflections)) { |
|
56 | $refl = self::getEnumReflection(static::class); |
|
57 | ||
58 | self::$constReflections[$key] = $refl->getReflectionConstant($name); |
|
59 | } |
|
60 | ||
61 | return self::$constReflections[$key]; |
|
62 | } |
|
63 | ||
64 | private static function getConstKey(string $class, string $name): string |
|
65 | { |
|
@@ 90-101 (lines=12) @@ | ||
87 | * |
|
88 | * @return static |
|
89 | */ |
|
90 | private static function createNamedInstance(string $name) |
|
91 | { |
|
92 | $class = self::findParentClassForConst($name); |
|
93 | ||
94 | $key = self::getConstKey($class, $name); |
|
95 | ||
96 | if (!array_key_exists($key, self::$instances)) { |
|
97 | self::$instances[$key] = new static($name); |
|
98 | } |
|
99 | ||
100 | return self::$instances[$key]; |
|
101 | } |
|
102 | ||
103 | final public function getName(): string |
|
104 | { |