Skip to content

Commit 408c23c

Browse files
committed
feat: add HTTP\Method class
1 parent 867be9e commit 408c23c

File tree

1 file changed

+95
-0
lines changed

1 file changed

+95
-0
lines changed

system/HTTP/Method.php

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
<?php
2+
3+
/**
4+
* This file is part of CodeIgniter 4 framework.
5+
*
6+
* (c) CodeIgniter Foundation <[email protected]>
7+
*
8+
* For the full copyright and license information, please view
9+
* the LICENSE file that was distributed with this source code.
10+
*/
11+
12+
namespace CodeIgniter\HTTP;
13+
14+
/**
15+
* HTTP Method List
16+
*/
17+
class Method
18+
{
19+
/**
20+
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/CONNECT
21+
*/
22+
public const CONNECT = 'CONNECT';
23+
24+
/**
25+
* Idempotent
26+
*
27+
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/DELETE
28+
*/
29+
public const DELETE = 'DELETE';
30+
31+
/**
32+
* Safe, Idempotent, Cacheable
33+
*
34+
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/GET
35+
*/
36+
public const GET = 'GET';
37+
38+
/**
39+
* Safe, Idempotent, Cacheable
40+
*
41+
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/HEAD
42+
*/
43+
public const HEAD = 'HEAD';
44+
45+
/**
46+
* Safe, Idempotent
47+
*
48+
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/OPTIONS
49+
*/
50+
public const OPTIONS = 'OPTIONS';
51+
52+
/**
53+
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/PATCH
54+
*/
55+
public const PATCH = 'PATCH';
56+
57+
/**
58+
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST
59+
*/
60+
public const POST = 'POST';
61+
62+
/**
63+
* Idempotent
64+
*
65+
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/PUT
66+
*/
67+
public const PUT = 'PUT';
68+
69+
/**
70+
* Safe, Idempotent
71+
*
72+
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/TRACE
73+
*/
74+
public const TRACE = 'TRACE';
75+
76+
/**
77+
* Returns all HTTP methods.
78+
*
79+
* @return list<string>
80+
*/
81+
public static function all(): array
82+
{
83+
return [
84+
self::CONNECT,
85+
self::DELETE,
86+
self::GET,
87+
self::HEAD,
88+
self::OPTIONS,
89+
self::PATCH,
90+
self::POST,
91+
self::PUT,
92+
self::TRACE,
93+
];
94+
}
95+
}

0 commit comments

Comments
 (0)