From be02f8d94563890bd3ec094db5fbb8da24b0f95c Mon Sep 17 00:00:00 2001 From: Alexandru Patranescu Date: Mon, 15 Feb 2021 11:26:04 +0200 Subject: [PATCH] optimize the from named constructor to have only one array full scan without calling the constructor again --- src/Enum.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Enum.php b/src/Enum.php index 19cc275..b665b0c 100644 --- a/src/Enum.php +++ b/src/Enum.php @@ -88,9 +88,9 @@ public function __wakeup() */ public static function from($value): self { - static::assertValidValue($value); + $key = static::assertValidValueReturningKey($value); - return new static($value); + return self::__callStatic($key, []); } /**