@@ 52-62 (lines=11) @@ | ||
49 | return static::createNamedInstance($name, $const[$name]); |
|
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 | { |
|
@@ 96-107 (lines=12) @@ | ||
93 | * |
|
94 | * @return static |
|
95 | */ |
|
96 | private static function createNamedInstance(string $name, $value) |
|
97 | { |
|
98 | $class = self::findParentClassForConst($name); |
|
99 | ||
100 | $key = self::getConstKey($class, $name); |
|
101 | ||
102 | if (!array_key_exists($key, self::$instances)) { |
|
103 | self::$instances[$key] = new static($name, $value); |
|
104 | } |
|
105 | ||
106 | return self::$instances[$key]; |
|
107 | } |
|
108 | ||
109 | /** |
|
110 | * @return mixed |