1 | <?php |
||
22 | class Response extends Message implements ResponseInterface |
||
23 | { |
||
24 | /** @var int The status code. */ |
||
25 | private $statusCode; |
||
26 | |||
27 | /** @var string The reason phrase. */ |
||
28 | private $reasonPhrase; |
||
29 | |||
30 | /** @var array The reason phrases */ |
||
31 | private static $reasonPhrases = [ |
||
32 | 100 => 'Continue', |
||
33 | 101 => 'Switching Protocols', |
||
34 | 102 => 'Processing', |
||
35 | 200 => 'OK', |
||
36 | 201 => 'Created', |
||
37 | 202 => 'Accepted', |
||
38 | 203 => 'Non-Authoritative Information', |
||
39 | 204 => 'No Content', |
||
40 | 205 => 'Reset Content', |
||
41 | 206 => 'Partial Content', |
||
42 | 207 => 'Multi-status', |
||
43 | 208 => 'Already Reported', |
||
44 | 300 => 'Multiple Choices', |
||
45 | 301 => 'Moved Permanently', |
||
46 | 302 => 'Found', |
||
47 | 303 => 'See Other', |
||
48 | 304 => 'Not Modified', |
||
49 | 305 => 'Use Proxy', |
||
50 | 306 => 'Switch Proxy', |
||
51 | 307 => 'Temporary Redirect', |
||
52 | 400 => 'Bad Request', |
||
53 | 401 => 'Unauthorized', |
||
54 | 402 => 'Payment Required', |
||
55 | 403 => 'Forbidden', |
||
56 | 404 => 'Not Found', |
||
57 | 405 => 'Method Not Allowed', |
||
58 | 406 => 'Not Acceptable', |
||
59 | 407 => 'Proxy Authentication Required', |
||
60 | 408 => 'Request Time-out', |
||
61 | 409 => 'Conflict', |
||
62 | 410 => 'Gone', |
||
63 | 411 => 'Length Required', |
||
64 | 412 => 'Precondition Failed', |
||
65 | 413 => 'Request Entity Too Large', |
||
66 | 414 => 'Request-URI Too Large', |
||
67 | 415 => 'Unsupported Media Type', |
||
68 | 416 => 'Requested range not satisfiable', |
||
69 | 417 => 'Expectation Failed', |
||
70 | 418 => 'I\'m a teapot', |
||
71 | 422 => 'Unprocessable Entity', |
||
72 | 423 => 'Locked', |
||
73 | 424 => 'Failed Dependency', |
||
74 | 425 => 'Unordered Collection', |
||
75 | 426 => 'Upgrade Required', |
||
76 | 428 => 'Precondition Required', |
||
77 | 429 => 'Too Many Requests', |
||
78 | 431 => 'Request Header Fields Too Large', |
||
79 | 500 => 'Internal Server Error', |
||
80 | 501 => 'Not Implemented', |
||
81 | 502 => 'Bad Gateway', |
||
82 | 503 => 'Service Unavailable', |
||
83 | 504 => 'Gateway Time-out', |
||
84 | 505 => 'HTTP Version not supported', |
||
85 | 506 => 'Variant Also Negotiates', |
||
86 | 507 => 'Insufficient Storage', |
||
87 | 508 => 'Loop Detected', |
||
88 | 511 => 'Network Authentication Required', |
||
89 | ]; |
||
90 | |||
91 | /** |
||
92 | * Construct a Response object with the given status code, reason phrase, version, headers & body. |
||
93 | * |
||
94 | * @param int $statusCode |
||
95 | * @param string $reasonPhrase = '' |
||
96 | * @param string $version = self::DEFAULT_VERSION |
||
97 | * @param array $headers = [] |
||
98 | * @param StreamInterface|null $body = null |
||
99 | */ |
||
100 | 6 | public function __construct($statusCode, $reasonPhrase = '', $version = self::DEFAULT_VERSION, array $headers = [], StreamInterface $body = null) |
|
106 | |||
107 | /** |
||
108 | * {@inheritdoc} |
||
109 | */ |
||
110 | 5 | public function getStatusCode() |
|
114 | |||
115 | /** |
||
116 | * Set the status. |
||
117 | * |
||
118 | * @param int $statusCode |
||
119 | * @param string $reasonPhrase = '' |
||
120 | * @return $this |
||
121 | */ |
||
122 | 6 | private function setStatus($statusCode, $reasonPhrase = '') |
|
133 | |||
134 | /** |
||
135 | * {@inheritdoc} |
||
136 | */ |
||
137 | 1 | public function withStatus($statusCode, $reasonPhrase = '') |
|
143 | |||
144 | /** |
||
145 | * {@inheritdoc} |
||
146 | */ |
||
147 | 5 | public function getReasonPhrase() |
|
151 | } |
||
152 |