From 662acfefa102edb63cbe9e2cf3b754b63edc7584 Mon Sep 17 00:00:00 2001 From: Sergei Shitikov Date: Sun, 27 Oct 2024 21:32:47 +0100 Subject: [PATCH] Update src/Container/HttpMethod.php improve fromString Co-authored-by: Jacob Dreesen --- src/Container/HttpMethod.php | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/Container/HttpMethod.php b/src/Container/HttpMethod.php index 628f5d4..4950c16 100644 --- a/src/Container/HttpMethod.php +++ b/src/Container/HttpMethod.php @@ -15,14 +15,6 @@ enum HttpMethod: string public static function fromString(string $method): self { - return match (strtoupper($method)) { - 'GET' => self::GET, - 'POST' => self::POST, - 'PUT' => self::PUT, - 'DELETE' => self::DELETE, - 'HEAD' => self::HEAD, - 'OPTIONS' => self::OPTIONS, - default => throw new \InvalidArgumentException("Invalid HTTP method: $method"), - }; + return self::tryFrom(strtoupper($method)) ?? throw new \InvalidArgumentException("Invalid HTTP method: $method"); } }