1 | <?php |
||
13 | class Response implements ResponseInterface |
||
14 | { |
||
15 | use MessageTrait; |
||
16 | |||
17 | const PHRASES = [ |
||
18 | 100 => 'Continue', |
||
19 | 101 => 'Switching Protocols', |
||
20 | 102 => 'Processing', |
||
21 | 200 => 'OK', |
||
22 | 201 => 'Created', |
||
23 | 202 => 'Accepted', |
||
24 | 203 => 'Non-Authoritative Information', |
||
25 | 204 => 'No Content', |
||
26 | 205 => 'Reset Content', |
||
27 | 206 => 'Partial Content', |
||
28 | 207 => 'Multi-status', |
||
29 | 208 => 'Already Reported', |
||
30 | 300 => 'Multiple Choices', |
||
31 | 301 => 'Moved Permanently', |
||
32 | 302 => 'Found', |
||
33 | 303 => 'See Other', |
||
34 | 304 => 'Not Modified', |
||
35 | 305 => 'Use Proxy', |
||
36 | 306 => 'Switch Proxy', |
||
37 | 307 => 'Temporary Redirect', |
||
38 | 400 => 'Bad Request', |
||
39 | 401 => 'Unauthorized', |
||
40 | 402 => 'Payment Required', |
||
41 | 403 => 'Forbidden', |
||
42 | 404 => 'Not Found', |
||
43 | 405 => 'Method Not Allowed', |
||
44 | 406 => 'Not Acceptable', |
||
45 | 407 => 'Proxy Authentication Required', |
||
46 | 408 => 'Request Time-out', |
||
47 | 409 => 'Conflict', |
||
48 | 410 => 'Gone', |
||
49 | 411 => 'Length Required', |
||
50 | 412 => 'Precondition Failed', |
||
51 | 413 => 'Request Entity Too Large', |
||
52 | 414 => 'Request-URI Too Large', |
||
53 | 415 => 'Unsupported Media Type', |
||
54 | 416 => 'Requested range not satisfiable', |
||
55 | 417 => 'Expectation Failed', |
||
56 | 418 => 'I\'m a teapot', |
||
57 | 422 => 'Unprocessable Entity', |
||
58 | 423 => 'Locked', |
||
59 | 424 => 'Failed Dependency', |
||
60 | 425 => 'Unordered Collection', |
||
61 | 426 => 'Upgrade Required', |
||
62 | 428 => 'Precondition Required', |
||
63 | 429 => 'Too Many Requests', |
||
64 | 431 => 'Request Header Fields Too Large', |
||
65 | 451 => 'Unavailable For Legal Reasons', |
||
66 | 500 => 'Internal Server Error', |
||
67 | 501 => 'Not Implemented', |
||
68 | 502 => 'Bad Gateway', |
||
69 | 503 => 'Service Unavailable', |
||
70 | 504 => 'Gateway Time-out', |
||
71 | 505 => 'HTTP Version not supported', |
||
72 | 506 => 'Variant Also Negotiates', |
||
73 | 507 => 'Insufficient Storage', |
||
74 | 508 => 'Loop Detected', |
||
75 | 511 => 'Network Authentication Required', |
||
76 | ]; |
||
77 | |||
78 | /** |
||
79 | * @var string |
||
80 | */ |
||
81 | private $reasonPhrase; |
||
82 | |||
83 | /** |
||
84 | * @var int |
||
85 | */ |
||
86 | private $statusCode; |
||
87 | |||
88 | /** |
||
89 | * @param int $status Status code for the response, if any. |
||
90 | * @param array $headers Headers for the response, if any. |
||
91 | * @param mixed $body Stream body. |
||
92 | * @param string $version Protocol version. |
||
93 | * @param string $reason Reason phrase (a default will be used if possible). |
||
94 | */ |
||
95 | 18 | public function __construct( |
|
118 | |||
119 | 3 | public function getStatusCode() : int |
|
123 | |||
124 | 4 | public function getReasonPhrase() : string |
|
128 | |||
129 | 2 | public function withStatus($code, $reasonPhrase = '') : self |
|
142 | } |
||
143 |