Skip to content

Commit be02f8d

Browse files
committed
optimize the from named constructor to have only one array full scan without calling the constructor again
1 parent b072dc2 commit be02f8d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/Enum.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ public function __wakeup()
8888
*/
8989
public static function from($value): self
9090
{
91-
static::assertValidValue($value);
91+
$key = static::assertValidValueReturningKey($value);
9292

93-
return new static($value);
93+
return self::__callStatic($key, []);
9494
}
9595

9696
/**

0 commit comments

Comments
 (0)