1 | <?php declare(strict_types=1); |
||
11 | class Url |
||
12 | { |
||
13 | /** |
||
14 | * @var string |
||
15 | */ |
||
16 | protected $url; |
||
17 | |||
18 | 11 | public function __construct(string $url) |
|
22 | |||
23 | 4 | public function getPath(): ?string |
|
29 | |||
30 | /** |
||
31 | * @param string $newPath |
||
32 | * @return string|self |
||
33 | */ |
||
34 | 3 | public function replacePath(string $newPath) |
|
47 | |||
48 | 4 | public function getQuery(): ?string |
|
54 | |||
55 | 3 | public function getFragment(): ?string |
|
61 | |||
62 | 3 | public function getQueryParameters(): array |
|
71 | |||
72 | 3 | public function withoutQueryAndFragment(): self |
|
80 | |||
81 | /** |
||
82 | * @param array $newParameters |
||
83 | * @param bool $merge If parameters should be merged (overwrite existing) or added (not overwriting existing) |
||
84 | * @param string $argSeparator |
||
85 | * @return self |
||
86 | */ |
||
87 | 2 | public function addQueryParameters(array $newParameters = [], bool $merge = true, string $argSeparator = '&'): self |
|
109 | |||
110 | 4 | public function __toString(): string |
|
114 | } |
||
115 |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)
or! empty(...)
instead.