Added missing HttpMethod enum

This commit is contained in:
Sergei Shitikov
2024-10-24 19:55:06 +02:00
parent 1cbfe638b9
commit 5b42abf081
+28
View File
@@ -0,0 +1,28 @@
<?php
declare(strict_types=1);
namespace Testcontainers\Container;
enum HttpMethod: string
{
case GET = 'GET';
case POST = 'POST';
case PUT = 'PUT';
case DELETE = 'DELETE';
case HEAD = 'HEAD';
case OPTIONS = 'OPTIONS';
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"),
};
}
}