1 | <?php |
||
23 | class Url |
||
24 | { |
||
25 | /** |
||
26 | * @var bool |
||
27 | */ |
||
28 | private $secured; |
||
29 | |||
30 | /** |
||
31 | * example: 127.0.0.1 |
||
32 | * |
||
33 | * @var string |
||
34 | */ |
||
35 | private $host; |
||
36 | |||
37 | /** |
||
38 | * example: 8080 |
||
39 | * |
||
40 | * @var int |
||
41 | */ |
||
42 | private $port; |
||
43 | |||
44 | /** |
||
45 | * example: /chat |
||
46 | * |
||
47 | * @var string |
||
48 | */ |
||
49 | private $uri; |
||
50 | |||
51 | public function __construct(string $url = null) |
||
57 | |||
58 | /** |
||
59 | * @return bool |
||
60 | */ |
||
61 | public function isSecured(): bool |
||
65 | |||
66 | /** |
||
67 | * @param bool $secured |
||
68 | * @return Url |
||
69 | */ |
||
70 | public function setSecured(bool $secured = true) |
||
76 | |||
77 | /** |
||
78 | * @return string |
||
79 | */ |
||
80 | public function getHost(): string |
||
84 | |||
85 | /** |
||
86 | * @param string $host |
||
87 | * @return Url |
||
88 | */ |
||
89 | public function setHost(string $host) |
||
95 | |||
96 | /** |
||
97 | * @return int |
||
98 | */ |
||
99 | public function getPort(): int |
||
103 | |||
104 | /** |
||
105 | * @param int $port |
||
106 | * @return Url |
||
107 | */ |
||
108 | public function setPort(int $port) |
||
114 | |||
115 | /** |
||
116 | * @return string |
||
117 | */ |
||
118 | public function getUri(): string |
||
122 | |||
123 | /** |
||
124 | * @param string $uri |
||
125 | * @return Url |
||
126 | */ |
||
127 | public function setUri($uri) |
||
133 | |||
134 | /** |
||
135 | * Fill the object with given URL as string. |
||
136 | * |
||
137 | * @param string $url |
||
138 | */ |
||
139 | private function initialize(string $url) |
||
152 | |||
153 | /** |
||
154 | * @return string |
||
155 | */ |
||
156 | public function __toString() |
||
163 | } |
||
164 |
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.