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