diff --git a/src/Enums/HTTPMethod.php b/src/Enums/HTTPMethod.php index 6fa438d..d8b3cbd 100644 --- a/src/Enums/HTTPMethod.php +++ b/src/Enums/HTTPMethod.php @@ -4,35 +4,13 @@ namespace Firehed\API\Enums; -use Firehed\Common\Enum; +use function class_alias; +use function version_compare; -/** - * Direct use of this class (via these static methods) is deprecated. Instead, - * implementations should rely on the Request traits. - * - * This will be converted to a native Enum in PHP 8.1. - * - * @method static HTTPMethod DELETE() - * @method static HTTPMethod GET() - * @method static HTTPMethod OPTIONS() - * @method static HTTPMethod PATCH() - * @method static HTTPMethod POST() - * @method static HTTPMethod PUT() - */ -class HTTPMethod extends Enum -{ +use const PHP_VERSION; - // Other methods exist, but these are the only relevant ones for RESTful - // APIs - const GET = 'GET'; - const PATCH = 'PATCH'; - const POST = 'POST'; - const PUT = 'PUT'; - const DELETE = 'DELETE'; - const OPTIONS = 'OPTIONS'; - - public function __toString() - { - return $this->getValue(); - } +if (version_compare(PHP_VERSION, '8.1.0') >= 0) { + class_alias(HTTPMethodGTE81::class, HTTPMethod::class); +} else { + class_alias(HTTPMethodLTE80::class, HTTPMethod::class); } diff --git a/src/Enums/HTTPMethodGTE81.php b/src/Enums/HTTPMethodGTE81.php new file mode 100644 index 0000000..3d78523 --- /dev/null +++ b/src/Enums/HTTPMethodGTE81.php @@ -0,0 +1,15 @@ +getValue(); + } +}