PHP Classes

File: infrastructure/core/enums/HttpRequest.php

Recommend this page to a friend!
  Classes of Maicon gonçalez   Potato Service   infrastructure/core/enums/HttpRequest.php   Download  
File: infrastructure/core/enums/HttpRequest.php
Role: Auxiliary script
Content type: text/plain
Description: Auxiliary script
Class: Potato Service
Framework that extracts route details from classes
Author: By
Last change: fix(core): Same changes and new class PDOEasy
Date: 9 months ago
Size: 519 bytes
 

Contents

Class file image Download
<?php
namespace infrastructure\core\enums;


enum HttpRequest: int {

    case
GET = 0;
    case
POST = 1;
    case
PUT = 2;
    case
DELETE = 3;
    case
PATCH = 4;

    public static function
fromString(string $httpRequest): HttpRequest {
       
$httpRequest = strtolower($httpRequest);

        return
match($httpRequest) {
           
"post" => self::POST,
           
"put" => self::PUT,
           
"delete" => self::DELETE,
           
"patch" => self::PATCH,
            default =>
self::GET
       
};
    }
}