@@ -262,7 +262,7 @@ |
||
| 262 | 262 | throw new InvalidArgumentException('HTTP status code must be an integer'); |
| 263 | 263 | } |
| 264 | 264 | |
| 265 | - if (! ($statusCode >= 100 && $statusCode <= 599)) { |
|
| 265 | + if (!($statusCode >= 100 && $statusCode <= 599)) { |
|
| 266 | 266 | throw new InvalidArgumentException('Invalid HTTP status code'); |
| 267 | 267 | } |
| 268 | 268 | } |
@@ -35,241 +35,241 @@ |
||
| 35 | 35 | class Response extends Message implements ResponseInterface, StatusCodeInterface |
| 36 | 36 | { |
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * List of Reason Phrases |
|
| 40 | - * |
|
| 41 | - * @link http://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml |
|
| 42 | - * |
|
| 43 | - * @var array<int<100, 599>, non-empty-string> |
|
| 44 | - */ |
|
| 45 | - public const REASON_PHRASES = [ |
|
| 38 | + /** |
|
| 39 | + * List of Reason Phrases |
|
| 40 | + * |
|
| 41 | + * @link http://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml |
|
| 42 | + * |
|
| 43 | + * @var array<int<100, 599>, non-empty-string> |
|
| 44 | + */ |
|
| 45 | + public const REASON_PHRASES = [ |
|
| 46 | 46 | |
| 47 | - // 1xx |
|
| 48 | - 100 => 'Continue', |
|
| 49 | - 101 => 'Switching Protocols', |
|
| 50 | - 102 => 'Processing', |
|
| 51 | - 103 => 'Early Hints', |
|
| 47 | + // 1xx |
|
| 48 | + 100 => 'Continue', |
|
| 49 | + 101 => 'Switching Protocols', |
|
| 50 | + 102 => 'Processing', |
|
| 51 | + 103 => 'Early Hints', |
|
| 52 | 52 | |
| 53 | - // 2xx |
|
| 54 | - 200 => 'OK', |
|
| 55 | - 201 => 'Created', |
|
| 56 | - 202 => 'Accepted', |
|
| 57 | - 203 => 'Non-Authoritative Information', |
|
| 58 | - 204 => 'No Content', |
|
| 59 | - 205 => 'Reset Content', |
|
| 60 | - 206 => 'Partial Content', |
|
| 61 | - 207 => 'Multi-Status', |
|
| 62 | - 208 => 'Already Reported', |
|
| 63 | - 226 => 'IM Used', |
|
| 53 | + // 2xx |
|
| 54 | + 200 => 'OK', |
|
| 55 | + 201 => 'Created', |
|
| 56 | + 202 => 'Accepted', |
|
| 57 | + 203 => 'Non-Authoritative Information', |
|
| 58 | + 204 => 'No Content', |
|
| 59 | + 205 => 'Reset Content', |
|
| 60 | + 206 => 'Partial Content', |
|
| 61 | + 207 => 'Multi-Status', |
|
| 62 | + 208 => 'Already Reported', |
|
| 63 | + 226 => 'IM Used', |
|
| 64 | 64 | |
| 65 | - // 3xx |
|
| 66 | - 300 => 'Multiple Choices', |
|
| 67 | - 301 => 'Moved Permanently', |
|
| 68 | - 302 => 'Found', |
|
| 69 | - 303 => 'See Other', |
|
| 70 | - 304 => 'Not Modified', |
|
| 71 | - 305 => 'Use Proxy', |
|
| 72 | - 307 => 'Temporary Redirect', |
|
| 73 | - 308 => 'Permanent Redirect', |
|
| 65 | + // 3xx |
|
| 66 | + 300 => 'Multiple Choices', |
|
| 67 | + 301 => 'Moved Permanently', |
|
| 68 | + 302 => 'Found', |
|
| 69 | + 303 => 'See Other', |
|
| 70 | + 304 => 'Not Modified', |
|
| 71 | + 305 => 'Use Proxy', |
|
| 72 | + 307 => 'Temporary Redirect', |
|
| 73 | + 308 => 'Permanent Redirect', |
|
| 74 | 74 | |
| 75 | - // 4xx |
|
| 76 | - 400 => 'Bad Request', |
|
| 77 | - 401 => 'Unauthorized', |
|
| 78 | - 402 => 'Payment Required', |
|
| 79 | - 403 => 'Forbidden', |
|
| 80 | - 404 => 'Not Found', |
|
| 81 | - 405 => 'Method Not Allowed', |
|
| 82 | - 406 => 'Not Acceptable', |
|
| 83 | - 407 => 'Proxy Authentication Required', |
|
| 84 | - 408 => 'Request Timeout', |
|
| 85 | - 409 => 'Conflict', |
|
| 86 | - 410 => 'Gone', |
|
| 87 | - 411 => 'Length Required', |
|
| 88 | - 412 => 'Precondition Failed', |
|
| 89 | - 413 => 'Payload Too Large', |
|
| 90 | - 414 => 'URI Too Long', |
|
| 91 | - 415 => 'Unsupported Media Type', |
|
| 92 | - 416 => 'Range Not Satisfiable', |
|
| 93 | - 417 => 'Expectation Failed', |
|
| 94 | - 421 => 'Misdirected Request', |
|
| 95 | - 422 => 'Unprocessable Entity', |
|
| 96 | - 423 => 'Locked', |
|
| 97 | - 424 => 'Failed Dependency', |
|
| 98 | - 425 => 'Too Early', |
|
| 99 | - 426 => 'Upgrade Required', |
|
| 100 | - 428 => 'Precondition Required', |
|
| 101 | - 429 => 'Too Many Requests', |
|
| 102 | - 431 => 'Request Header Fields Too Large', |
|
| 103 | - 451 => 'Unavailable For Legal Reasons', |
|
| 75 | + // 4xx |
|
| 76 | + 400 => 'Bad Request', |
|
| 77 | + 401 => 'Unauthorized', |
|
| 78 | + 402 => 'Payment Required', |
|
| 79 | + 403 => 'Forbidden', |
|
| 80 | + 404 => 'Not Found', |
|
| 81 | + 405 => 'Method Not Allowed', |
|
| 82 | + 406 => 'Not Acceptable', |
|
| 83 | + 407 => 'Proxy Authentication Required', |
|
| 84 | + 408 => 'Request Timeout', |
|
| 85 | + 409 => 'Conflict', |
|
| 86 | + 410 => 'Gone', |
|
| 87 | + 411 => 'Length Required', |
|
| 88 | + 412 => 'Precondition Failed', |
|
| 89 | + 413 => 'Payload Too Large', |
|
| 90 | + 414 => 'URI Too Long', |
|
| 91 | + 415 => 'Unsupported Media Type', |
|
| 92 | + 416 => 'Range Not Satisfiable', |
|
| 93 | + 417 => 'Expectation Failed', |
|
| 94 | + 421 => 'Misdirected Request', |
|
| 95 | + 422 => 'Unprocessable Entity', |
|
| 96 | + 423 => 'Locked', |
|
| 97 | + 424 => 'Failed Dependency', |
|
| 98 | + 425 => 'Too Early', |
|
| 99 | + 426 => 'Upgrade Required', |
|
| 100 | + 428 => 'Precondition Required', |
|
| 101 | + 429 => 'Too Many Requests', |
|
| 102 | + 431 => 'Request Header Fields Too Large', |
|
| 103 | + 451 => 'Unavailable For Legal Reasons', |
|
| 104 | 104 | |
| 105 | - // 5xx |
|
| 106 | - 500 => 'Internal Server Error', |
|
| 107 | - 501 => 'Not Implemented', |
|
| 108 | - 502 => 'Bad Gateway', |
|
| 109 | - 503 => 'Service Unavailable', |
|
| 110 | - 504 => 'Gateway Timeout', |
|
| 111 | - 505 => 'HTTP Version Not Supported', |
|
| 112 | - 506 => 'Variant Also Negotiates', |
|
| 113 | - 507 => 'Insufficient Storage', |
|
| 114 | - 508 => 'Loop Detected', |
|
| 115 | - 510 => 'Not Extended', |
|
| 116 | - 511 => 'Network Authentication Required', |
|
| 117 | - ]; |
|
| 105 | + // 5xx |
|
| 106 | + 500 => 'Internal Server Error', |
|
| 107 | + 501 => 'Not Implemented', |
|
| 108 | + 502 => 'Bad Gateway', |
|
| 109 | + 503 => 'Service Unavailable', |
|
| 110 | + 504 => 'Gateway Timeout', |
|
| 111 | + 505 => 'HTTP Version Not Supported', |
|
| 112 | + 506 => 'Variant Also Negotiates', |
|
| 113 | + 507 => 'Insufficient Storage', |
|
| 114 | + 508 => 'Loop Detected', |
|
| 115 | + 510 => 'Not Extended', |
|
| 116 | + 511 => 'Network Authentication Required', |
|
| 117 | + ]; |
|
| 118 | 118 | |
| 119 | - /** |
|
| 120 | - * The response's status code |
|
| 121 | - * |
|
| 122 | - * @var int |
|
| 123 | - */ |
|
| 124 | - private int $statusCode = self::STATUS_OK; |
|
| 119 | + /** |
|
| 120 | + * The response's status code |
|
| 121 | + * |
|
| 122 | + * @var int |
|
| 123 | + */ |
|
| 124 | + private int $statusCode = self::STATUS_OK; |
|
| 125 | 125 | |
| 126 | - /** |
|
| 127 | - * The response's reason phrase |
|
| 128 | - * |
|
| 129 | - * @var string |
|
| 130 | - */ |
|
| 131 | - private string $reasonPhrase = self::REASON_PHRASES[self::STATUS_OK]; |
|
| 126 | + /** |
|
| 127 | + * The response's reason phrase |
|
| 128 | + * |
|
| 129 | + * @var string |
|
| 130 | + */ |
|
| 131 | + private string $reasonPhrase = self::REASON_PHRASES[self::STATUS_OK]; |
|
| 132 | 132 | |
| 133 | - /** |
|
| 134 | - * Constrictor of the class |
|
| 135 | - * |
|
| 136 | - * @param int|null $statusCode |
|
| 137 | - * @param string|null $reasonPhrase |
|
| 138 | - * @param array<string, string|string[]>|null $headers |
|
| 139 | - * @param StreamInterface|null $body |
|
| 140 | - * |
|
| 141 | - * @throws InvalidArgumentException |
|
| 142 | - * If one of the arguments isn't valid. |
|
| 143 | - */ |
|
| 144 | - public function __construct( |
|
| 145 | - ?int $statusCode = null, |
|
| 146 | - ?string $reasonPhrase = null, |
|
| 147 | - ?array $headers = null, |
|
| 148 | - ?StreamInterface $body = null |
|
| 149 | - ) { |
|
| 150 | - if (isset($statusCode)) { |
|
| 151 | - $this->setStatus($statusCode, $reasonPhrase ?? ''); |
|
| 152 | - } |
|
| 133 | + /** |
|
| 134 | + * Constrictor of the class |
|
| 135 | + * |
|
| 136 | + * @param int|null $statusCode |
|
| 137 | + * @param string|null $reasonPhrase |
|
| 138 | + * @param array<string, string|string[]>|null $headers |
|
| 139 | + * @param StreamInterface|null $body |
|
| 140 | + * |
|
| 141 | + * @throws InvalidArgumentException |
|
| 142 | + * If one of the arguments isn't valid. |
|
| 143 | + */ |
|
| 144 | + public function __construct( |
|
| 145 | + ?int $statusCode = null, |
|
| 146 | + ?string $reasonPhrase = null, |
|
| 147 | + ?array $headers = null, |
|
| 148 | + ?StreamInterface $body = null |
|
| 149 | + ) { |
|
| 150 | + if (isset($statusCode)) { |
|
| 151 | + $this->setStatus($statusCode, $reasonPhrase ?? ''); |
|
| 152 | + } |
|
| 153 | 153 | |
| 154 | - if (isset($headers)) { |
|
| 155 | - $this->setHeaders($headers); |
|
| 156 | - } |
|
| 154 | + if (isset($headers)) { |
|
| 155 | + $this->setHeaders($headers); |
|
| 156 | + } |
|
| 157 | 157 | |
| 158 | - if (isset($body)) { |
|
| 159 | - $this->setBody($body); |
|
| 160 | - } |
|
| 161 | - } |
|
| 158 | + if (isset($body)) { |
|
| 159 | + $this->setBody($body); |
|
| 160 | + } |
|
| 161 | + } |
|
| 162 | 162 | |
| 163 | - /** |
|
| 164 | - * Gets the response's status code |
|
| 165 | - * |
|
| 166 | - * @return int |
|
| 167 | - */ |
|
| 168 | - public function getStatusCode(): int |
|
| 169 | - { |
|
| 170 | - return $this->statusCode; |
|
| 171 | - } |
|
| 163 | + /** |
|
| 164 | + * Gets the response's status code |
|
| 165 | + * |
|
| 166 | + * @return int |
|
| 167 | + */ |
|
| 168 | + public function getStatusCode(): int |
|
| 169 | + { |
|
| 170 | + return $this->statusCode; |
|
| 171 | + } |
|
| 172 | 172 | |
| 173 | - /** |
|
| 174 | - * Gets the response's reason phrase |
|
| 175 | - * |
|
| 176 | - * @return string |
|
| 177 | - */ |
|
| 178 | - public function getReasonPhrase(): string |
|
| 179 | - { |
|
| 180 | - return $this->reasonPhrase; |
|
| 181 | - } |
|
| 173 | + /** |
|
| 174 | + * Gets the response's reason phrase |
|
| 175 | + * |
|
| 176 | + * @return string |
|
| 177 | + */ |
|
| 178 | + public function getReasonPhrase(): string |
|
| 179 | + { |
|
| 180 | + return $this->reasonPhrase; |
|
| 181 | + } |
|
| 182 | 182 | |
| 183 | - /** |
|
| 184 | - * Creates a new instance of the response with the given status code |
|
| 185 | - * |
|
| 186 | - * @param int $code |
|
| 187 | - * @param string $reasonPhrase |
|
| 188 | - * |
|
| 189 | - * @return static |
|
| 190 | - * |
|
| 191 | - * @throws InvalidArgumentException |
|
| 192 | - * If the status isn't valid. |
|
| 193 | - */ |
|
| 194 | - public function withStatus($code, $reasonPhrase = ''): ResponseInterface |
|
| 195 | - { |
|
| 196 | - $clone = clone $this; |
|
| 197 | - $clone->setStatus($code, $reasonPhrase); |
|
| 183 | + /** |
|
| 184 | + * Creates a new instance of the response with the given status code |
|
| 185 | + * |
|
| 186 | + * @param int $code |
|
| 187 | + * @param string $reasonPhrase |
|
| 188 | + * |
|
| 189 | + * @return static |
|
| 190 | + * |
|
| 191 | + * @throws InvalidArgumentException |
|
| 192 | + * If the status isn't valid. |
|
| 193 | + */ |
|
| 194 | + public function withStatus($code, $reasonPhrase = ''): ResponseInterface |
|
| 195 | + { |
|
| 196 | + $clone = clone $this; |
|
| 197 | + $clone->setStatus($code, $reasonPhrase); |
|
| 198 | 198 | |
| 199 | - return $clone; |
|
| 200 | - } |
|
| 199 | + return $clone; |
|
| 200 | + } |
|
| 201 | 201 | |
| 202 | - /** |
|
| 203 | - * Sets the given status code to the response |
|
| 204 | - * |
|
| 205 | - * @param int $statusCode |
|
| 206 | - * @param string $reasonPhrase |
|
| 207 | - * |
|
| 208 | - * @return void |
|
| 209 | - * |
|
| 210 | - * @throws InvalidArgumentException |
|
| 211 | - * If the status isn't valid. |
|
| 212 | - */ |
|
| 213 | - final protected function setStatus($statusCode, $reasonPhrase): void |
|
| 214 | - { |
|
| 215 | - $this->validateStatusCode($statusCode); |
|
| 216 | - $this->validateReasonPhrase($reasonPhrase); |
|
| 202 | + /** |
|
| 203 | + * Sets the given status code to the response |
|
| 204 | + * |
|
| 205 | + * @param int $statusCode |
|
| 206 | + * @param string $reasonPhrase |
|
| 207 | + * |
|
| 208 | + * @return void |
|
| 209 | + * |
|
| 210 | + * @throws InvalidArgumentException |
|
| 211 | + * If the status isn't valid. |
|
| 212 | + */ |
|
| 213 | + final protected function setStatus($statusCode, $reasonPhrase): void |
|
| 214 | + { |
|
| 215 | + $this->validateStatusCode($statusCode); |
|
| 216 | + $this->validateReasonPhrase($reasonPhrase); |
|
| 217 | 217 | |
| 218 | - if ('' === $reasonPhrase) { |
|
| 219 | - $reasonPhrase = self::REASON_PHRASES[$statusCode] ?? 'Unknown Status Code'; |
|
| 220 | - } |
|
| 218 | + if ('' === $reasonPhrase) { |
|
| 219 | + $reasonPhrase = self::REASON_PHRASES[$statusCode] ?? 'Unknown Status Code'; |
|
| 220 | + } |
|
| 221 | 221 | |
| 222 | - $this->statusCode = $statusCode; |
|
| 223 | - $this->reasonPhrase = $reasonPhrase; |
|
| 224 | - } |
|
| 222 | + $this->statusCode = $statusCode; |
|
| 223 | + $this->reasonPhrase = $reasonPhrase; |
|
| 224 | + } |
|
| 225 | 225 | |
| 226 | - /** |
|
| 227 | - * Validates the given status code |
|
| 228 | - * |
|
| 229 | - * @link https://tools.ietf.org/html/rfc7230#section-3.1.2 |
|
| 230 | - * |
|
| 231 | - * @param mixed $statusCode |
|
| 232 | - * |
|
| 233 | - * @return void |
|
| 234 | - * |
|
| 235 | - * @throws InvalidArgumentException |
|
| 236 | - * If the status code isn't valid. |
|
| 237 | - */ |
|
| 238 | - private function validateStatusCode($statusCode): void |
|
| 239 | - { |
|
| 240 | - if (!is_int($statusCode)) { |
|
| 241 | - throw new InvalidArgumentException('HTTP status code must be an integer'); |
|
| 242 | - } |
|
| 226 | + /** |
|
| 227 | + * Validates the given status code |
|
| 228 | + * |
|
| 229 | + * @link https://tools.ietf.org/html/rfc7230#section-3.1.2 |
|
| 230 | + * |
|
| 231 | + * @param mixed $statusCode |
|
| 232 | + * |
|
| 233 | + * @return void |
|
| 234 | + * |
|
| 235 | + * @throws InvalidArgumentException |
|
| 236 | + * If the status code isn't valid. |
|
| 237 | + */ |
|
| 238 | + private function validateStatusCode($statusCode): void |
|
| 239 | + { |
|
| 240 | + if (!is_int($statusCode)) { |
|
| 241 | + throw new InvalidArgumentException('HTTP status code must be an integer'); |
|
| 242 | + } |
|
| 243 | 243 | |
| 244 | - if (! ($statusCode >= 100 && $statusCode <= 599)) { |
|
| 245 | - throw new InvalidArgumentException('Invalid HTTP status code'); |
|
| 246 | - } |
|
| 247 | - } |
|
| 244 | + if (! ($statusCode >= 100 && $statusCode <= 599)) { |
|
| 245 | + throw new InvalidArgumentException('Invalid HTTP status code'); |
|
| 246 | + } |
|
| 247 | + } |
|
| 248 | 248 | |
| 249 | - /** |
|
| 250 | - * Validates the given reason phrase |
|
| 251 | - * |
|
| 252 | - * @link https://tools.ietf.org/html/rfc7230#section-3.1.2 |
|
| 253 | - * |
|
| 254 | - * @param mixed $reasonPhrase |
|
| 255 | - * |
|
| 256 | - * @return void |
|
| 257 | - * |
|
| 258 | - * @throws InvalidArgumentException |
|
| 259 | - * If the reason phrase isn't valid. |
|
| 260 | - */ |
|
| 261 | - private function validateReasonPhrase($reasonPhrase): void |
|
| 262 | - { |
|
| 263 | - if ('' === $reasonPhrase) { |
|
| 264 | - return; |
|
| 265 | - } |
|
| 249 | + /** |
|
| 250 | + * Validates the given reason phrase |
|
| 251 | + * |
|
| 252 | + * @link https://tools.ietf.org/html/rfc7230#section-3.1.2 |
|
| 253 | + * |
|
| 254 | + * @param mixed $reasonPhrase |
|
| 255 | + * |
|
| 256 | + * @return void |
|
| 257 | + * |
|
| 258 | + * @throws InvalidArgumentException |
|
| 259 | + * If the reason phrase isn't valid. |
|
| 260 | + */ |
|
| 261 | + private function validateReasonPhrase($reasonPhrase): void |
|
| 262 | + { |
|
| 263 | + if ('' === $reasonPhrase) { |
|
| 264 | + return; |
|
| 265 | + } |
|
| 266 | 266 | |
| 267 | - if (!is_string($reasonPhrase)) { |
|
| 268 | - throw new InvalidArgumentException('HTTP reason phrase must be a string'); |
|
| 269 | - } |
|
| 267 | + if (!is_string($reasonPhrase)) { |
|
| 268 | + throw new InvalidArgumentException('HTTP reason phrase must be a string'); |
|
| 269 | + } |
|
| 270 | 270 | |
| 271 | - if (!preg_match(HeaderInterface::RFC7230_FIELD_VALUE_REGEX, $reasonPhrase)) { |
|
| 272 | - throw new InvalidArgumentException('Invalid HTTP reason phrase'); |
|
| 273 | - } |
|
| 274 | - } |
|
| 271 | + if (!preg_match(HeaderInterface::RFC7230_FIELD_VALUE_REGEX, $reasonPhrase)) { |
|
| 272 | + throw new InvalidArgumentException('Invalid HTTP reason phrase'); |
|
| 273 | + } |
|
| 274 | + } |
|
| 275 | 275 | } |
@@ -27,35 +27,35 @@ |
||
| 27 | 27 | class StreamFactory implements StreamFactoryInterface |
| 28 | 28 | { |
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * {@inheritdoc} |
|
| 32 | - */ |
|
| 33 | - public function createStream(string $content = ''): StreamInterface |
|
| 34 | - { |
|
| 35 | - $stream = new PhpTempStream(); |
|
| 36 | - if ($content === '') { |
|
| 37 | - return $stream; |
|
| 38 | - } |
|
| 39 | - |
|
| 40 | - $stream->write($content); |
|
| 41 | - $stream->rewind(); |
|
| 42 | - |
|
| 43 | - return $stream; |
|
| 44 | - } |
|
| 45 | - |
|
| 46 | - /** |
|
| 47 | - * {@inheritdoc} |
|
| 48 | - */ |
|
| 49 | - public function createStreamFromFile(string $filename, string $mode = 'r'): StreamInterface |
|
| 50 | - { |
|
| 51 | - return new FileStream($filename, $mode); |
|
| 52 | - } |
|
| 53 | - |
|
| 54 | - /** |
|
| 55 | - * {@inheritdoc} |
|
| 56 | - */ |
|
| 57 | - public function createStreamFromResource($resource): StreamInterface |
|
| 58 | - { |
|
| 59 | - return new Stream($resource); |
|
| 60 | - } |
|
| 30 | + /** |
|
| 31 | + * {@inheritdoc} |
|
| 32 | + */ |
|
| 33 | + public function createStream(string $content = ''): StreamInterface |
|
| 34 | + { |
|
| 35 | + $stream = new PhpTempStream(); |
|
| 36 | + if ($content === '') { |
|
| 37 | + return $stream; |
|
| 38 | + } |
|
| 39 | + |
|
| 40 | + $stream->write($content); |
|
| 41 | + $stream->rewind(); |
|
| 42 | + |
|
| 43 | + return $stream; |
|
| 44 | + } |
|
| 45 | + |
|
| 46 | + /** |
|
| 47 | + * {@inheritdoc} |
|
| 48 | + */ |
|
| 49 | + public function createStreamFromFile(string $filename, string $mode = 'r'): StreamInterface |
|
| 50 | + { |
|
| 51 | + return new FileStream($filename, $mode); |
|
| 52 | + } |
|
| 53 | + |
|
| 54 | + /** |
|
| 55 | + * {@inheritdoc} |
|
| 56 | + */ |
|
| 57 | + public function createStreamFromResource($resource): StreamInterface |
|
| 58 | + { |
|
| 59 | + return new Stream($resource); |
|
| 60 | + } |
|
| 61 | 61 | } |
@@ -25,11 +25,11 @@ |
||
| 25 | 25 | class UriFactory implements UriFactoryInterface |
| 26 | 26 | { |
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * {@inheritdoc} |
|
| 30 | - */ |
|
| 31 | - public function createUri(string $uri = ''): UriInterface |
|
| 32 | - { |
|
| 33 | - return new Uri($uri); |
|
| 34 | - } |
|
| 28 | + /** |
|
| 29 | + * {@inheritdoc} |
|
| 30 | + */ |
|
| 31 | + public function createUri(string $uri = ''): UriInterface |
|
| 32 | + { |
|
| 33 | + return new Uri($uri); |
|
| 34 | + } |
|
| 35 | 35 | } |
@@ -25,11 +25,11 @@ |
||
| 25 | 25 | class RequestFactory implements RequestFactoryInterface |
| 26 | 26 | { |
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * {@inheritdoc} |
|
| 30 | - */ |
|
| 31 | - public function createRequest(string $method, $uri): RequestInterface |
|
| 32 | - { |
|
| 33 | - return new Request($method, $uri); |
|
| 34 | - } |
|
| 28 | + /** |
|
| 29 | + * {@inheritdoc} |
|
| 30 | + */ |
|
| 31 | + public function createRequest(string $method, $uri): RequestInterface |
|
| 32 | + { |
|
| 33 | + return new Request($method, $uri); |
|
| 34 | + } |
|
| 35 | 35 | } |
@@ -17,10 +17,10 @@ |
||
| 17 | 17 | interface ComponentInterface |
| 18 | 18 | { |
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * Gets the component value |
|
| 22 | - * |
|
| 23 | - * @return mixed |
|
| 24 | - */ |
|
| 25 | - public function getValue(); |
|
| 20 | + /** |
|
| 21 | + * Gets the component value |
|
| 22 | + * |
|
| 23 | + * @return mixed |
|
| 24 | + */ |
|
| 25 | + public function getValue(); |
|
| 26 | 26 | } |
@@ -25,11 +25,11 @@ |
||
| 25 | 25 | class ResponseFactory implements ResponseFactoryInterface |
| 26 | 26 | { |
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * {@inheritdoc} |
|
| 30 | - */ |
|
| 31 | - public function createResponse(int $code = 200, string $reasonPhrase = ''): ResponseInterface |
|
| 32 | - { |
|
| 33 | - return new Response($code, $reasonPhrase); |
|
| 34 | - } |
|
| 28 | + /** |
|
| 29 | + * {@inheritdoc} |
|
| 30 | + */ |
|
| 31 | + public function createResponse(int $code = 200, string $reasonPhrase = ''): ResponseInterface |
|
| 32 | + { |
|
| 33 | + return new Response($code, $reasonPhrase); |
|
| 34 | + } |
|
| 35 | 35 | } |
@@ -31,22 +31,22 @@ |
||
| 31 | 31 | class UploadedFileFactory implements UploadedFileFactoryInterface |
| 32 | 32 | { |
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * {@inheritdoc} |
|
| 36 | - */ |
|
| 37 | - public function createUploadedFile( |
|
| 38 | - StreamInterface $stream, |
|
| 39 | - ?int $size = null, |
|
| 40 | - int $error = UPLOAD_ERR_OK, |
|
| 41 | - ?string $clientFilename = null, |
|
| 42 | - ?string $clientMediaType = null |
|
| 43 | - ): UploadedFileInterface { |
|
| 44 | - return new UploadedFile( |
|
| 45 | - $stream, |
|
| 46 | - $size, |
|
| 47 | - $error, |
|
| 48 | - $clientFilename, |
|
| 49 | - $clientMediaType |
|
| 50 | - ); |
|
| 51 | - } |
|
| 34 | + /** |
|
| 35 | + * {@inheritdoc} |
|
| 36 | + */ |
|
| 37 | + public function createUploadedFile( |
|
| 38 | + StreamInterface $stream, |
|
| 39 | + ?int $size = null, |
|
| 40 | + int $error = UPLOAD_ERR_OK, |
|
| 41 | + ?string $clientFilename = null, |
|
| 42 | + ?string $clientMediaType = null |
|
| 43 | + ): UploadedFileInterface { |
|
| 44 | + return new UploadedFile( |
|
| 45 | + $stream, |
|
| 46 | + $size, |
|
| 47 | + $error, |
|
| 48 | + $clientFilename, |
|
| 49 | + $clientMediaType |
|
| 50 | + ); |
|
| 51 | + } |
|
| 52 | 52 | } |
@@ -32,29 +32,29 @@ |
||
| 32 | 32 | */ |
| 33 | 33 | function server_request_headers(?array $serverParams = null): array |
| 34 | 34 | { |
| 35 | - $serverParams ??= $_SERVER; |
|
| 35 | + $serverParams ??= $_SERVER; |
|
| 36 | 36 | |
| 37 | - // https://datatracker.ietf.org/doc/html/rfc3875#section-4.1.2 |
|
| 38 | - if (!isset($serverParams['HTTP_CONTENT_LENGTH']) && isset($serverParams['CONTENT_LENGTH'])) { |
|
| 39 | - $serverParams['HTTP_CONTENT_LENGTH'] = $serverParams['CONTENT_LENGTH']; |
|
| 40 | - } |
|
| 37 | + // https://datatracker.ietf.org/doc/html/rfc3875#section-4.1.2 |
|
| 38 | + if (!isset($serverParams['HTTP_CONTENT_LENGTH']) && isset($serverParams['CONTENT_LENGTH'])) { |
|
| 39 | + $serverParams['HTTP_CONTENT_LENGTH'] = $serverParams['CONTENT_LENGTH']; |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - // https://datatracker.ietf.org/doc/html/rfc3875#section-4.1.3 |
|
| 43 | - if (!isset($serverParams['HTTP_CONTENT_TYPE']) && isset($serverParams['CONTENT_TYPE'])) { |
|
| 44 | - $serverParams['HTTP_CONTENT_TYPE'] = $serverParams['CONTENT_TYPE']; |
|
| 45 | - } |
|
| 42 | + // https://datatracker.ietf.org/doc/html/rfc3875#section-4.1.3 |
|
| 43 | + if (!isset($serverParams['HTTP_CONTENT_TYPE']) && isset($serverParams['CONTENT_TYPE'])) { |
|
| 44 | + $serverParams['HTTP_CONTENT_TYPE'] = $serverParams['CONTENT_TYPE']; |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - $result = []; |
|
| 48 | - foreach ($serverParams as $key => $value) { |
|
| 49 | - if (0 <> strncmp('HTTP_', $key, 5)) { |
|
| 50 | - continue; |
|
| 51 | - } |
|
| 47 | + $result = []; |
|
| 48 | + foreach ($serverParams as $key => $value) { |
|
| 49 | + if (0 <> strncmp('HTTP_', $key, 5)) { |
|
| 50 | + continue; |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - $name = strtr(substr($key, 5), '_', '-'); |
|
| 54 | - $name = ucwords(strtolower($name), '-'); |
|
| 53 | + $name = strtr(substr($key, 5), '_', '-'); |
|
| 54 | + $name = ucwords(strtolower($name), '-'); |
|
| 55 | 55 | |
| 56 | - $result[$name] = $value; |
|
| 57 | - } |
|
| 56 | + $result[$name] = $value; |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - return $result; |
|
| 59 | + return $result; |
|
| 60 | 60 | } |
@@ -29,24 +29,24 @@ |
||
| 29 | 29 | */ |
| 30 | 30 | function server_request_protocol_version(?array $serverParams = null): string |
| 31 | 31 | { |
| 32 | - $serverParams ??= $_SERVER; |
|
| 32 | + $serverParams ??= $_SERVER; |
|
| 33 | 33 | |
| 34 | - if (!isset($serverParams['SERVER_PROTOCOL'])) { |
|
| 35 | - return '1.1'; |
|
| 36 | - } |
|
| 34 | + if (!isset($serverParams['SERVER_PROTOCOL'])) { |
|
| 35 | + return '1.1'; |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | - // "HTTP" "/" 1*digit "." 1*digit |
|
| 39 | - sscanf($serverParams['SERVER_PROTOCOL'], 'HTTP/%d.%d', $major, $minor); |
|
| 38 | + // "HTTP" "/" 1*digit "." 1*digit |
|
| 39 | + sscanf($serverParams['SERVER_PROTOCOL'], 'HTTP/%d.%d', $major, $minor); |
|
| 40 | 40 | |
| 41 | - // e.g.: HTTP/1.1 |
|
| 42 | - if (isset($minor)) { |
|
| 43 | - return sprintf('%d.%d', $major, $minor); |
|
| 44 | - } |
|
| 41 | + // e.g.: HTTP/1.1 |
|
| 42 | + if (isset($minor)) { |
|
| 43 | + return sprintf('%d.%d', $major, $minor); |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - // e.g.: HTTP/2 |
|
| 47 | - if (isset($major)) { |
|
| 48 | - return sprintf('%d', $major); |
|
| 49 | - } |
|
| 46 | + // e.g.: HTTP/2 |
|
| 47 | + if (isset($major)) { |
|
| 48 | + return sprintf('%d', $major); |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - return '1.1'; |
|
| 51 | + return '1.1'; |
|
| 52 | 52 | } |