Passed
Pull Request — master (#31)
by Anatoly
39:16
created
src/Response.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -262,7 +262,7 @@
 block discarded – undo
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
     }
Please login to merge, or discard this patch.
Indentation   +215 added lines, -215 removed lines patch added patch discarded remove patch
@@ -35,241 +35,241 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
src/StreamFactory.php 1 patch
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -27,35 +27,35 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
src/UriFactory.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -25,11 +25,11 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
src/RequestFactory.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -25,11 +25,11 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
src/Uri/Component/ComponentInterface.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -17,10 +17,10 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
src/Uri/Component/Port.php 1 patch
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -29,48 +29,48 @@
 block discarded – undo
29 29
 final class Port implements ComponentInterface
30 30
 {
31 31
 
32
-    /**
33
-     * The component value
34
-     *
35
-     * @var int|null
36
-     */
37
-    private ?int $value = null;
32
+	/**
33
+	 * The component value
34
+	 *
35
+	 * @var int|null
36
+	 */
37
+	private ?int $value = null;
38 38
 
39
-    /**
40
-     * Constructor of the class
41
-     *
42
-     * @param mixed $value
43
-     *
44
-     * @throws InvalidUriComponentException
45
-     *         If the component isn't valid.
46
-     */
47
-    public function __construct($value)
48
-    {
49
-        $min = 1;
50
-        $max = (2 ** 16) - 1;
39
+	/**
40
+	 * Constructor of the class
41
+	 *
42
+	 * @param mixed $value
43
+	 *
44
+	 * @throws InvalidUriComponentException
45
+	 *         If the component isn't valid.
46
+	 */
47
+	public function __construct($value)
48
+	{
49
+		$min = 1;
50
+		$max = (2 ** 16) - 1;
51 51
 
52
-        if ($value === null) {
53
-            return;
54
-        }
52
+		if ($value === null) {
53
+			return;
54
+		}
55 55
 
56
-        if (!is_int($value)) {
57
-            throw new InvalidUriComponentException('URI component "port" must be an integer');
58
-        }
56
+		if (!is_int($value)) {
57
+			throw new InvalidUriComponentException('URI component "port" must be an integer');
58
+		}
59 59
 
60
-        if (!($value >= $min && $value <= $max)) {
61
-            throw new InvalidUriComponentException('Invalid URI component "port"');
62
-        }
60
+		if (!($value >= $min && $value <= $max)) {
61
+			throw new InvalidUriComponentException('Invalid URI component "port"');
62
+		}
63 63
 
64
-        $this->value = $value;
65
-    }
64
+		$this->value = $value;
65
+	}
66 66
 
67
-    /**
68
-     * {@inheritdoc}
69
-     *
70
-     * @return int|null
71
-     */
72
-    public function getValue(): ?int
73
-    {
74
-        return $this->value;
75
-    }
67
+	/**
68
+	 * {@inheritdoc}
69
+	 *
70
+	 * @return int|null
71
+	 */
72
+	public function getValue(): ?int
73
+	{
74
+		return $this->value;
75
+	}
76 76
 }
Please login to merge, or discard this patch.
src/ResponseFactory.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -25,11 +25,11 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
src/ServerRequest.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -358,8 +358,8 @@
 block discarded – undo
358 358
          *
359 359
          * @psalm-suppress MissingClosureParamType
360 360
          */
361
-        array_walk_recursive($files, static function ($file): void {
362
-            if (! ($file instanceof UploadedFileInterface)) {
361
+        array_walk_recursive($files, static function($file): void {
362
+            if (!($file instanceof UploadedFileInterface)) {
363 363
                 throw new InvalidArgumentException('Invalid uploaded files');
364 364
             }
365 365
         });
Please login to merge, or discard this patch.
Indentation   +350 added lines, -350 removed lines patch added patch discarded remove patch
@@ -35,354 +35,354 @@
 block discarded – undo
35 35
 class ServerRequest extends Request implements ServerRequestInterface
36 36
 {
37 37
 
38
-    /**
39
-     * The server parameters
40
-     *
41
-     * @var array
42
-     */
43
-    private array $serverParams;
44
-
45
-    /**
46
-     * The request's query parameters
47
-     *
48
-     * @var array
49
-     */
50
-    private array $queryParams;
51
-
52
-    /**
53
-     * The request's cookie parameters
54
-     *
55
-     * @var array
56
-     */
57
-    private array $cookieParams;
58
-
59
-    /**
60
-     * The request's uploaded files
61
-     *
62
-     * @var array
63
-     */
64
-    private array $uploadedFiles;
65
-
66
-    /**
67
-     * The request's parsed body
68
-     *
69
-     * @var array|object|null
70
-     */
71
-    private $parsedBody;
72
-
73
-    /**
74
-     * The request attributes
75
-     *
76
-     * @var array
77
-     */
78
-    private array $attributes;
79
-
80
-    /**
81
-     * Constructor of the class
82
-     *
83
-     * @param string|null $protocolVersion
84
-     * @param string|null $method
85
-     * @param mixed $uri
86
-     * @param array<string, string|string[]>|null $headers
87
-     * @param StreamInterface|null $body
88
-     *
89
-     * @param array $serverParams
90
-     * @param array $queryParams
91
-     * @param array $cookieParams
92
-     * @param array $uploadedFiles
93
-     * @param array|object|null $parsedBody
94
-     * @param array $attributes
95
-     *
96
-     * @throws InvalidArgumentException
97
-     *         If one of the arguments isn't valid.
98
-     */
99
-    public function __construct(
100
-        ?string $protocolVersion = null,
101
-        ?string $method = null,
102
-        $uri = null,
103
-        ?array $headers = null,
104
-        ?StreamInterface $body = null,
105
-        array $serverParams = [],
106
-        array $queryParams = [],
107
-        array $cookieParams = [],
108
-        array $uploadedFiles = [],
109
-        $parsedBody = null,
110
-        array $attributes = []
111
-    ) {
112
-        if (isset($protocolVersion)) {
113
-            $this->setProtocolVersion($protocolVersion);
114
-        }
115
-
116
-        parent::__construct($method, $uri, $headers, $body);
117
-
118
-        $this->serverParams = $serverParams;
119
-        $this->queryParams = $queryParams;
120
-        $this->cookieParams = $cookieParams;
121
-        $this->setUploadedFiles($uploadedFiles);
122
-        $this->setParsedBody($parsedBody);
123
-        $this->attributes = $attributes;
124
-    }
125
-
126
-    /**
127
-     * Gets the server parameters
128
-     *
129
-     * @return array
130
-     */
131
-    public function getServerParams(): array
132
-    {
133
-        return $this->serverParams;
134
-    }
135
-
136
-    /**
137
-     * Gets the request's query parameters
138
-     *
139
-     * @return array
140
-     */
141
-    public function getQueryParams(): array
142
-    {
143
-        return $this->queryParams;
144
-    }
145
-
146
-    /**
147
-     * Creates a new instance of the request with the given query parameters
148
-     *
149
-     * @param array $query
150
-     *
151
-     * @return static
152
-     */
153
-    public function withQueryParams(array $query): ServerRequestInterface
154
-    {
155
-        $clone = clone $this;
156
-        $clone->queryParams = $query;
157
-
158
-        return $clone;
159
-    }
160
-
161
-    /**
162
-     * Gets the request's cookie parameters
163
-     *
164
-     * @return array
165
-     */
166
-    public function getCookieParams(): array
167
-    {
168
-        return $this->cookieParams;
169
-    }
170
-
171
-    /**
172
-     * Creates a new instance of the request with the given cookie parameters
173
-     *
174
-     * @param array $cookies
175
-     *
176
-     * @return static
177
-     */
178
-    public function withCookieParams(array $cookies): ServerRequestInterface
179
-    {
180
-        $clone = clone $this;
181
-        $clone->cookieParams = $cookies;
182
-
183
-        return $clone;
184
-    }
185
-
186
-    /**
187
-     * Gets the request's uploaded files
188
-     *
189
-     * @return array
190
-     */
191
-    public function getUploadedFiles(): array
192
-    {
193
-        return $this->uploadedFiles;
194
-    }
195
-
196
-    /**
197
-     * Creates a new instance of the request with the given uploaded files
198
-     *
199
-     * @param array $uploadedFiles
200
-     *
201
-     * @return static
202
-     *
203
-     * @throws InvalidArgumentException
204
-     *         If one of the files isn't valid.
205
-     */
206
-    public function withUploadedFiles(array $uploadedFiles): ServerRequestInterface
207
-    {
208
-        $clone = clone $this;
209
-        $clone->setUploadedFiles($uploadedFiles);
210
-
211
-        return $clone;
212
-    }
213
-
214
-    /**
215
-     * Gets the request's parsed body
216
-     *
217
-     * @return array|object|null
218
-     */
219
-    public function getParsedBody()
220
-    {
221
-        return $this->parsedBody;
222
-    }
223
-
224
-    /**
225
-     * Creates a new instance of the request with the given parsed body
226
-     *
227
-     * @param array|object|null $data
228
-     *
229
-     * @return static
230
-     *
231
-     * @throws InvalidArgumentException
232
-     *         If the data isn't valid.
233
-     */
234
-    public function withParsedBody($data): ServerRequestInterface
235
-    {
236
-        $clone = clone $this;
237
-        $clone->setParsedBody($data);
238
-
239
-        return $clone;
240
-    }
241
-
242
-    /**
243
-     * Gets the request attributes
244
-     *
245
-     * @return array
246
-     */
247
-    public function getAttributes(): array
248
-    {
249
-        return $this->attributes;
250
-    }
251
-
252
-    /**
253
-     * Gets the request's attribute value by the given name
254
-     *
255
-     * Returns the default value if the attribute wasn't found.
256
-     *
257
-     * @param array-key $name
258
-     * @param mixed $default
259
-     *
260
-     * @return mixed
261
-     */
262
-    public function getAttribute($name, $default = null)
263
-    {
264
-        if (!array_key_exists($name, $this->attributes)) {
265
-            return $default;
266
-        }
267
-
268
-        return $this->attributes[$name];
269
-    }
270
-
271
-    /**
272
-     * Creates a new instance of the request with the given attribute
273
-     *
274
-     * @param array-key $name
275
-     * @param mixed $value
276
-     *
277
-     * @return static
278
-     */
279
-    public function withAttribute($name, $value): ServerRequestInterface
280
-    {
281
-        $clone = clone $this;
282
-        $clone->attributes[$name] = $value;
283
-
284
-        return $clone;
285
-    }
286
-
287
-    /**
288
-     * Creates a new instance of the request without an attribute with the given name
289
-     *
290
-     * @param array-key $name
291
-     *
292
-     * @return static
293
-     */
294
-    public function withoutAttribute($name): ServerRequestInterface
295
-    {
296
-        $clone = clone $this;
297
-        unset($clone->attributes[$name]);
298
-
299
-        return $clone;
300
-    }
301
-
302
-    /**
303
-     * Sets the given uploaded files to the request
304
-     *
305
-     * @param array $files
306
-     *
307
-     * @return void
308
-     *
309
-     * @throws InvalidArgumentException
310
-     *         If one of the files isn't valid.
311
-     */
312
-    final protected function setUploadedFiles(array $files): void
313
-    {
314
-        $this->validateUploadedFiles($files);
315
-
316
-        $this->uploadedFiles = $files;
317
-    }
318
-
319
-    /**
320
-     * Sets the given parsed body to the request
321
-     *
322
-     * @param array|object|null $data
323
-     *
324
-     * @return void
325
-     *
326
-     * @throws InvalidArgumentException
327
-     *         If the parsed body isn't valid.
328
-     */
329
-    final protected function setParsedBody($data): void
330
-    {
331
-        $this->validateParsedBody($data);
332
-
333
-        $this->parsedBody = $data;
334
-    }
335
-
336
-    /**
337
-     * Validates the given uploaded files
338
-     *
339
-     * @param array $files
340
-     *
341
-     * @return void
342
-     *
343
-     * @throws InvalidArgumentException
344
-     *         If one of the files isn't valid.
345
-     */
346
-    private function validateUploadedFiles(array $files): void
347
-    {
348
-        if ([] === $files) {
349
-            return;
350
-        }
351
-
352
-        /**
353
-         * @param mixed $file
354
-         *
355
-         * @return void
356
-         *
357
-         * @throws InvalidArgumentException
358
-         *
359
-         * @psalm-suppress MissingClosureParamType
360
-         */
361
-        array_walk_recursive($files, static function ($file): void {
362
-            if (! ($file instanceof UploadedFileInterface)) {
363
-                throw new InvalidArgumentException('Invalid uploaded files');
364
-            }
365
-        });
366
-    }
367
-
368
-    /**
369
-     * Validates the given parsed body
370
-     *
371
-     * @param mixed $data
372
-     *
373
-     * @return void
374
-     *
375
-     * @throws InvalidArgumentException
376
-     *         If the parsed body isn't valid.
377
-     */
378
-    private function validateParsedBody($data): void
379
-    {
380
-        if (null === $data) {
381
-            return;
382
-        }
383
-
384
-        if (!is_array($data) && !is_object($data)) {
385
-            throw new InvalidArgumentException('Invalid parsed body');
386
-        }
387
-    }
38
+	/**
39
+	 * The server parameters
40
+	 *
41
+	 * @var array
42
+	 */
43
+	private array $serverParams;
44
+
45
+	/**
46
+	 * The request's query parameters
47
+	 *
48
+	 * @var array
49
+	 */
50
+	private array $queryParams;
51
+
52
+	/**
53
+	 * The request's cookie parameters
54
+	 *
55
+	 * @var array
56
+	 */
57
+	private array $cookieParams;
58
+
59
+	/**
60
+	 * The request's uploaded files
61
+	 *
62
+	 * @var array
63
+	 */
64
+	private array $uploadedFiles;
65
+
66
+	/**
67
+	 * The request's parsed body
68
+	 *
69
+	 * @var array|object|null
70
+	 */
71
+	private $parsedBody;
72
+
73
+	/**
74
+	 * The request attributes
75
+	 *
76
+	 * @var array
77
+	 */
78
+	private array $attributes;
79
+
80
+	/**
81
+	 * Constructor of the class
82
+	 *
83
+	 * @param string|null $protocolVersion
84
+	 * @param string|null $method
85
+	 * @param mixed $uri
86
+	 * @param array<string, string|string[]>|null $headers
87
+	 * @param StreamInterface|null $body
88
+	 *
89
+	 * @param array $serverParams
90
+	 * @param array $queryParams
91
+	 * @param array $cookieParams
92
+	 * @param array $uploadedFiles
93
+	 * @param array|object|null $parsedBody
94
+	 * @param array $attributes
95
+	 *
96
+	 * @throws InvalidArgumentException
97
+	 *         If one of the arguments isn't valid.
98
+	 */
99
+	public function __construct(
100
+		?string $protocolVersion = null,
101
+		?string $method = null,
102
+		$uri = null,
103
+		?array $headers = null,
104
+		?StreamInterface $body = null,
105
+		array $serverParams = [],
106
+		array $queryParams = [],
107
+		array $cookieParams = [],
108
+		array $uploadedFiles = [],
109
+		$parsedBody = null,
110
+		array $attributes = []
111
+	) {
112
+		if (isset($protocolVersion)) {
113
+			$this->setProtocolVersion($protocolVersion);
114
+		}
115
+
116
+		parent::__construct($method, $uri, $headers, $body);
117
+
118
+		$this->serverParams = $serverParams;
119
+		$this->queryParams = $queryParams;
120
+		$this->cookieParams = $cookieParams;
121
+		$this->setUploadedFiles($uploadedFiles);
122
+		$this->setParsedBody($parsedBody);
123
+		$this->attributes = $attributes;
124
+	}
125
+
126
+	/**
127
+	 * Gets the server parameters
128
+	 *
129
+	 * @return array
130
+	 */
131
+	public function getServerParams(): array
132
+	{
133
+		return $this->serverParams;
134
+	}
135
+
136
+	/**
137
+	 * Gets the request's query parameters
138
+	 *
139
+	 * @return array
140
+	 */
141
+	public function getQueryParams(): array
142
+	{
143
+		return $this->queryParams;
144
+	}
145
+
146
+	/**
147
+	 * Creates a new instance of the request with the given query parameters
148
+	 *
149
+	 * @param array $query
150
+	 *
151
+	 * @return static
152
+	 */
153
+	public function withQueryParams(array $query): ServerRequestInterface
154
+	{
155
+		$clone = clone $this;
156
+		$clone->queryParams = $query;
157
+
158
+		return $clone;
159
+	}
160
+
161
+	/**
162
+	 * Gets the request's cookie parameters
163
+	 *
164
+	 * @return array
165
+	 */
166
+	public function getCookieParams(): array
167
+	{
168
+		return $this->cookieParams;
169
+	}
170
+
171
+	/**
172
+	 * Creates a new instance of the request with the given cookie parameters
173
+	 *
174
+	 * @param array $cookies
175
+	 *
176
+	 * @return static
177
+	 */
178
+	public function withCookieParams(array $cookies): ServerRequestInterface
179
+	{
180
+		$clone = clone $this;
181
+		$clone->cookieParams = $cookies;
182
+
183
+		return $clone;
184
+	}
185
+
186
+	/**
187
+	 * Gets the request's uploaded files
188
+	 *
189
+	 * @return array
190
+	 */
191
+	public function getUploadedFiles(): array
192
+	{
193
+		return $this->uploadedFiles;
194
+	}
195
+
196
+	/**
197
+	 * Creates a new instance of the request with the given uploaded files
198
+	 *
199
+	 * @param array $uploadedFiles
200
+	 *
201
+	 * @return static
202
+	 *
203
+	 * @throws InvalidArgumentException
204
+	 *         If one of the files isn't valid.
205
+	 */
206
+	public function withUploadedFiles(array $uploadedFiles): ServerRequestInterface
207
+	{
208
+		$clone = clone $this;
209
+		$clone->setUploadedFiles($uploadedFiles);
210
+
211
+		return $clone;
212
+	}
213
+
214
+	/**
215
+	 * Gets the request's parsed body
216
+	 *
217
+	 * @return array|object|null
218
+	 */
219
+	public function getParsedBody()
220
+	{
221
+		return $this->parsedBody;
222
+	}
223
+
224
+	/**
225
+	 * Creates a new instance of the request with the given parsed body
226
+	 *
227
+	 * @param array|object|null $data
228
+	 *
229
+	 * @return static
230
+	 *
231
+	 * @throws InvalidArgumentException
232
+	 *         If the data isn't valid.
233
+	 */
234
+	public function withParsedBody($data): ServerRequestInterface
235
+	{
236
+		$clone = clone $this;
237
+		$clone->setParsedBody($data);
238
+
239
+		return $clone;
240
+	}
241
+
242
+	/**
243
+	 * Gets the request attributes
244
+	 *
245
+	 * @return array
246
+	 */
247
+	public function getAttributes(): array
248
+	{
249
+		return $this->attributes;
250
+	}
251
+
252
+	/**
253
+	 * Gets the request's attribute value by the given name
254
+	 *
255
+	 * Returns the default value if the attribute wasn't found.
256
+	 *
257
+	 * @param array-key $name
258
+	 * @param mixed $default
259
+	 *
260
+	 * @return mixed
261
+	 */
262
+	public function getAttribute($name, $default = null)
263
+	{
264
+		if (!array_key_exists($name, $this->attributes)) {
265
+			return $default;
266
+		}
267
+
268
+		return $this->attributes[$name];
269
+	}
270
+
271
+	/**
272
+	 * Creates a new instance of the request with the given attribute
273
+	 *
274
+	 * @param array-key $name
275
+	 * @param mixed $value
276
+	 *
277
+	 * @return static
278
+	 */
279
+	public function withAttribute($name, $value): ServerRequestInterface
280
+	{
281
+		$clone = clone $this;
282
+		$clone->attributes[$name] = $value;
283
+
284
+		return $clone;
285
+	}
286
+
287
+	/**
288
+	 * Creates a new instance of the request without an attribute with the given name
289
+	 *
290
+	 * @param array-key $name
291
+	 *
292
+	 * @return static
293
+	 */
294
+	public function withoutAttribute($name): ServerRequestInterface
295
+	{
296
+		$clone = clone $this;
297
+		unset($clone->attributes[$name]);
298
+
299
+		return $clone;
300
+	}
301
+
302
+	/**
303
+	 * Sets the given uploaded files to the request
304
+	 *
305
+	 * @param array $files
306
+	 *
307
+	 * @return void
308
+	 *
309
+	 * @throws InvalidArgumentException
310
+	 *         If one of the files isn't valid.
311
+	 */
312
+	final protected function setUploadedFiles(array $files): void
313
+	{
314
+		$this->validateUploadedFiles($files);
315
+
316
+		$this->uploadedFiles = $files;
317
+	}
318
+
319
+	/**
320
+	 * Sets the given parsed body to the request
321
+	 *
322
+	 * @param array|object|null $data
323
+	 *
324
+	 * @return void
325
+	 *
326
+	 * @throws InvalidArgumentException
327
+	 *         If the parsed body isn't valid.
328
+	 */
329
+	final protected function setParsedBody($data): void
330
+	{
331
+		$this->validateParsedBody($data);
332
+
333
+		$this->parsedBody = $data;
334
+	}
335
+
336
+	/**
337
+	 * Validates the given uploaded files
338
+	 *
339
+	 * @param array $files
340
+	 *
341
+	 * @return void
342
+	 *
343
+	 * @throws InvalidArgumentException
344
+	 *         If one of the files isn't valid.
345
+	 */
346
+	private function validateUploadedFiles(array $files): void
347
+	{
348
+		if ([] === $files) {
349
+			return;
350
+		}
351
+
352
+		/**
353
+		 * @param mixed $file
354
+		 *
355
+		 * @return void
356
+		 *
357
+		 * @throws InvalidArgumentException
358
+		 *
359
+		 * @psalm-suppress MissingClosureParamType
360
+		 */
361
+		array_walk_recursive($files, static function ($file): void {
362
+			if (! ($file instanceof UploadedFileInterface)) {
363
+				throw new InvalidArgumentException('Invalid uploaded files');
364
+			}
365
+		});
366
+	}
367
+
368
+	/**
369
+	 * Validates the given parsed body
370
+	 *
371
+	 * @param mixed $data
372
+	 *
373
+	 * @return void
374
+	 *
375
+	 * @throws InvalidArgumentException
376
+	 *         If the parsed body isn't valid.
377
+	 */
378
+	private function validateParsedBody($data): void
379
+	{
380
+		if (null === $data) {
381
+			return;
382
+		}
383
+
384
+		if (!is_array($data) && !is_object($data)) {
385
+			throw new InvalidArgumentException('Invalid parsed body');
386
+		}
387
+	}
388 388
 }
Please login to merge, or discard this patch.
src/UploadedFileFactory.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -31,22 +31,22 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.