This repository was archived by the owner on Jan 5, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStatus.php
More file actions
executable file
·135 lines (126 loc) · 4.18 KB
/
Status.php
File metadata and controls
executable file
·135 lines (126 loc) · 4.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<?php
namespace Modulus\Http;
use Modulus\Support\Extendable;
final class Status
{
use Extendable;
/**
* Status::CODE
*
* @var array
*/
const CODE = array(
100 => 'Informational: Continue',
101 => 'Informational: Switching Protocols',
102 => 'Informational: Processing',
200 => 'Successful: OK',
201 => 'Successful: Created',
202 => 'Successful: Accepted',
203 => 'Successful: Non-Authoritative Information',
204 => 'Successful: No Content',
205 => 'Successful: Reset Content',
206 => 'Successful: Partial Content',
207 => 'Successful: Multi-Status',
208 => 'Successful: Already Reported',
226 => 'Successful: IM Used',
300 => 'Redirection: Multiple Choices',
301 => 'Redirection: Moved Permanently',
302 => 'Redirection: Found',
303 => 'Redirection: See Other',
304 => 'Redirection: Not Modified',
305 => 'Redirection: Use Proxy',
306 => 'Redirection: Switch Proxy',
307 => 'Redirection: Temporary Redirect',
308 => 'Redirection: Permanent Redirect',
400 => 'Client Error: Bad Request',
401 => 'Client Error: Unauthorized',
402 => 'Client Error: Payment Required',
403 => 'Client Error: Forbidden',
404 => 'Client Error: Not Found',
405 => 'Client Error: Method Not Allowed',
406 => 'Client Error: Not Acceptable',
407 => 'Client Error: Proxy Authentication Required',
408 => 'Client Error: Request Timeout',
409 => 'Client Error: Conflict',
410 => 'Client Error: Gone',
411 => 'Client Error: Length Required',
412 => 'Client Error: Precondition Failed',
413 => 'Client Error: Request Entity Too Large',
414 => 'Client Error: Request-URI Too Long',
415 => 'Client Error: Unsupported Media Type',
416 => 'Client Error: Requested Range Not Satisfiable',
417 => 'Client Error: Expectation Failed',
418 => 'Client Error: I\'m a teapot',
419 => 'Client Error: Authentication Timeout',
420 => 'Client Error: Enhance Your Calm',
420 => 'Client Error: Method Failure',
422 => 'Client Error: Unprocessable Entity',
423 => 'Client Error: Locked',
424 => 'Client Error: Failed Dependency',
424 => 'Client Error: Method Failure',
425 => 'Client Error: Unordered Collection',
426 => 'Client Error: Upgrade Required',
428 => 'Client Error: Precondition Required',
429 => 'Client Error: Too Many Requests',
431 => 'Client Error: Request Header Fields Too Large',
444 => 'Client Error: No Response',
449 => 'Client Error: Retry With',
450 => 'Client Error: Blocked by Windows Parental Controls',
451 => 'Client Error: Redirect',
451 => 'Client Error: Unavailable For Legal Reasons',
494 => 'Client Error: Request Header Too Large',
495 => 'Client Error: Cert Error',
496 => 'Client Error: No Cert',
497 => 'Client Error: HTTP to HTTPS',
499 => 'Client Error: Client Closed Request',
500 => 'Server Error: Internal Server Error',
501 => 'Server Error: Not Implemented',
502 => 'Server Error: Bad Gateway',
503 => 'Server Error: Service Unavailable',
504 => 'Server Error: Gateway Timeout',
505 => 'Server Error: HTTP Version Not Supported',
506 => 'Server Error: Variant Also Negotiates',
507 => 'Server Error: Insufficient Storage',
508 => 'Server Error: Loop Detected',
509 => 'Server Error: Bandwidth Limit Exceeded',
510 => 'Server Error: Not Extended',
511 => 'Server Error: Network Authentication Required',
598 => 'Server Error: Network read timeout error',
599 => 'Server Error: Network connect timeout error',
);
/**
* Current status code
*
* @return integer
*/
public static function current() : ?int
{
return http_response_code();
}
/**
* Set status code
*
* @param int $code
* @return ?bool
*/
public static function set(int $code) : ?bool
{
if (!isset(Status::CODE[$code])) {
return false;
}
http_response_code($code);
return true;
}
/**
* Get status description
*
* @return ?string
*/
public static function description() : ?string
{
if (isset(Status::CODE[Status::current()])) {
return Status::CODE[Status::current()];
}
return null;
}
}