Test Failed
Pull Request — master (#31)
by Anatoly
33:35 queued 29:37
created
src/Uri.php 1 patch
Indentation   +474 added lines, -474 removed lines patch added patch discarded remove patch
@@ -41,478 +41,478 @@
 block discarded – undo
41 41
 class Uri implements UriInterface
42 42
 {
43 43
 
44
-    /**
45
-     * Scheme of the URI
46
-     *
47
-     * @var string
48
-     */
49
-    private string $scheme = '';
50
-
51
-    /**
52
-     * User Information of the URI
53
-     *
54
-     * @var string
55
-     */
56
-    private string $userInfo = '';
57
-
58
-    /**
59
-     * Host of the URI
60
-     *
61
-     * @var string
62
-     */
63
-    private string $host = '';
64
-
65
-    /**
66
-     * Port of the URI
67
-     *
68
-     * @var int|null
69
-     */
70
-    private ?int $port = null;
71
-
72
-    /**
73
-     * Path of the URI
74
-     *
75
-     * @var string
76
-     */
77
-    private string $path = '';
78
-
79
-    /**
80
-     * Query of the URI
81
-     *
82
-     * @var string
83
-     */
84
-    private string $query = '';
85
-
86
-    /**
87
-     * Fragment of the URI
88
-     *
89
-     * @var string
90
-     */
91
-    private string $fragment = '';
92
-
93
-    /**
94
-     * Constructor of the class
95
-     *
96
-     * @param string $uri
97
-     *
98
-     * @throws InvalidArgumentException
99
-     *         If the URI isn't valid.
100
-     */
101
-    public function __construct(string $uri = '')
102
-    {
103
-        if ($uri === '') {
104
-            return;
105
-        }
106
-
107
-        $components = parse_url($uri);
108
-        if ($components === false) {
109
-            throw new InvalidArgumentException('Unable to parse URI');
110
-        }
111
-
112
-        if (isset($components['scheme'])) {
113
-            $this->setScheme($components['scheme']);
114
-        }
115
-
116
-        if (isset($components['user'])) {
117
-            $this->setUserInfo(
118
-                $components['user'],
119
-                $components['pass'] ?? null
120
-            );
121
-        }
122
-
123
-        if (isset($components['host'])) {
124
-            $this->setHost($components['host']);
125
-        }
126
-
127
-        if (isset($components['port'])) {
128
-            $this->setPort($components['port']);
129
-        }
130
-
131
-        if (isset($components['path'])) {
132
-            $this->setPath($components['path']);
133
-        }
134
-
135
-        if (isset($components['query'])) {
136
-            $this->setQuery($components['query']);
137
-        }
138
-
139
-        if (isset($components['fragment'])) {
140
-            $this->setFragment($components['fragment']);
141
-        }
142
-    }
143
-
144
-    /**
145
-     * Creates a URI
146
-     *
147
-     * @param mixed $uri
148
-     *
149
-     * @return UriInterface
150
-     *
151
-     * @throws InvalidArgumentException
152
-     *         If the URI isn't valid.
153
-     */
154
-    public static function create($uri): UriInterface
155
-    {
156
-        if ($uri instanceof UriInterface) {
157
-            return $uri;
158
-        }
159
-
160
-        if (!is_string($uri)) {
161
-            throw new InvalidArgumentException('URI should be a string');
162
-        }
163
-
164
-        return new self($uri);
165
-    }
166
-
167
-    /**
168
-     * {@inheritdoc}
169
-     *
170
-     * @throws InvalidArgumentException
171
-     *         If the scheme isn't valid.
172
-     */
173
-    public function withScheme($scheme): UriInterface
174
-    {
175
-        $clone = clone $this;
176
-        $clone->setScheme($scheme);
177
-
178
-        return $clone;
179
-    }
180
-
181
-    /**
182
-     * {@inheritdoc}
183
-     *
184
-     * @throws InvalidArgumentException
185
-     *         If the user information isn't valid.
186
-     */
187
-    public function withUserInfo($user, $password = null): UriInterface
188
-    {
189
-        $clone = clone $this;
190
-        $clone->setUserInfo($user, $password);
191
-
192
-        return $clone;
193
-    }
194
-
195
-    /**
196
-     * {@inheritdoc}
197
-     *
198
-     * @throws InvalidArgumentException
199
-     *         If the host isn't valid.
200
-     */
201
-    public function withHost($host): UriInterface
202
-    {
203
-        $clone = clone $this;
204
-        $clone->setHost($host);
205
-
206
-        return $clone;
207
-    }
208
-
209
-    /**
210
-     * {@inheritdoc}
211
-     *
212
-     * @throws InvalidArgumentException
213
-     *         If the port isn't valid.
214
-     */
215
-    public function withPort($port): UriInterface
216
-    {
217
-        $clone = clone $this;
218
-        $clone->setPort($port);
219
-
220
-        return $clone;
221
-    }
222
-
223
-    /**
224
-     * {@inheritdoc}
225
-     *
226
-     * @throws InvalidArgumentException
227
-     *         If the path isn't valid.
228
-     */
229
-    public function withPath($path): UriInterface
230
-    {
231
-        $clone = clone $this;
232
-        $clone->setPath($path);
233
-
234
-        return $clone;
235
-    }
236
-
237
-    /**
238
-     * {@inheritdoc}
239
-     *
240
-     * @throws InvalidArgumentException
241
-     *         If the query isn't valid.
242
-     */
243
-    public function withQuery($query): UriInterface
244
-    {
245
-        $clone = clone $this;
246
-        $clone->setQuery($query);
247
-
248
-        return $clone;
249
-    }
250
-
251
-    /**
252
-     * {@inheritdoc}
253
-     *
254
-     * @throws InvalidArgumentException
255
-     *         If the fragment isn't valid.
256
-     */
257
-    public function withFragment($fragment): UriInterface
258
-    {
259
-        $clone = clone $this;
260
-        $clone->setFragment($fragment);
261
-
262
-        return $clone;
263
-    }
264
-
265
-    /**
266
-     * {@inheritdoc}
267
-     */
268
-    public function getScheme(): string
269
-    {
270
-        return $this->scheme;
271
-    }
272
-
273
-    /**
274
-     * {@inheritdoc}
275
-     */
276
-    public function getUserInfo(): string
277
-    {
278
-        return $this->userInfo;
279
-    }
280
-
281
-    /**
282
-     * {@inheritdoc}
283
-     */
284
-    public function getHost(): string
285
-    {
286
-        return $this->host;
287
-    }
288
-
289
-    /**
290
-     * {@inheritdoc}
291
-     */
292
-    public function getPort(): ?int
293
-    {
294
-        // The 80 is the default port number for the HTTP protocol.
295
-        if ($this->port === 80 && $this->scheme === 'http') {
296
-            return null;
297
-        }
298
-
299
-        // The 443 is the default port number for the HTTPS protocol.
300
-        if ($this->port === 443 && $this->scheme === 'https') {
301
-            return null;
302
-        }
303
-
304
-        return $this->port;
305
-    }
306
-
307
-    /**
308
-     * {@inheritdoc}
309
-     */
310
-    public function getPath(): string
311
-    {
312
-        // CVE-2015-3257
313
-        if (strncmp($this->path, '//', 2) === 0) {
314
-            return '/' . ltrim($this->path, '/');
315
-        }
316
-
317
-        return $this->path;
318
-    }
319
-
320
-    /**
321
-     * {@inheritdoc}
322
-     */
323
-    public function getQuery(): string
324
-    {
325
-        return $this->query;
326
-    }
327
-
328
-    /**
329
-     * {@inheritdoc}
330
-     */
331
-    public function getFragment(): string
332
-    {
333
-        return $this->fragment;
334
-    }
335
-
336
-    /**
337
-     * {@inheritdoc}
338
-     */
339
-    public function getAuthority(): string
340
-    {
341
-        // The host is the basic subcomponent.
342
-        if ($this->host === '') {
343
-            return '';
344
-        }
345
-
346
-        $authority = $this->host;
347
-        if ($this->userInfo !== '') {
348
-            $authority = $this->userInfo . '@' . $authority;
349
-        }
350
-
351
-        $port = $this->getPort();
352
-        if ($port !== null) {
353
-            $authority = $authority . ':' . $port;
354
-        }
355
-
356
-        return $authority;
357
-    }
358
-
359
-    /**
360
-     * {@inheritdoc}
361
-     */
362
-    public function __toString(): string
363
-    {
364
-        $uri = '';
365
-
366
-        $scheme = $this->scheme;
367
-        if ($scheme !== '') {
368
-            $uri .= $scheme . ':';
369
-        }
370
-
371
-        $authority = $this->getAuthority();
372
-        if ($authority !== '') {
373
-            $uri .= '//' . $authority;
374
-        }
375
-
376
-        $path = $this->path;
377
-        if ($path !== '') {
378
-            // https://github.com/sunrise-php/uri/issues/31
379
-            // https://datatracker.ietf.org/doc/html/rfc3986#section-3.3
380
-            //
381
-            // If a URI contains an authority component,
382
-            // then the path component must either be empty
383
-            // or begin with a slash ("/") character.
384
-            if ($authority !== '' && strncmp($path, '/', 1) !== 0) {
385
-                $path = '/' . $path;
386
-            }
387
-
388
-            // https://github.com/sunrise-php/uri/issues/31
389
-            // https://datatracker.ietf.org/doc/html/rfc3986#section-3.3
390
-            //
391
-            // If a URI does not contain an authority component,
392
-            // then the path cannot begin with two slash characters ("//").
393
-            if ($authority === '' && strncmp($path, '//', 2) === 0) {
394
-                $path = '/' . ltrim($path, '/');
395
-            }
396
-
397
-            $uri .= $path;
398
-        }
399
-
400
-        $query = $this->query;
401
-        if ($query !== '') {
402
-            $uri .= '?' . $query;
403
-        }
404
-
405
-        $fragment = $this->fragment;
406
-        if ($fragment !== '') {
407
-            $uri .= '#' . $fragment;
408
-        }
409
-
410
-        return $uri;
411
-    }
412
-
413
-    /**
414
-     * Sets the given scheme to the URI
415
-     *
416
-     * @param mixed $scheme
417
-     *
418
-     * @return void
419
-     *
420
-     * @throws InvalidArgumentException
421
-     *         If the scheme isn't valid.
422
-     */
423
-    final protected function setScheme($scheme): void
424
-    {
425
-        $this->scheme = (new Scheme($scheme))->getValue();
426
-    }
427
-
428
-    /**
429
-     * Sets the given user information to the URI
430
-     *
431
-     * @param mixed $user
432
-     * @param mixed $password
433
-     *
434
-     * @return void
435
-     *
436
-     * @throws InvalidArgumentException
437
-     *         If the user information isn't valid.
438
-     */
439
-    final protected function setUserInfo($user, $password): void
440
-    {
441
-        $this->userInfo = (new UserInfo($user, $password))->getValue();
442
-    }
443
-
444
-    /**
445
-     * Sets the given host to the URI
446
-     *
447
-     * @param mixed $host
448
-     *
449
-     * @return void
450
-     *
451
-     * @throws InvalidArgumentException
452
-     *         If the host isn't valid.
453
-     */
454
-    final protected function setHost($host): void
455
-    {
456
-        $this->host = (new Host($host))->getValue();
457
-    }
458
-
459
-    /**
460
-     * Sets the given port to the URI
461
-     *
462
-     * @param mixed $port
463
-     *
464
-     * @return void
465
-     *
466
-     * @throws InvalidArgumentException
467
-     *         If the port isn't valid.
468
-     */
469
-    final protected function setPort($port): void
470
-    {
471
-        $this->port = (new Port($port))->getValue();
472
-    }
473
-
474
-    /**
475
-     * Sets the given path to the URI
476
-     *
477
-     * @param mixed $path
478
-     *
479
-     * @return void
480
-     *
481
-     * @throws InvalidArgumentException
482
-     *         If the path isn't valid.
483
-     */
484
-    final protected function setPath($path): void
485
-    {
486
-        $this->path = (new Path($path))->getValue();
487
-    }
488
-
489
-    /**
490
-     * Sets the given query to the URI
491
-     *
492
-     * @param mixed $query
493
-     *
494
-     * @return void
495
-     *
496
-     * @throws InvalidArgumentException
497
-     *         If the query isn't valid.
498
-     */
499
-    final protected function setQuery($query): void
500
-    {
501
-        $this->query = (new Query($query))->getValue();
502
-    }
503
-
504
-    /**
505
-     * Sets the given fragment to the URI
506
-     *
507
-     * @param mixed $fragment
508
-     *
509
-     * @return void
510
-     *
511
-     * @throws InvalidArgumentException
512
-     *         If the fragment isn't valid.
513
-     */
514
-    final protected function setFragment($fragment): void
515
-    {
516
-        $this->fragment = (new Fragment($fragment))->getValue();
517
-    }
44
+	/**
45
+	 * Scheme of the URI
46
+	 *
47
+	 * @var string
48
+	 */
49
+	private string $scheme = '';
50
+
51
+	/**
52
+	 * User Information of the URI
53
+	 *
54
+	 * @var string
55
+	 */
56
+	private string $userInfo = '';
57
+
58
+	/**
59
+	 * Host of the URI
60
+	 *
61
+	 * @var string
62
+	 */
63
+	private string $host = '';
64
+
65
+	/**
66
+	 * Port of the URI
67
+	 *
68
+	 * @var int|null
69
+	 */
70
+	private ?int $port = null;
71
+
72
+	/**
73
+	 * Path of the URI
74
+	 *
75
+	 * @var string
76
+	 */
77
+	private string $path = '';
78
+
79
+	/**
80
+	 * Query of the URI
81
+	 *
82
+	 * @var string
83
+	 */
84
+	private string $query = '';
85
+
86
+	/**
87
+	 * Fragment of the URI
88
+	 *
89
+	 * @var string
90
+	 */
91
+	private string $fragment = '';
92
+
93
+	/**
94
+	 * Constructor of the class
95
+	 *
96
+	 * @param string $uri
97
+	 *
98
+	 * @throws InvalidArgumentException
99
+	 *         If the URI isn't valid.
100
+	 */
101
+	public function __construct(string $uri = '')
102
+	{
103
+		if ($uri === '') {
104
+			return;
105
+		}
106
+
107
+		$components = parse_url($uri);
108
+		if ($components === false) {
109
+			throw new InvalidArgumentException('Unable to parse URI');
110
+		}
111
+
112
+		if (isset($components['scheme'])) {
113
+			$this->setScheme($components['scheme']);
114
+		}
115
+
116
+		if (isset($components['user'])) {
117
+			$this->setUserInfo(
118
+				$components['user'],
119
+				$components['pass'] ?? null
120
+			);
121
+		}
122
+
123
+		if (isset($components['host'])) {
124
+			$this->setHost($components['host']);
125
+		}
126
+
127
+		if (isset($components['port'])) {
128
+			$this->setPort($components['port']);
129
+		}
130
+
131
+		if (isset($components['path'])) {
132
+			$this->setPath($components['path']);
133
+		}
134
+
135
+		if (isset($components['query'])) {
136
+			$this->setQuery($components['query']);
137
+		}
138
+
139
+		if (isset($components['fragment'])) {
140
+			$this->setFragment($components['fragment']);
141
+		}
142
+	}
143
+
144
+	/**
145
+	 * Creates a URI
146
+	 *
147
+	 * @param mixed $uri
148
+	 *
149
+	 * @return UriInterface
150
+	 *
151
+	 * @throws InvalidArgumentException
152
+	 *         If the URI isn't valid.
153
+	 */
154
+	public static function create($uri): UriInterface
155
+	{
156
+		if ($uri instanceof UriInterface) {
157
+			return $uri;
158
+		}
159
+
160
+		if (!is_string($uri)) {
161
+			throw new InvalidArgumentException('URI should be a string');
162
+		}
163
+
164
+		return new self($uri);
165
+	}
166
+
167
+	/**
168
+	 * {@inheritdoc}
169
+	 *
170
+	 * @throws InvalidArgumentException
171
+	 *         If the scheme isn't valid.
172
+	 */
173
+	public function withScheme($scheme): UriInterface
174
+	{
175
+		$clone = clone $this;
176
+		$clone->setScheme($scheme);
177
+
178
+		return $clone;
179
+	}
180
+
181
+	/**
182
+	 * {@inheritdoc}
183
+	 *
184
+	 * @throws InvalidArgumentException
185
+	 *         If the user information isn't valid.
186
+	 */
187
+	public function withUserInfo($user, $password = null): UriInterface
188
+	{
189
+		$clone = clone $this;
190
+		$clone->setUserInfo($user, $password);
191
+
192
+		return $clone;
193
+	}
194
+
195
+	/**
196
+	 * {@inheritdoc}
197
+	 *
198
+	 * @throws InvalidArgumentException
199
+	 *         If the host isn't valid.
200
+	 */
201
+	public function withHost($host): UriInterface
202
+	{
203
+		$clone = clone $this;
204
+		$clone->setHost($host);
205
+
206
+		return $clone;
207
+	}
208
+
209
+	/**
210
+	 * {@inheritdoc}
211
+	 *
212
+	 * @throws InvalidArgumentException
213
+	 *         If the port isn't valid.
214
+	 */
215
+	public function withPort($port): UriInterface
216
+	{
217
+		$clone = clone $this;
218
+		$clone->setPort($port);
219
+
220
+		return $clone;
221
+	}
222
+
223
+	/**
224
+	 * {@inheritdoc}
225
+	 *
226
+	 * @throws InvalidArgumentException
227
+	 *         If the path isn't valid.
228
+	 */
229
+	public function withPath($path): UriInterface
230
+	{
231
+		$clone = clone $this;
232
+		$clone->setPath($path);
233
+
234
+		return $clone;
235
+	}
236
+
237
+	/**
238
+	 * {@inheritdoc}
239
+	 *
240
+	 * @throws InvalidArgumentException
241
+	 *         If the query isn't valid.
242
+	 */
243
+	public function withQuery($query): UriInterface
244
+	{
245
+		$clone = clone $this;
246
+		$clone->setQuery($query);
247
+
248
+		return $clone;
249
+	}
250
+
251
+	/**
252
+	 * {@inheritdoc}
253
+	 *
254
+	 * @throws InvalidArgumentException
255
+	 *         If the fragment isn't valid.
256
+	 */
257
+	public function withFragment($fragment): UriInterface
258
+	{
259
+		$clone = clone $this;
260
+		$clone->setFragment($fragment);
261
+
262
+		return $clone;
263
+	}
264
+
265
+	/**
266
+	 * {@inheritdoc}
267
+	 */
268
+	public function getScheme(): string
269
+	{
270
+		return $this->scheme;
271
+	}
272
+
273
+	/**
274
+	 * {@inheritdoc}
275
+	 */
276
+	public function getUserInfo(): string
277
+	{
278
+		return $this->userInfo;
279
+	}
280
+
281
+	/**
282
+	 * {@inheritdoc}
283
+	 */
284
+	public function getHost(): string
285
+	{
286
+		return $this->host;
287
+	}
288
+
289
+	/**
290
+	 * {@inheritdoc}
291
+	 */
292
+	public function getPort(): ?int
293
+	{
294
+		// The 80 is the default port number for the HTTP protocol.
295
+		if ($this->port === 80 && $this->scheme === 'http') {
296
+			return null;
297
+		}
298
+
299
+		// The 443 is the default port number for the HTTPS protocol.
300
+		if ($this->port === 443 && $this->scheme === 'https') {
301
+			return null;
302
+		}
303
+
304
+		return $this->port;
305
+	}
306
+
307
+	/**
308
+	 * {@inheritdoc}
309
+	 */
310
+	public function getPath(): string
311
+	{
312
+		// CVE-2015-3257
313
+		if (strncmp($this->path, '//', 2) === 0) {
314
+			return '/' . ltrim($this->path, '/');
315
+		}
316
+
317
+		return $this->path;
318
+	}
319
+
320
+	/**
321
+	 * {@inheritdoc}
322
+	 */
323
+	public function getQuery(): string
324
+	{
325
+		return $this->query;
326
+	}
327
+
328
+	/**
329
+	 * {@inheritdoc}
330
+	 */
331
+	public function getFragment(): string
332
+	{
333
+		return $this->fragment;
334
+	}
335
+
336
+	/**
337
+	 * {@inheritdoc}
338
+	 */
339
+	public function getAuthority(): string
340
+	{
341
+		// The host is the basic subcomponent.
342
+		if ($this->host === '') {
343
+			return '';
344
+		}
345
+
346
+		$authority = $this->host;
347
+		if ($this->userInfo !== '') {
348
+			$authority = $this->userInfo . '@' . $authority;
349
+		}
350
+
351
+		$port = $this->getPort();
352
+		if ($port !== null) {
353
+			$authority = $authority . ':' . $port;
354
+		}
355
+
356
+		return $authority;
357
+	}
358
+
359
+	/**
360
+	 * {@inheritdoc}
361
+	 */
362
+	public function __toString(): string
363
+	{
364
+		$uri = '';
365
+
366
+		$scheme = $this->scheme;
367
+		if ($scheme !== '') {
368
+			$uri .= $scheme . ':';
369
+		}
370
+
371
+		$authority = $this->getAuthority();
372
+		if ($authority !== '') {
373
+			$uri .= '//' . $authority;
374
+		}
375
+
376
+		$path = $this->path;
377
+		if ($path !== '') {
378
+			// https://github.com/sunrise-php/uri/issues/31
379
+			// https://datatracker.ietf.org/doc/html/rfc3986#section-3.3
380
+			//
381
+			// If a URI contains an authority component,
382
+			// then the path component must either be empty
383
+			// or begin with a slash ("/") character.
384
+			if ($authority !== '' && strncmp($path, '/', 1) !== 0) {
385
+				$path = '/' . $path;
386
+			}
387
+
388
+			// https://github.com/sunrise-php/uri/issues/31
389
+			// https://datatracker.ietf.org/doc/html/rfc3986#section-3.3
390
+			//
391
+			// If a URI does not contain an authority component,
392
+			// then the path cannot begin with two slash characters ("//").
393
+			if ($authority === '' && strncmp($path, '//', 2) === 0) {
394
+				$path = '/' . ltrim($path, '/');
395
+			}
396
+
397
+			$uri .= $path;
398
+		}
399
+
400
+		$query = $this->query;
401
+		if ($query !== '') {
402
+			$uri .= '?' . $query;
403
+		}
404
+
405
+		$fragment = $this->fragment;
406
+		if ($fragment !== '') {
407
+			$uri .= '#' . $fragment;
408
+		}
409
+
410
+		return $uri;
411
+	}
412
+
413
+	/**
414
+	 * Sets the given scheme to the URI
415
+	 *
416
+	 * @param mixed $scheme
417
+	 *
418
+	 * @return void
419
+	 *
420
+	 * @throws InvalidArgumentException
421
+	 *         If the scheme isn't valid.
422
+	 */
423
+	final protected function setScheme($scheme): void
424
+	{
425
+		$this->scheme = (new Scheme($scheme))->getValue();
426
+	}
427
+
428
+	/**
429
+	 * Sets the given user information to the URI
430
+	 *
431
+	 * @param mixed $user
432
+	 * @param mixed $password
433
+	 *
434
+	 * @return void
435
+	 *
436
+	 * @throws InvalidArgumentException
437
+	 *         If the user information isn't valid.
438
+	 */
439
+	final protected function setUserInfo($user, $password): void
440
+	{
441
+		$this->userInfo = (new UserInfo($user, $password))->getValue();
442
+	}
443
+
444
+	/**
445
+	 * Sets the given host to the URI
446
+	 *
447
+	 * @param mixed $host
448
+	 *
449
+	 * @return void
450
+	 *
451
+	 * @throws InvalidArgumentException
452
+	 *         If the host isn't valid.
453
+	 */
454
+	final protected function setHost($host): void
455
+	{
456
+		$this->host = (new Host($host))->getValue();
457
+	}
458
+
459
+	/**
460
+	 * Sets the given port to the URI
461
+	 *
462
+	 * @param mixed $port
463
+	 *
464
+	 * @return void
465
+	 *
466
+	 * @throws InvalidArgumentException
467
+	 *         If the port isn't valid.
468
+	 */
469
+	final protected function setPort($port): void
470
+	{
471
+		$this->port = (new Port($port))->getValue();
472
+	}
473
+
474
+	/**
475
+	 * Sets the given path to the URI
476
+	 *
477
+	 * @param mixed $path
478
+	 *
479
+	 * @return void
480
+	 *
481
+	 * @throws InvalidArgumentException
482
+	 *         If the path isn't valid.
483
+	 */
484
+	final protected function setPath($path): void
485
+	{
486
+		$this->path = (new Path($path))->getValue();
487
+	}
488
+
489
+	/**
490
+	 * Sets the given query to the URI
491
+	 *
492
+	 * @param mixed $query
493
+	 *
494
+	 * @return void
495
+	 *
496
+	 * @throws InvalidArgumentException
497
+	 *         If the query isn't valid.
498
+	 */
499
+	final protected function setQuery($query): void
500
+	{
501
+		$this->query = (new Query($query))->getValue();
502
+	}
503
+
504
+	/**
505
+	 * Sets the given fragment to the URI
506
+	 *
507
+	 * @param mixed $fragment
508
+	 *
509
+	 * @return void
510
+	 *
511
+	 * @throws InvalidArgumentException
512
+	 *         If the fragment isn't valid.
513
+	 */
514
+	final protected function setFragment($fragment): void
515
+	{
516
+		$this->fragment = (new Fragment($fragment))->getValue();
517
+	}
518 518
 }
Please login to merge, or discard this patch.
src/Message.php 1 patch
Indentation   +390 added lines, -390 removed lines patch added patch discarded remove patch
@@ -39,394 +39,394 @@
 block discarded – undo
39 39
 abstract class Message implements MessageInterface
40 40
 {
41 41
 
42
-    /**
43
-     * Supported HTTP versions
44
-     *
45
-     * @var list<string>
46
-     */
47
-    public const SUPPORTED_HTTP_VERSIONS = ['1.0', '1.1', '2.0', '2'];
48
-
49
-    /**
50
-     * Default HTTP version
51
-     *
52
-     * @var string
53
-     */
54
-    public const DEFAULT_HTTP_VERSION = '1.1';
55
-
56
-    /**
57
-     * The message HTTP version
58
-     *
59
-     * @var string
60
-     */
61
-    private string $protocolVersion = self::DEFAULT_HTTP_VERSION;
62
-
63
-    /**
64
-     * The message headers
65
-     *
66
-     * @var array<string, list<string>>
67
-     */
68
-    private array $headers = [];
69
-
70
-    /**
71
-     * Original header names (see $headers)
72
-     *
73
-     * @var array<string, string>
74
-     */
75
-    private array $headerNames = [];
76
-
77
-    /**
78
-     * The message body
79
-     *
80
-     * @var StreamInterface|null
81
-     */
82
-    private ?StreamInterface $body = null;
83
-
84
-    /**
85
-     * Gets the message HTTP version
86
-     *
87
-     * @return string
88
-     */
89
-    public function getProtocolVersion(): string
90
-    {
91
-        return $this->protocolVersion;
92
-    }
93
-
94
-    /**
95
-     * Creates a new instance of the message with the given HTTP version
96
-     *
97
-     * @param string $version
98
-     *
99
-     * @return static
100
-     *
101
-     * @throws InvalidArgumentException
102
-     *         If the HTTP version isn't valid.
103
-     */
104
-    public function withProtocolVersion($version): MessageInterface
105
-    {
106
-        $clone = clone $this;
107
-        $clone->setProtocolVersion($version);
108
-
109
-        return $clone;
110
-    }
111
-
112
-    /**
113
-     * Gets the message headers
114
-     *
115
-     * @return array<string, list<string>>
116
-     */
117
-    public function getHeaders(): array
118
-    {
119
-        return $this->headers;
120
-    }
121
-
122
-    /**
123
-     * Checks if a header exists in the message by the given name
124
-     *
125
-     * @param string $name
126
-     *
127
-     * @return bool
128
-     */
129
-    public function hasHeader($name): bool
130
-    {
131
-        $key = strtolower($name);
132
-
133
-        return isset($this->headerNames[$key]);
134
-    }
135
-
136
-    /**
137
-     * Gets a header value(s) from the message by the given name
138
-     *
139
-     * @param string $name
140
-     *
141
-     * @return list<string>
142
-     */
143
-    public function getHeader($name): array
144
-    {
145
-        $key = strtolower($name);
146
-
147
-        if (!isset($this->headerNames[$key])) {
148
-            return [];
149
-        }
150
-
151
-        return $this->headers[$this->headerNames[$key]];
152
-    }
153
-
154
-    /**
155
-     * Gets a header value as a string from the message by the given name
156
-     *
157
-     * @param string $name
158
-     *
159
-     * @return string
160
-     */
161
-    public function getHeaderLine($name): string
162
-    {
163
-        $key = strtolower($name);
164
-
165
-        if (!isset($this->headerNames[$key])) {
166
-            return '';
167
-        }
168
-
169
-        return implode(',', $this->headers[$this->headerNames[$key]]);
170
-    }
171
-
172
-    /**
173
-     * Creates a new instance of the message with the given header overwriting the old header
174
-     *
175
-     * @param string $name
176
-     * @param string|string[] $value
177
-     *
178
-     * @return static
179
-     *
180
-     * @throws InvalidArgumentException
181
-     *         If the header isn't valid.
182
-     */
183
-    public function withHeader($name, $value): MessageInterface
184
-    {
185
-        $clone = clone $this;
186
-        $clone->setHeader($name, $value, true);
187
-
188
-        return $clone;
189
-    }
190
-
191
-    /**
192
-     * Creates a new instance of the message with the given header NOT overwriting the old header
193
-     *
194
-     * @param string $name
195
-     * @param string|string[] $value
196
-     *
197
-     * @return static
198
-     *
199
-     * @throws InvalidArgumentException
200
-     *         If the header isn't valid.
201
-     */
202
-    public function withAddedHeader($name, $value): MessageInterface
203
-    {
204
-        $clone = clone $this;
205
-        $clone->setHeader($name, $value, false);
206
-
207
-        return $clone;
208
-    }
209
-
210
-    /**
211
-     * Creates a new instance of the message without a header by the given name
212
-     *
213
-     * @param string $name
214
-     *
215
-     * @return static
216
-     */
217
-    public function withoutHeader($name): MessageInterface
218
-    {
219
-        $clone = clone $this;
220
-        $clone->deleteHeader($name);
221
-
222
-        return $clone;
223
-    }
224
-
225
-    /**
226
-     * Gets the message body
227
-     *
228
-     * @return StreamInterface
229
-     */
230
-    public function getBody(): StreamInterface
231
-    {
232
-        return $this->body ??= new PhpTempStream();
233
-    }
234
-
235
-    /**
236
-     * Creates a new instance of the message with the given body
237
-     *
238
-     * @param StreamInterface $body
239
-     *
240
-     * @return static
241
-     */
242
-    public function withBody(StreamInterface $body): MessageInterface
243
-    {
244
-        $clone = clone $this;
245
-        $clone->setBody($body);
246
-
247
-        return $clone;
248
-    }
249
-
250
-    /**
251
-     * Sets the given HTTP version to the message
252
-     *
253
-     * @param string $protocolVersion
254
-     *
255
-     * @return void
256
-     *
257
-     * @throws InvalidArgumentException
258
-     *         If the HTTP version isn't valid.
259
-     */
260
-    final protected function setProtocolVersion($protocolVersion): void
261
-    {
262
-        $this->validateProtocolVersion($protocolVersion);
263
-
264
-        $this->protocolVersion = $protocolVersion;
265
-    }
266
-
267
-    /**
268
-     * Sets a new header to the message with the given name and value(s)
269
-     *
270
-     * @param string $name
271
-     * @param string|string[] $value
272
-     * @param bool $replace
273
-     *
274
-     * @return void
275
-     *
276
-     * @throws InvalidArgumentException
277
-     *         If the header isn't valid.
278
-     */
279
-    final protected function setHeader($name, $value, bool $replace = true): void
280
-    {
281
-        if (!is_array($value)) {
282
-            $value = [$value];
283
-        }
284
-
285
-        $this->validateHeaderName($name);
286
-        $this->validateHeaderValue($name, $value);
287
-
288
-        if ($replace) {
289
-            $this->deleteHeader($name);
290
-        }
291
-
292
-        $key = strtolower($name);
293
-
294
-        $this->headerNames[$key] ??= $name;
295
-        $this->headers[$this->headerNames[$key]] ??= [];
296
-
297
-        foreach ($value as $item) {
298
-            $this->headers[$this->headerNames[$key]][] = $item;
299
-        }
300
-    }
301
-
302
-    /**
303
-     * Sets the given headers to the message
304
-     *
305
-     * @param array<string, string|string[]> $headers
306
-     *
307
-     * @return void
308
-     *
309
-     * @throws InvalidArgumentException
310
-     *         If one of the headers isn't valid.
311
-     */
312
-    final protected function setHeaders(array $headers): void
313
-    {
314
-        foreach ($headers as $name => $value) {
315
-            $this->setHeader($name, $value, false);
316
-        }
317
-    }
318
-
319
-    /**
320
-     * Deletes a header from the message by the given name
321
-     *
322
-     * @param string $name
323
-     *
324
-     * @return void
325
-     */
326
-    final protected function deleteHeader($name): void
327
-    {
328
-        $key = strtolower($name);
329
-
330
-        if (isset($this->headerNames[$key])) {
331
-            unset($this->headers[$this->headerNames[$key]]);
332
-            unset($this->headerNames[$key]);
333
-        }
334
-    }
335
-
336
-    /**
337
-     * Sets the given body to the message
338
-     *
339
-     * @param StreamInterface $body
340
-     *
341
-     * @return void
342
-     */
343
-    final protected function setBody(StreamInterface $body): void
344
-    {
345
-        $this->body = $body;
346
-    }
347
-
348
-    /**
349
-     * Validates the given HTTP version
350
-     *
351
-     * @param mixed $protocolVersion
352
-     *
353
-     * @return void
354
-     *
355
-     * @throws InvalidArgumentException
356
-     *         If the HTTP version isn't valid.
357
-     */
358
-    private function validateProtocolVersion($protocolVersion): void
359
-    {
360
-        if (!in_array($protocolVersion, self::SUPPORTED_HTTP_VERSIONS, true)) {
361
-            throw new InvalidArgumentException('Invalid or unsupported HTTP version');
362
-        }
363
-    }
364
-
365
-    /**
366
-     * Validates the given header name
367
-     *
368
-     * @param mixed $name
369
-     *
370
-     * @return void
371
-     *
372
-     * @throws InvalidArgumentException
373
-     *         If the header name isn't valid.
374
-     */
375
-    private function validateHeaderName($name): void
376
-    {
377
-        if ($name === '') {
378
-            throw new InvalidArgumentException('HTTP header name cannot be an empty');
379
-        }
380
-
381
-        if (!is_string($name)) {
382
-            throw new InvalidArgumentException('HTTP header name must be a string');
383
-        }
384
-
385
-        if (!preg_match(HeaderInterface::RFC7230_TOKEN_REGEX, $name)) {
386
-            throw new InvalidArgumentException('HTTP header name is invalid');
387
-        }
388
-    }
389
-
390
-    /**
391
-     * Validates the given header value
392
-     *
393
-     * @param string $name
394
-     * @param array $value
395
-     *
396
-     * @return void
397
-     *
398
-     * @throws InvalidArgumentException
399
-     *         If the header value isn't valid.
400
-     */
401
-    private function validateHeaderValue(string $name, array $value): void
402
-    {
403
-        if ([] === $value) {
404
-            throw new InvalidArgumentException(sprintf(
405
-                'The "%s" HTTP header value cannot be an empty array',
406
-                $name,
407
-            ));
408
-        }
409
-
410
-        foreach ($value as $key => $item) {
411
-            if ('' === $item) {
412
-                continue;
413
-            }
414
-
415
-            if (!is_string($item)) {
416
-                throw new InvalidArgumentException(sprintf(
417
-                    'The "%s[%s]" HTTP header value must be a string',
418
-                    $name,
419
-                    $key
420
-                ));
421
-            }
422
-
423
-            if (!preg_match(HeaderInterface::RFC7230_FIELD_VALUE_REGEX, $item)) {
424
-                throw new InvalidArgumentException(sprintf(
425
-                    'The "%s[%s]" HTTP header value is invalid',
426
-                    $name,
427
-                    $key
428
-                ));
429
-            }
430
-        }
431
-    }
42
+	/**
43
+	 * Supported HTTP versions
44
+	 *
45
+	 * @var list<string>
46
+	 */
47
+	public const SUPPORTED_HTTP_VERSIONS = ['1.0', '1.1', '2.0', '2'];
48
+
49
+	/**
50
+	 * Default HTTP version
51
+	 *
52
+	 * @var string
53
+	 */
54
+	public const DEFAULT_HTTP_VERSION = '1.1';
55
+
56
+	/**
57
+	 * The message HTTP version
58
+	 *
59
+	 * @var string
60
+	 */
61
+	private string $protocolVersion = self::DEFAULT_HTTP_VERSION;
62
+
63
+	/**
64
+	 * The message headers
65
+	 *
66
+	 * @var array<string, list<string>>
67
+	 */
68
+	private array $headers = [];
69
+
70
+	/**
71
+	 * Original header names (see $headers)
72
+	 *
73
+	 * @var array<string, string>
74
+	 */
75
+	private array $headerNames = [];
76
+
77
+	/**
78
+	 * The message body
79
+	 *
80
+	 * @var StreamInterface|null
81
+	 */
82
+	private ?StreamInterface $body = null;
83
+
84
+	/**
85
+	 * Gets the message HTTP version
86
+	 *
87
+	 * @return string
88
+	 */
89
+	public function getProtocolVersion(): string
90
+	{
91
+		return $this->protocolVersion;
92
+	}
93
+
94
+	/**
95
+	 * Creates a new instance of the message with the given HTTP version
96
+	 *
97
+	 * @param string $version
98
+	 *
99
+	 * @return static
100
+	 *
101
+	 * @throws InvalidArgumentException
102
+	 *         If the HTTP version isn't valid.
103
+	 */
104
+	public function withProtocolVersion($version): MessageInterface
105
+	{
106
+		$clone = clone $this;
107
+		$clone->setProtocolVersion($version);
108
+
109
+		return $clone;
110
+	}
111
+
112
+	/**
113
+	 * Gets the message headers
114
+	 *
115
+	 * @return array<string, list<string>>
116
+	 */
117
+	public function getHeaders(): array
118
+	{
119
+		return $this->headers;
120
+	}
121
+
122
+	/**
123
+	 * Checks if a header exists in the message by the given name
124
+	 *
125
+	 * @param string $name
126
+	 *
127
+	 * @return bool
128
+	 */
129
+	public function hasHeader($name): bool
130
+	{
131
+		$key = strtolower($name);
132
+
133
+		return isset($this->headerNames[$key]);
134
+	}
135
+
136
+	/**
137
+	 * Gets a header value(s) from the message by the given name
138
+	 *
139
+	 * @param string $name
140
+	 *
141
+	 * @return list<string>
142
+	 */
143
+	public function getHeader($name): array
144
+	{
145
+		$key = strtolower($name);
146
+
147
+		if (!isset($this->headerNames[$key])) {
148
+			return [];
149
+		}
150
+
151
+		return $this->headers[$this->headerNames[$key]];
152
+	}
153
+
154
+	/**
155
+	 * Gets a header value as a string from the message by the given name
156
+	 *
157
+	 * @param string $name
158
+	 *
159
+	 * @return string
160
+	 */
161
+	public function getHeaderLine($name): string
162
+	{
163
+		$key = strtolower($name);
164
+
165
+		if (!isset($this->headerNames[$key])) {
166
+			return '';
167
+		}
168
+
169
+		return implode(',', $this->headers[$this->headerNames[$key]]);
170
+	}
171
+
172
+	/**
173
+	 * Creates a new instance of the message with the given header overwriting the old header
174
+	 *
175
+	 * @param string $name
176
+	 * @param string|string[] $value
177
+	 *
178
+	 * @return static
179
+	 *
180
+	 * @throws InvalidArgumentException
181
+	 *         If the header isn't valid.
182
+	 */
183
+	public function withHeader($name, $value): MessageInterface
184
+	{
185
+		$clone = clone $this;
186
+		$clone->setHeader($name, $value, true);
187
+
188
+		return $clone;
189
+	}
190
+
191
+	/**
192
+	 * Creates a new instance of the message with the given header NOT overwriting the old header
193
+	 *
194
+	 * @param string $name
195
+	 * @param string|string[] $value
196
+	 *
197
+	 * @return static
198
+	 *
199
+	 * @throws InvalidArgumentException
200
+	 *         If the header isn't valid.
201
+	 */
202
+	public function withAddedHeader($name, $value): MessageInterface
203
+	{
204
+		$clone = clone $this;
205
+		$clone->setHeader($name, $value, false);
206
+
207
+		return $clone;
208
+	}
209
+
210
+	/**
211
+	 * Creates a new instance of the message without a header by the given name
212
+	 *
213
+	 * @param string $name
214
+	 *
215
+	 * @return static
216
+	 */
217
+	public function withoutHeader($name): MessageInterface
218
+	{
219
+		$clone = clone $this;
220
+		$clone->deleteHeader($name);
221
+
222
+		return $clone;
223
+	}
224
+
225
+	/**
226
+	 * Gets the message body
227
+	 *
228
+	 * @return StreamInterface
229
+	 */
230
+	public function getBody(): StreamInterface
231
+	{
232
+		return $this->body ??= new PhpTempStream();
233
+	}
234
+
235
+	/**
236
+	 * Creates a new instance of the message with the given body
237
+	 *
238
+	 * @param StreamInterface $body
239
+	 *
240
+	 * @return static
241
+	 */
242
+	public function withBody(StreamInterface $body): MessageInterface
243
+	{
244
+		$clone = clone $this;
245
+		$clone->setBody($body);
246
+
247
+		return $clone;
248
+	}
249
+
250
+	/**
251
+	 * Sets the given HTTP version to the message
252
+	 *
253
+	 * @param string $protocolVersion
254
+	 *
255
+	 * @return void
256
+	 *
257
+	 * @throws InvalidArgumentException
258
+	 *         If the HTTP version isn't valid.
259
+	 */
260
+	final protected function setProtocolVersion($protocolVersion): void
261
+	{
262
+		$this->validateProtocolVersion($protocolVersion);
263
+
264
+		$this->protocolVersion = $protocolVersion;
265
+	}
266
+
267
+	/**
268
+	 * Sets a new header to the message with the given name and value(s)
269
+	 *
270
+	 * @param string $name
271
+	 * @param string|string[] $value
272
+	 * @param bool $replace
273
+	 *
274
+	 * @return void
275
+	 *
276
+	 * @throws InvalidArgumentException
277
+	 *         If the header isn't valid.
278
+	 */
279
+	final protected function setHeader($name, $value, bool $replace = true): void
280
+	{
281
+		if (!is_array($value)) {
282
+			$value = [$value];
283
+		}
284
+
285
+		$this->validateHeaderName($name);
286
+		$this->validateHeaderValue($name, $value);
287
+
288
+		if ($replace) {
289
+			$this->deleteHeader($name);
290
+		}
291
+
292
+		$key = strtolower($name);
293
+
294
+		$this->headerNames[$key] ??= $name;
295
+		$this->headers[$this->headerNames[$key]] ??= [];
296
+
297
+		foreach ($value as $item) {
298
+			$this->headers[$this->headerNames[$key]][] = $item;
299
+		}
300
+	}
301
+
302
+	/**
303
+	 * Sets the given headers to the message
304
+	 *
305
+	 * @param array<string, string|string[]> $headers
306
+	 *
307
+	 * @return void
308
+	 *
309
+	 * @throws InvalidArgumentException
310
+	 *         If one of the headers isn't valid.
311
+	 */
312
+	final protected function setHeaders(array $headers): void
313
+	{
314
+		foreach ($headers as $name => $value) {
315
+			$this->setHeader($name, $value, false);
316
+		}
317
+	}
318
+
319
+	/**
320
+	 * Deletes a header from the message by the given name
321
+	 *
322
+	 * @param string $name
323
+	 *
324
+	 * @return void
325
+	 */
326
+	final protected function deleteHeader($name): void
327
+	{
328
+		$key = strtolower($name);
329
+
330
+		if (isset($this->headerNames[$key])) {
331
+			unset($this->headers[$this->headerNames[$key]]);
332
+			unset($this->headerNames[$key]);
333
+		}
334
+	}
335
+
336
+	/**
337
+	 * Sets the given body to the message
338
+	 *
339
+	 * @param StreamInterface $body
340
+	 *
341
+	 * @return void
342
+	 */
343
+	final protected function setBody(StreamInterface $body): void
344
+	{
345
+		$this->body = $body;
346
+	}
347
+
348
+	/**
349
+	 * Validates the given HTTP version
350
+	 *
351
+	 * @param mixed $protocolVersion
352
+	 *
353
+	 * @return void
354
+	 *
355
+	 * @throws InvalidArgumentException
356
+	 *         If the HTTP version isn't valid.
357
+	 */
358
+	private function validateProtocolVersion($protocolVersion): void
359
+	{
360
+		if (!in_array($protocolVersion, self::SUPPORTED_HTTP_VERSIONS, true)) {
361
+			throw new InvalidArgumentException('Invalid or unsupported HTTP version');
362
+		}
363
+	}
364
+
365
+	/**
366
+	 * Validates the given header name
367
+	 *
368
+	 * @param mixed $name
369
+	 *
370
+	 * @return void
371
+	 *
372
+	 * @throws InvalidArgumentException
373
+	 *         If the header name isn't valid.
374
+	 */
375
+	private function validateHeaderName($name): void
376
+	{
377
+		if ($name === '') {
378
+			throw new InvalidArgumentException('HTTP header name cannot be an empty');
379
+		}
380
+
381
+		if (!is_string($name)) {
382
+			throw new InvalidArgumentException('HTTP header name must be a string');
383
+		}
384
+
385
+		if (!preg_match(HeaderInterface::RFC7230_TOKEN_REGEX, $name)) {
386
+			throw new InvalidArgumentException('HTTP header name is invalid');
387
+		}
388
+	}
389
+
390
+	/**
391
+	 * Validates the given header value
392
+	 *
393
+	 * @param string $name
394
+	 * @param array $value
395
+	 *
396
+	 * @return void
397
+	 *
398
+	 * @throws InvalidArgumentException
399
+	 *         If the header value isn't valid.
400
+	 */
401
+	private function validateHeaderValue(string $name, array $value): void
402
+	{
403
+		if ([] === $value) {
404
+			throw new InvalidArgumentException(sprintf(
405
+				'The "%s" HTTP header value cannot be an empty array',
406
+				$name,
407
+			));
408
+		}
409
+
410
+		foreach ($value as $key => $item) {
411
+			if ('' === $item) {
412
+				continue;
413
+			}
414
+
415
+			if (!is_string($item)) {
416
+				throw new InvalidArgumentException(sprintf(
417
+					'The "%s[%s]" HTTP header value must be a string',
418
+					$name,
419
+					$key
420
+				));
421
+			}
422
+
423
+			if (!preg_match(HeaderInterface::RFC7230_FIELD_VALUE_REGEX, $item)) {
424
+				throw new InvalidArgumentException(sprintf(
425
+					'The "%s[%s]" HTTP header value is invalid',
426
+					$name,
427
+					$key
428
+				));
429
+			}
430
+		}
431
+	}
432 432
 }
Please login to merge, or discard this patch.
src/Uri/Component/Path.php 2 patches
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -31,53 +31,53 @@
 block discarded – undo
31 31
 final class Path implements ComponentInterface
32 32
 {
33 33
 
34
-    /**
35
-     * Regular expression used for the component normalization
36
-     *
37
-     * @var string
38
-     */
39
-    // phpcs:ignore Generic.Files.LineLength
40
-    private const NORMALIZATION_REGEX = '/(?:%[0-9A-Fa-f]{2}|[\x21\x24\x26-\x3b\x3d\x40-\x5a\x5f\x61-\x7a\x7e]+)|(.?)/u';
34
+	/**
35
+	 * Regular expression used for the component normalization
36
+	 *
37
+	 * @var string
38
+	 */
39
+	// phpcs:ignore Generic.Files.LineLength
40
+	private const NORMALIZATION_REGEX = '/(?:%[0-9A-Fa-f]{2}|[\x21\x24\x26-\x3b\x3d\x40-\x5a\x5f\x61-\x7a\x7e]+)|(.?)/u';
41 41
 
42
-    /**
43
-     * The component value
44
-     *
45
-     * @var string
46
-     */
47
-    private string $value = '';
42
+	/**
43
+	 * The component value
44
+	 *
45
+	 * @var string
46
+	 */
47
+	private string $value = '';
48 48
 
49
-    /**
50
-     * Constructor of the class
51
-     *
52
-     * @param mixed $value
53
-     *
54
-     * @throws InvalidArgumentException
55
-     *         If the component isn't valid.
56
-     */
57
-    public function __construct($value)
58
-    {
59
-        if ($value === '') {
60
-            return;
61
-        }
49
+	/**
50
+	 * Constructor of the class
51
+	 *
52
+	 * @param mixed $value
53
+	 *
54
+	 * @throws InvalidArgumentException
55
+	 *         If the component isn't valid.
56
+	 */
57
+	public function __construct($value)
58
+	{
59
+		if ($value === '') {
60
+			return;
61
+		}
62 62
 
63
-        if (!is_string($value)) {
64
-            throw new InvalidArgumentException('URI component "path" must be a string');
65
-        }
63
+		if (!is_string($value)) {
64
+			throw new InvalidArgumentException('URI component "path" must be a string');
65
+		}
66 66
 
67
-        $this->value = preg_replace_callback(self::NORMALIZATION_REGEX, static function (array $match): string {
68
-            /** @var array{0: string, 1?: string} $match */
67
+		$this->value = preg_replace_callback(self::NORMALIZATION_REGEX, static function (array $match): string {
68
+			/** @var array{0: string, 1?: string} $match */
69 69
 
70
-            return isset($match[1]) ? rawurlencode($match[1]) : $match[0];
71
-        }, $value);
72
-    }
70
+			return isset($match[1]) ? rawurlencode($match[1]) : $match[0];
71
+		}, $value);
72
+	}
73 73
 
74
-    /**
75
-     * {@inheritdoc}
76
-     *
77
-     * @return string
78
-     */
79
-    public function getValue(): string
80
-    {
81
-        return $this->value;
82
-    }
74
+	/**
75
+	 * {@inheritdoc}
76
+	 *
77
+	 * @return string
78
+	 */
79
+	public function getValue(): string
80
+	{
81
+		return $this->value;
82
+	}
83 83
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@
 block discarded – undo
64 64
             throw new InvalidArgumentException('URI component "path" must be a string');
65 65
         }
66 66
 
67
-        $this->value = preg_replace_callback(self::NORMALIZATION_REGEX, static function (array $match): string {
67
+        $this->value = preg_replace_callback(self::NORMALIZATION_REGEX, static function(array $match): string {
68 68
             /** @var array{0: string, 1?: string} $match */
69 69
 
70 70
             return isset($match[1]) ? rawurlencode($match[1]) : $match[0];
Please login to merge, or discard this patch.
src/Uri/Component/User.php 2 patches
Indentation   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -31,71 +31,71 @@
 block discarded – undo
31 31
 final class User implements ComponentInterface
32 32
 {
33 33
 
34
-    /**
35
-     * Regular expression used for the component normalization
36
-     *
37
-     * @var string
38
-     */
39
-    // phpcs:ignore Generic.Files.LineLength
40
-    private const NORMALIZATION_REGEX = '/(?:%[0-9A-Fa-f]{2}|[\x21\x24\x26-\x2e\x30-\x39\x3b\x3d\x41-\x5a\x5f\x61-\x7a\x7e]+)|(.?)/u';
34
+	/**
35
+	 * Regular expression used for the component normalization
36
+	 *
37
+	 * @var string
38
+	 */
39
+	// phpcs:ignore Generic.Files.LineLength
40
+	private const NORMALIZATION_REGEX = '/(?:%[0-9A-Fa-f]{2}|[\x21\x24\x26-\x2e\x30-\x39\x3b\x3d\x41-\x5a\x5f\x61-\x7a\x7e]+)|(.?)/u';
41 41
 
42
-    /**
43
-     * The component value
44
-     *
45
-     * @var string
46
-     */
47
-    private string $value = '';
42
+	/**
43
+	 * The component value
44
+	 *
45
+	 * @var string
46
+	 */
47
+	private string $value = '';
48 48
 
49
-    /**
50
-     * Constructor of the class
51
-     *
52
-     * @param mixed $value
53
-     *
54
-     * @throws InvalidArgumentException
55
-     *         If the component isn't valid.
56
-     */
57
-    public function __construct($value)
58
-    {
59
-        if ($value === '') {
60
-            return;
61
-        }
49
+	/**
50
+	 * Constructor of the class
51
+	 *
52
+	 * @param mixed $value
53
+	 *
54
+	 * @throws InvalidArgumentException
55
+	 *         If the component isn't valid.
56
+	 */
57
+	public function __construct($value)
58
+	{
59
+		if ($value === '') {
60
+			return;
61
+		}
62 62
 
63
-        if (!is_string($value)) {
64
-            throw new InvalidArgumentException('URI component "user" must be a string');
65
-        }
63
+		if (!is_string($value)) {
64
+			throw new InvalidArgumentException('URI component "user" must be a string');
65
+		}
66 66
 
67
-        $this->value = preg_replace_callback(self::NORMALIZATION_REGEX, static function (array $match): string {
68
-            /** @var array{0: string, 1?: string} $match */
67
+		$this->value = preg_replace_callback(self::NORMALIZATION_REGEX, static function (array $match): string {
68
+			/** @var array{0: string, 1?: string} $match */
69 69
 
70
-            return isset($match[1]) ? rawurlencode($match[1]) : $match[0];
71
-        }, $value);
72
-    }
70
+			return isset($match[1]) ? rawurlencode($match[1]) : $match[0];
71
+		}, $value);
72
+	}
73 73
 
74
-    /**
75
-     * Creates a user component
76
-     *
77
-     * @param mixed $user
78
-     *
79
-     * @return User
80
-     *
81
-     * @throws InvalidArgumentException
82
-     */
83
-    public static function create($user): User
84
-    {
85
-        if ($user instanceof User) {
86
-            return $user;
87
-        }
74
+	/**
75
+	 * Creates a user component
76
+	 *
77
+	 * @param mixed $user
78
+	 *
79
+	 * @return User
80
+	 *
81
+	 * @throws InvalidArgumentException
82
+	 */
83
+	public static function create($user): User
84
+	{
85
+		if ($user instanceof User) {
86
+			return $user;
87
+		}
88 88
 
89
-        return new User($user);
90
-    }
89
+		return new User($user);
90
+	}
91 91
 
92
-    /**
93
-     * {@inheritdoc}
94
-     *
95
-     * @return string
96
-     */
97
-    public function getValue(): string
98
-    {
99
-        return $this->value;
100
-    }
92
+	/**
93
+	 * {@inheritdoc}
94
+	 *
95
+	 * @return string
96
+	 */
97
+	public function getValue(): string
98
+	{
99
+		return $this->value;
100
+	}
101 101
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@
 block discarded – undo
64 64
             throw new InvalidArgumentException('URI component "user" must be a string');
65 65
         }
66 66
 
67
-        $this->value = preg_replace_callback(self::NORMALIZATION_REGEX, static function (array $match): string {
67
+        $this->value = preg_replace_callback(self::NORMALIZATION_REGEX, static function(array $match): string {
68 68
             /** @var array{0: string, 1?: string} $match */
69 69
 
70 70
             return isset($match[1]) ? rawurlencode($match[1]) : $match[0];
Please login to merge, or discard this patch.
src/Uri/Component/Password.php 2 patches
Indentation   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -31,71 +31,71 @@
 block discarded – undo
31 31
 final class Password implements ComponentInterface
32 32
 {
33 33
 
34
-    /**
35
-     * Regular expression used for the component normalization
36
-     *
37
-     * @var string
38
-     */
39
-    // phpcs:ignore Generic.Files.LineLength
40
-    private const NORMALIZATION_REGEX = '/(?:%[0-9A-Fa-f]{2}|[\x21\x24\x26-\x2e\x30-\x39\x3b\x3d\x41-\x5a\x5f\x61-\x7a\x7e]+)|(.?)/u';
34
+	/**
35
+	 * Regular expression used for the component normalization
36
+	 *
37
+	 * @var string
38
+	 */
39
+	// phpcs:ignore Generic.Files.LineLength
40
+	private const NORMALIZATION_REGEX = '/(?:%[0-9A-Fa-f]{2}|[\x21\x24\x26-\x2e\x30-\x39\x3b\x3d\x41-\x5a\x5f\x61-\x7a\x7e]+)|(.?)/u';
41 41
 
42
-    /**
43
-     * The component value
44
-     *
45
-     * @var string
46
-     */
47
-    private string $value = '';
42
+	/**
43
+	 * The component value
44
+	 *
45
+	 * @var string
46
+	 */
47
+	private string $value = '';
48 48
 
49
-    /**
50
-     * Constructor of the class
51
-     *
52
-     * @param mixed $value
53
-     *
54
-     * @throws InvalidArgumentException
55
-     *         If the component isn't valid.
56
-     */
57
-    public function __construct($value)
58
-    {
59
-        if ($value === '') {
60
-            return;
61
-        }
49
+	/**
50
+	 * Constructor of the class
51
+	 *
52
+	 * @param mixed $value
53
+	 *
54
+	 * @throws InvalidArgumentException
55
+	 *         If the component isn't valid.
56
+	 */
57
+	public function __construct($value)
58
+	{
59
+		if ($value === '') {
60
+			return;
61
+		}
62 62
 
63
-        if (!is_string($value)) {
64
-            throw new InvalidArgumentException('URI component "password" must be a string');
65
-        }
63
+		if (!is_string($value)) {
64
+			throw new InvalidArgumentException('URI component "password" must be a string');
65
+		}
66 66
 
67
-        $this->value = preg_replace_callback(self::NORMALIZATION_REGEX, static function (array $match): string {
68
-            /** @var array{0: string, 1?: string} $match */
67
+		$this->value = preg_replace_callback(self::NORMALIZATION_REGEX, static function (array $match): string {
68
+			/** @var array{0: string, 1?: string} $match */
69 69
 
70
-            return isset($match[1]) ? rawurlencode($match[1]) : $match[0];
71
-        }, $value);
72
-    }
70
+			return isset($match[1]) ? rawurlencode($match[1]) : $match[0];
71
+		}, $value);
72
+	}
73 73
 
74
-    /**
75
-     * Creates a password component
76
-     *
77
-     * @param mixed $password
78
-     *
79
-     * @return Password
80
-     *
81
-     * @throws InvalidArgumentException
82
-     */
83
-    public static function create($password): Password
84
-    {
85
-        if ($password instanceof Password) {
86
-            return $password;
87
-        }
74
+	/**
75
+	 * Creates a password component
76
+	 *
77
+	 * @param mixed $password
78
+	 *
79
+	 * @return Password
80
+	 *
81
+	 * @throws InvalidArgumentException
82
+	 */
83
+	public static function create($password): Password
84
+	{
85
+		if ($password instanceof Password) {
86
+			return $password;
87
+		}
88 88
 
89
-        return new Password($password);
90
-    }
89
+		return new Password($password);
90
+	}
91 91
 
92
-    /**
93
-     * {@inheritdoc}
94
-     *
95
-     * @return string
96
-     */
97
-    public function getValue(): string
98
-    {
99
-        return $this->value;
100
-    }
92
+	/**
93
+	 * {@inheritdoc}
94
+	 *
95
+	 * @return string
96
+	 */
97
+	public function getValue(): string
98
+	{
99
+		return $this->value;
100
+	}
101 101
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@
 block discarded – undo
64 64
             throw new InvalidArgumentException('URI component "password" must be a string');
65 65
         }
66 66
 
67
-        $this->value = preg_replace_callback(self::NORMALIZATION_REGEX, static function (array $match): string {
67
+        $this->value = preg_replace_callback(self::NORMALIZATION_REGEX, static function(array $match): string {
68 68
             /** @var array{0: string, 1?: string} $match */
69 69
 
70 70
             return isset($match[1]) ? rawurlencode($match[1]) : $match[0];
Please login to merge, or discard this patch.
src/Uri/Component/Host.php 2 patches
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -32,56 +32,56 @@
 block discarded – undo
32 32
 final class Host implements ComponentInterface
33 33
 {
34 34
 
35
-    /**
36
-     * Regular expression used for the component normalization
37
-     *
38
-     * @var string
39
-     */
40
-    // phpcs:ignore Generic.Files.LineLength
41
-    private const NORMALIZATION_REGEX = '/(?:%[0-9A-Fa-f]{2}|[\x21\x24\x26-\x2e\x30-\x39\x3b\x3d\x41-\x5a\x5f\x61-\x7a\x7e]+)|(.?)/u';
35
+	/**
36
+	 * Regular expression used for the component normalization
37
+	 *
38
+	 * @var string
39
+	 */
40
+	// phpcs:ignore Generic.Files.LineLength
41
+	private const NORMALIZATION_REGEX = '/(?:%[0-9A-Fa-f]{2}|[\x21\x24\x26-\x2e\x30-\x39\x3b\x3d\x41-\x5a\x5f\x61-\x7a\x7e]+)|(.?)/u';
42 42
 
43
-    /**
44
-     * The component value
45
-     *
46
-     * @var string
47
-     */
48
-    private string $value = '';
43
+	/**
44
+	 * The component value
45
+	 *
46
+	 * @var string
47
+	 */
48
+	private string $value = '';
49 49
 
50
-    /**
51
-     * Constructor of the class
52
-     *
53
-     * @param mixed $value
54
-     *
55
-     * @throws InvalidArgumentException
56
-     *         If the component isn't valid.
57
-     */
58
-    public function __construct($value)
59
-    {
60
-        if ($value === '') {
61
-            return;
62
-        }
50
+	/**
51
+	 * Constructor of the class
52
+	 *
53
+	 * @param mixed $value
54
+	 *
55
+	 * @throws InvalidArgumentException
56
+	 *         If the component isn't valid.
57
+	 */
58
+	public function __construct($value)
59
+	{
60
+		if ($value === '') {
61
+			return;
62
+		}
63 63
 
64
-        if (!is_string($value)) {
65
-            throw new InvalidArgumentException('URI component "host" must be a string');
66
-        }
64
+		if (!is_string($value)) {
65
+			throw new InvalidArgumentException('URI component "host" must be a string');
66
+		}
67 67
 
68
-        $this->value = preg_replace_callback(self::NORMALIZATION_REGEX, static function (array $match): string {
69
-            /** @var array{0: string, 1?: string} $match */
68
+		$this->value = preg_replace_callback(self::NORMALIZATION_REGEX, static function (array $match): string {
69
+			/** @var array{0: string, 1?: string} $match */
70 70
 
71
-            return isset($match[1]) ? rawurlencode($match[1]) : $match[0];
72
-        }, $value);
71
+			return isset($match[1]) ? rawurlencode($match[1]) : $match[0];
72
+		}, $value);
73 73
 
74
-        // the component is case-insensitive...
75
-        $this->value = strtolower($this->value);
76
-    }
74
+		// the component is case-insensitive...
75
+		$this->value = strtolower($this->value);
76
+	}
77 77
 
78
-    /**
79
-     * {@inheritdoc}
80
-     *
81
-     * @return string
82
-     */
83
-    public function getValue(): string
84
-    {
85
-        return $this->value;
86
-    }
78
+	/**
79
+	 * {@inheritdoc}
80
+	 *
81
+	 * @return string
82
+	 */
83
+	public function getValue(): string
84
+	{
85
+		return $this->value;
86
+	}
87 87
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@
 block discarded – undo
65 65
             throw new InvalidArgumentException('URI component "host" must be a string');
66 66
         }
67 67
 
68
-        $this->value = preg_replace_callback(self::NORMALIZATION_REGEX, static function (array $match): string {
68
+        $this->value = preg_replace_callback(self::NORMALIZATION_REGEX, static function(array $match): string {
69 69
             /** @var array{0: string, 1?: string} $match */
70 70
 
71 71
             return isset($match[1]) ? rawurlencode($match[1]) : $match[0];
Please login to merge, or discard this patch.
src/Uri/Component/Query.php 2 patches
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -31,53 +31,53 @@
 block discarded – undo
31 31
 final class Query implements ComponentInterface
32 32
 {
33 33
 
34
-    /**
35
-     * Regular expression used for the component normalization
36
-     *
37
-     * @var string
38
-     */
39
-    // phpcs:ignore Generic.Files.LineLength
40
-    private const NORMALIZATION_REGEX = '/(?:%[0-9A-Fa-f]{2}|[\x21\x24\x26-\x3b\x3d\x3f-\x5a\x5f\x61-\x7a\x7e]+)|(.?)/u';
34
+	/**
35
+	 * Regular expression used for the component normalization
36
+	 *
37
+	 * @var string
38
+	 */
39
+	// phpcs:ignore Generic.Files.LineLength
40
+	private const NORMALIZATION_REGEX = '/(?:%[0-9A-Fa-f]{2}|[\x21\x24\x26-\x3b\x3d\x3f-\x5a\x5f\x61-\x7a\x7e]+)|(.?)/u';
41 41
 
42
-    /**
43
-     * The component value
44
-     *
45
-     * @var string
46
-     */
47
-    private string $value = '';
42
+	/**
43
+	 * The component value
44
+	 *
45
+	 * @var string
46
+	 */
47
+	private string $value = '';
48 48
 
49
-    /**
50
-     * Constructor of the class
51
-     *
52
-     * @param mixed $value
53
-     *
54
-     * @throws InvalidArgumentException
55
-     *         If the component isn't valid.
56
-     */
57
-    public function __construct($value)
58
-    {
59
-        if ($value === '') {
60
-            return;
61
-        }
49
+	/**
50
+	 * Constructor of the class
51
+	 *
52
+	 * @param mixed $value
53
+	 *
54
+	 * @throws InvalidArgumentException
55
+	 *         If the component isn't valid.
56
+	 */
57
+	public function __construct($value)
58
+	{
59
+		if ($value === '') {
60
+			return;
61
+		}
62 62
 
63
-        if (!is_string($value)) {
64
-            throw new InvalidArgumentException('URI component "query" must be a string');
65
-        }
63
+		if (!is_string($value)) {
64
+			throw new InvalidArgumentException('URI component "query" must be a string');
65
+		}
66 66
 
67
-        $this->value = preg_replace_callback(self::NORMALIZATION_REGEX, static function (array $match): string {
68
-            /** @var array{0: string, 1?: string} $match */
67
+		$this->value = preg_replace_callback(self::NORMALIZATION_REGEX, static function (array $match): string {
68
+			/** @var array{0: string, 1?: string} $match */
69 69
 
70
-            return isset($match[1]) ? rawurlencode($match[1]) : $match[0];
71
-        }, $value);
72
-    }
70
+			return isset($match[1]) ? rawurlencode($match[1]) : $match[0];
71
+		}, $value);
72
+	}
73 73
 
74
-    /**
75
-     * {@inheritdoc}
76
-     *
77
-     * @return string
78
-     */
79
-    public function getValue(): string
80
-    {
81
-        return $this->value;
82
-    }
74
+	/**
75
+	 * {@inheritdoc}
76
+	 *
77
+	 * @return string
78
+	 */
79
+	public function getValue(): string
80
+	{
81
+		return $this->value;
82
+	}
83 83
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@
 block discarded – undo
64 64
             throw new InvalidArgumentException('URI component "query" must be a string');
65 65
         }
66 66
 
67
-        $this->value = preg_replace_callback(self::NORMALIZATION_REGEX, static function (array $match): string {
67
+        $this->value = preg_replace_callback(self::NORMALIZATION_REGEX, static function(array $match): string {
68 68
             /** @var array{0: string, 1?: string} $match */
69 69
 
70 70
             return isset($match[1]) ? rawurlencode($match[1]) : $match[0];
Please login to merge, or discard this patch.
src/Uri/Component/Fragment.php 2 patches
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -31,53 +31,53 @@
 block discarded – undo
31 31
 final class Fragment implements ComponentInterface
32 32
 {
33 33
 
34
-    /**
35
-     * Regular expression used for the component normalization
36
-     *
37
-     * @var string
38
-     */
39
-    // phpcs:ignore Generic.Files.LineLength
40
-    private const NORMALIZATION_REGEX = '/(?:%[0-9A-Fa-f]{2}|[\x21\x24\x26-\x3b\x3d\x3f-\x5a\x5f\x61-\x7a\x7e])*|(.?)/u';
34
+	/**
35
+	 * Regular expression used for the component normalization
36
+	 *
37
+	 * @var string
38
+	 */
39
+	// phpcs:ignore Generic.Files.LineLength
40
+	private const NORMALIZATION_REGEX = '/(?:%[0-9A-Fa-f]{2}|[\x21\x24\x26-\x3b\x3d\x3f-\x5a\x5f\x61-\x7a\x7e])*|(.?)/u';
41 41
 
42
-    /**
43
-     * The component value
44
-     *
45
-     * @var string
46
-     */
47
-    private string $value = '';
42
+	/**
43
+	 * The component value
44
+	 *
45
+	 * @var string
46
+	 */
47
+	private string $value = '';
48 48
 
49
-    /**
50
-     * Constructor of the class
51
-     *
52
-     * @param mixed $value
53
-     *
54
-     * @throws InvalidArgumentException
55
-     *         If the component isn't valid.
56
-     */
57
-    public function __construct($value)
58
-    {
59
-        if ($value === '') {
60
-            return;
61
-        }
49
+	/**
50
+	 * Constructor of the class
51
+	 *
52
+	 * @param mixed $value
53
+	 *
54
+	 * @throws InvalidArgumentException
55
+	 *         If the component isn't valid.
56
+	 */
57
+	public function __construct($value)
58
+	{
59
+		if ($value === '') {
60
+			return;
61
+		}
62 62
 
63
-        if (!is_string($value)) {
64
-            throw new InvalidArgumentException('URI component "fragment" must be a string');
65
-        }
63
+		if (!is_string($value)) {
64
+			throw new InvalidArgumentException('URI component "fragment" must be a string');
65
+		}
66 66
 
67
-        $this->value = preg_replace_callback(self::NORMALIZATION_REGEX, static function (array $match): string {
68
-            /** @var array{0: string, 1?: string} $match */
67
+		$this->value = preg_replace_callback(self::NORMALIZATION_REGEX, static function (array $match): string {
68
+			/** @var array{0: string, 1?: string} $match */
69 69
 
70
-            return isset($match[1]) ? rawurlencode($match[1]) : $match[0];
71
-        }, $value);
72
-    }
70
+			return isset($match[1]) ? rawurlencode($match[1]) : $match[0];
71
+		}, $value);
72
+	}
73 73
 
74
-    /**
75
-     * {@inheritdoc}
76
-     *
77
-     * @return string
78
-     */
79
-    public function getValue(): string
80
-    {
81
-        return $this->value;
82
-    }
74
+	/**
75
+	 * {@inheritdoc}
76
+	 *
77
+	 * @return string
78
+	 */
79
+	public function getValue(): string
80
+	{
81
+		return $this->value;
82
+	}
83 83
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@
 block discarded – undo
64 64
             throw new InvalidArgumentException('URI component "fragment" must be a string');
65 65
         }
66 66
 
67
-        $this->value = preg_replace_callback(self::NORMALIZATION_REGEX, static function (array $match): string {
67
+        $this->value = preg_replace_callback(self::NORMALIZATION_REGEX, static function(array $match): string {
68 68
             /** @var array{0: string, 1?: string} $match */
69 69
 
70 70
             return isset($match[1]) ? rawurlencode($match[1]) : $match[0];
Please login to merge, or discard this patch.