Oihana PHP Enums

HttpMethod uses ConstantsTrait

Defines constants for common HTTP request methods.

Table of Contents

Constants

ALL  : string = 'ALL'
all  : string = 'all'
CONNECT  : string = 'CONNECT'
connect  : string = 'connect'
count  : string = 'count'
default  : string = 'default'
DELETE  : string = 'DELETE'
delete  : string = 'delete'
deleteAll  : string = 'deleteAll'
exist  : string = 'exist'
flush  : string = 'flush'
GET  : string = 'GET'
get  : string = 'get'
HEAD  : string = 'HEAD'
head  : string = 'head'
insert  : string = 'insert'
list  : string = 'list'
OPTIONS  : string = 'OPTIONS'
options  : string = 'options'
PATCH  : string = 'PATCH'
patch  : string = 'patch'
POST  : string = 'POST'
post  : string = 'post'
PURGE  : string = 'PURGE'
purge  : string = 'purge'
PUT  : string = 'PUT'
put  : string = 'put'
replace  : string = 'replace'
TRACE  : string = 'TRACE'
trace  : string = 'trace'
truncate  : string = 'truncate'
update  : string = 'update'
upsert  : string = 'upsert'

Methods

isValid()  : bool
Checks whether a given HTTP method is a valid standard HTTP method.

Constants

Methods

isValid()

Checks whether a given HTTP method is a valid standard HTTP method.

public static isValid(string $method[, bool $caseSensitive = false ]) : bool

This method compares the input string against the list of recognized HTTP methods (GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS, TRACE, CONNECT, PURGE). By default, the check is case-insensitive, but you can enforce exact case matching by setting $caseSensitive to true.

Parameters
$method : string

The HTTP method to validate (e.g., 'GET', 'post').

$caseSensitive : bool = false

Optional. Whether the match should be case-sensitive. Defaults to false.

Tags
example
HttpMethod::isValid('POST');        // true
HttpMethod::isValid('post');        // true
HttpMethod::isValid('post', true);  // false
HttpMethod::isValid('flush');       // false
Return values
bool

Returns true if the method is a recognized HTTP method, false otherwise.

On this page

Search results