1 | <?php namespace Comodojo\Dispatcher\Components; |
||
28 | class HttpStatusCodes { |
||
29 | |||
30 | private $codes = array( |
||
31 | // Informational 1xx |
||
32 | 100 => 'Continue', |
||
33 | 101 => 'Switching Protocols', |
||
34 | 102 => 'Processing', |
||
35 | // Successful 2xx |
||
36 | 200 => 'OK', |
||
37 | 201 => 'Created', |
||
38 | 202 => 'Accepted', |
||
39 | 203 => 'Non-Authoritative Information', |
||
40 | 204 => 'No Content', |
||
41 | 205 => 'Reset Content', |
||
42 | 206 => 'Partial Content', |
||
43 | 207 => 'Multi-Status', // missing |
||
44 | 208 => 'Already Reported', // missing |
||
45 | 226 => 'IM Used', // missing |
||
46 | // Redirection 3xx |
||
47 | 300 => 'Multiple Choices', |
||
48 | 301 => 'Moved Permanently', |
||
49 | 302 => 'Found', |
||
50 | 303 => 'See Other', |
||
51 | 304 => 'Not Modified', |
||
52 | 305 => 'Use Proxy', |
||
53 | 307 => 'Temporary Redirect', |
||
54 | 308 => 'Permanent Redirect', |
||
55 | // Client Error 4xx |
||
56 | 400 => 'Bad Request', |
||
57 | 401 => 'Unauthorized', // missing |
||
58 | 402 => 'Payment Required', // missing |
||
59 | 403 => 'Forbidden', |
||
60 | 404 => 'Not Found', |
||
61 | 405 => 'Method Not Allowed', |
||
62 | 406 => 'Not Acceptable', // missing |
||
63 | 407 => 'Proxy Authentication Required', // missing |
||
64 | 408 => 'Request Timeout', // missing |
||
65 | 409 => 'Conflict', // missing |
||
66 | 410 => 'Gone', |
||
67 | 411 => 'Length Required', // missing |
||
68 | 412 => 'Precondition Failed', // missing |
||
69 | 413 => 'Payload Too Large', // missing |
||
70 | 414 => 'URI Too Long', // missing |
||
71 | 415 => 'Unsupported Media Type', // missing |
||
72 | 416 => 'Range Not Satisfiable', // missing |
||
73 | 417 => 'Expectation Failed', // missing |
||
74 | 421 => 'Misdirected Request', // missing |
||
75 | 422 => 'Unprocessable Entity', // missing |
||
76 | 423 => 'Locked', // missing |
||
77 | 424 => 'Failed Dependency', // missing |
||
78 | 426 => 'Upgrade Required', // missing |
||
79 | 428 => 'Precondition Required', // missing |
||
80 | 429 => 'Too Many Requests', // missing |
||
81 | 431 => 'Request Header Fields Too Large', // missing |
||
82 | 451 => 'Unavailable For Legal Reasons', // missing |
||
83 | // Server Error 5xx |
||
84 | 500 => 'Internal Server Error', |
||
85 | 501 => 'Not Implemented', |
||
86 | 502 => 'Bad Gateway', |
||
87 | 503 => 'Service Unavailable', |
||
88 | 504 => 'Gateway Timeout', |
||
89 | 505 => 'HTTP Version Not Supported', |
||
90 | 506 => 'Variant Also Negotiates (Experimental)', // missing |
||
91 | 507 => 'Insufficient Storage', // missing |
||
92 | 508 => 'Loop Detected', // missing |
||
93 | 510 => 'Not Extended', // missing |
||
94 | 511 => 'Network Authentication Required' // missing |
||
95 | ); |
||
96 | |||
97 | public function exists($code) { |
||
102 | |||
103 | public function getMessage($code) { |
||
110 | |||
111 | public function isInformational($code) { |
||
116 | |||
117 | public function isSuccessful($code) { |
||
122 | |||
123 | public function isRedirection($code) { |
||
128 | |||
129 | public function isClientError($code) { |
||
134 | |||
135 | public function isServerError($code) { |
||
140 | |||
141 | } |
||
142 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: