Skip to content

Commit d99b9ff

Browse files
committed
Little update to optimize __callStatic()
1 parent 9951a06 commit d99b9ff

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/Enum.php

+3-4
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public static function toArray()
108108
{
109109
$class = get_called_class();
110110
if (!array_key_exists($class, static::$cache)) {
111-
$reflection = new \ReflectionClass($class);
111+
$reflection = new \ReflectionClass($class);
112112
static::$cache[$class] = $reflection->getConstants();
113113
}
114114

@@ -164,9 +164,8 @@ public static function search($value)
164164
*/
165165
public static function __callStatic($name, $arguments)
166166
{
167-
if (static::isValidKey($name)) {
168-
$array = static::toArray();
169-
167+
$array = static::toArray();
168+
if (isset($array[$name])) {
170169
return new static($array[$name]);
171170
}
172171

0 commit comments

Comments
 (0)