1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace BWC\Share\Net; |
4
|
|
|
|
5
|
|
|
|
6
|
|
|
class HttpStatusCode |
7
|
|
|
{ |
8
|
|
|
const CONTINUE_ = 100; |
9
|
|
|
const SWITCHING_PROTOCOLS = 101; |
10
|
|
|
|
11
|
|
|
const OK = 200; |
12
|
|
|
const CREATED = 201; |
13
|
|
|
const ACCEPTED = 202; |
14
|
|
|
const NON_AUTHORITATIVE_INFORMATION = 203; |
15
|
|
|
const NO_CONTENT = 204; |
16
|
|
|
|
17
|
|
|
const MOVED_PERMANENTLY = 304; |
18
|
|
|
const FOUND = 302; |
19
|
|
|
const TEMPORARY_REDIRECT = 307; |
20
|
|
|
|
21
|
|
|
const BAD_REQUEST = 400; |
22
|
|
|
const UNAUTHORIZED = 401; |
23
|
|
|
const FORBIDDEN = 403; |
24
|
|
|
const NOT_FOUND = 404; |
25
|
|
|
const METHOD_NOT_ALLOWED = 405; |
26
|
|
|
|
27
|
|
|
const INTERNAL_SERVER_ERROR = 500; |
28
|
|
|
const NOT_IMPLEMENTED = 501; |
29
|
|
|
const SERVICE_UNAVAILABLE = 503; |
30
|
|
|
const HTTP_VERSION_NOT_SUPPORTED = 505; |
31
|
|
|
|
32
|
|
|
|
33
|
|
|
private static $codes = array( |
34
|
|
|
0 => 'Connection failed', |
35
|
|
|
100 => 'Continue', |
36
|
|
|
101 => 'Switching Protocols', |
37
|
|
|
200 => 'OK', |
38
|
|
|
201 => 'Created', |
39
|
|
|
202 => 'Accepted', |
40
|
|
|
203 => 'Non-Authoritative Information', |
41
|
|
|
204 => 'No Content', |
42
|
|
|
205 => 'Reset Content', |
43
|
|
|
206 => 'Partial Content', |
44
|
|
|
300 => 'Multiple Choices', |
45
|
|
|
301 => 'Moved Permanently', |
46
|
|
|
302 => 'Found', |
47
|
|
|
303 => 'See Other', |
48
|
|
|
304 => 'Not Modified', |
49
|
|
|
305 => 'Use Proxy', |
50
|
|
|
307 => 'Temporary Redirect', |
51
|
|
|
400 => 'Bad Request', |
52
|
|
|
401 => 'Unauthorized', |
53
|
|
|
403 => 'Forbidden', |
54
|
|
|
404 => 'Not Found', |
55
|
|
|
405 => 'Method Not Allowed', |
56
|
|
|
406 => 'Not Acceptable', |
57
|
|
|
407 => 'Proxy Authentication Required', |
58
|
|
|
408 => 'Request Timeout', |
59
|
|
|
409 => 'Conflict', |
60
|
|
|
410 => 'Gone', |
61
|
|
|
411 => 'Length Required', |
62
|
|
|
412 => 'Precondition Failed', |
63
|
|
|
413 => 'Request Entity Too Large', |
64
|
|
|
414 => 'Request URI Too Long', |
65
|
|
|
415 => 'Unsupported Media Type', |
66
|
|
|
416 => 'Requested Range Not Satisfiable', |
67
|
|
|
417 => 'Expectation Failed', |
68
|
|
|
500 => 'Internal Server Error', |
69
|
|
|
501 => 'Not Implemented', |
70
|
|
|
502 => 'Bad Gateway', |
71
|
|
|
503 => 'Service Unavailable', |
72
|
|
|
504 => 'Gateway Timeout', |
73
|
|
|
505 => 'HTTP Version Not Supported', |
74
|
|
|
); |
75
|
|
|
|
76
|
|
|
|
77
|
|
|
static function getMessage($code) { |
|
|
|
|
78
|
|
|
$result = self::$codes[$code]; |
79
|
|
|
return $result; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
} |
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.