|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @package presentation |
|
4
|
|
|
* @subpackage responses |
|
5
|
|
|
* @author marius orcsik <[email protected]> |
|
6
|
|
|
* @date 2011.11.20 |
|
7
|
|
|
*/ |
|
8
|
|
|
namespace vsc\presentation\responses; |
|
9
|
|
|
|
|
10
|
|
|
class HttpResponseType { |
|
11
|
22 |
|
public static function getStatus($iStatus) { |
|
|
|
|
|
|
12
|
22 |
|
return (is_int($iStatus) && array_key_exists($iStatus, static::$aStatusList)) ? static::$aStatusList[$iStatus] : static::$aStatusList[500]; |
|
13
|
|
|
} |
|
14
|
|
|
|
|
15
|
1 |
|
public static function isValidStatus($iStatus) { |
|
16
|
1 |
|
return array_key_exists($iStatus, static::$aStatusList); |
|
17
|
|
|
} |
|
18
|
|
|
|
|
19
|
|
|
static protected $aStatusList = [ |
|
20
|
|
|
200 => '200 OK', |
|
21
|
|
|
201 => '201 Created', |
|
22
|
|
|
202 => '202 Accepted', |
|
23
|
|
|
204 => '204 No Content', |
|
24
|
|
|
301 => '301 Moved Permanently', |
|
25
|
|
|
302 => '302 Found', |
|
26
|
|
|
303 => '303 See Other', |
|
27
|
|
|
304 => '304 Not Modified', |
|
28
|
|
|
400 => '400 Bad Request', |
|
29
|
|
|
401 => '401 Unauthorized', |
|
30
|
|
|
402 => '402 Payment Required', |
|
31
|
|
|
403 => '403 Forbidden', |
|
32
|
|
|
404 => '404 Not Found', |
|
33
|
|
|
405 => '405 Method Not Allowed', |
|
34
|
|
|
406 => '406 Not Acceptable', |
|
35
|
|
|
408 => '408 Request Timeout', |
|
36
|
|
|
409 => '409 Conflict', |
|
37
|
|
|
410 => '410 Gone', |
|
38
|
|
|
415 => '415 Unsupported Media Type', |
|
39
|
|
|
426 => '426 Update Required', |
|
40
|
|
|
500 => '500 Internal Server Error', |
|
41
|
|
|
501 => '501 Not Implemented', |
|
42
|
|
|
]; |
|
43
|
|
|
|
|
44
|
1 |
|
public static function getList() { |
|
45
|
1 |
|
return self::$aStatusList; |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
const OK = 200; |
|
49
|
|
|
const CREATED = 201; |
|
50
|
|
|
const ACCEPTED = 202; |
|
51
|
|
|
const NO_CONTENT = 204; |
|
52
|
|
|
const FOUND = 302; |
|
53
|
|
|
const SEE_OTHER = 303; |
|
54
|
|
|
const NOT_MODIFIED = 304; |
|
55
|
|
|
const CLIENT_ERROR = 400; |
|
56
|
|
|
const NOT_AUTHORIZED = 401; |
|
57
|
|
|
const FORBIDDEN = 403; |
|
58
|
|
|
const NOT_FOUND = 404; |
|
59
|
|
|
const METHOD_NOT_ALLOWED = 405; |
|
60
|
|
|
const UNSUPPORTED_MEDIA_TYPE = 415; |
|
61
|
|
|
const INTERNAL_ERROR = 500; |
|
62
|
|
|
} |
|
63
|
|
|
|
Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a
@returnannotation as described here.