1 | <?php |
||
7 | final class Url implements ValueObjectInterface |
||
8 | { |
||
9 | /** |
||
10 | * @var string |
||
11 | */ |
||
12 | private const NIL = ''; |
||
13 | |||
14 | /** |
||
15 | * @var string |
||
16 | */ |
||
17 | private const DEFAULT_PATH = '/'; |
||
18 | |||
19 | /** |
||
20 | * @var Text |
||
21 | */ |
||
22 | private $fragment; |
||
23 | |||
24 | /** |
||
25 | * @var Text |
||
26 | */ |
||
27 | private $host; |
||
28 | |||
29 | /* |
||
30 | * @var Text |
||
31 | */ |
||
32 | private $scheme; |
||
33 | |||
34 | /** |
||
35 | * @var Text |
||
36 | */ |
||
37 | private $query; |
||
38 | |||
39 | /** |
||
40 | * @var Integer |
||
41 | */ |
||
42 | private $port; |
||
43 | |||
44 | /** |
||
45 | * @var Text |
||
46 | */ |
||
47 | private $path; |
||
48 | |||
49 | /** |
||
50 | * @param string|null $nativeValue |
||
51 | * @return Url |
||
52 | */ |
||
53 | 22 | public static function fromNative($nativeValue): Url |
|
58 | |||
59 | 4 | public function toNative(): string |
|
60 | { |
||
61 | 4 | if ($this->host->isEmpty()) { |
|
62 | 1 | return self::NIL; |
|
63 | } |
||
64 | 4 | return sprintf( |
|
65 | 4 | '%s://%s%s%s%s%s', |
|
66 | 4 | $this->scheme, |
|
67 | 4 | $this->host, |
|
68 | 4 | $this->formatPort(), |
|
69 | 4 | $this->path, |
|
70 | 4 | $this->formatQuery(), |
|
71 | 4 | $this->formatFragment() |
|
72 | ); |
||
73 | } |
||
74 | |||
75 | 1 | public function equals(ValueObjectInterface $otherValue): bool |
|
79 | |||
80 | 1 | public function __toString(): string |
|
84 | |||
85 | 1 | public function getPath(): Text |
|
89 | |||
90 | 1 | public function getPort(): Integer |
|
94 | |||
95 | 1 | public function getFragment(): Text |
|
99 | |||
100 | 1 | public function getHost(): Text |
|
104 | |||
105 | 1 | public function getQuery(): Text |
|
109 | |||
110 | 1 | public function getScheme(): Text |
|
114 | |||
115 | 22 | private function __construct(string $url = self::NIL) |
|
124 | |||
125 | 22 | private function parseHost(string $url): Text |
|
129 | |||
130 | 22 | private function parseScheme(string $url): Text |
|
134 | |||
135 | 22 | private function parseQuery(string $url): Text |
|
139 | |||
140 | 22 | private function parseFragment(string $url): Text |
|
144 | |||
145 | 22 | private function parsePath(string $url): Text |
|
149 | |||
150 | 22 | private function parsePort(string $url): Integer |
|
154 | |||
155 | 4 | private function formatPort(): string |
|
163 | |||
164 | 4 | private function formatQuery(): string |
|
171 | |||
172 | 4 | private function formatFragment(): string |
|
179 | } |
||
180 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..