1 | <?php |
||
39 | class ResourceIdentifier |
||
40 | { |
||
41 | |||
42 | /** |
||
43 | * The URL data of the resource identifier. |
||
44 | * |
||
45 | * @var array |
||
46 | */ |
||
47 | protected $data = array(); |
||
48 | |||
49 | /** |
||
50 | * Initializes the resource identifier with the data of the passed array. |
||
51 | * |
||
52 | * @param array $urlElements The data to initialize the identifier with |
||
53 | */ |
||
54 | 13 | public function __construct(array $urlElements = array()) |
|
58 | |||
59 | /** |
||
60 | * Returns the value for the passed key, if available. |
||
61 | * |
||
62 | * @param string $key The key of the value to return |
||
63 | * |
||
64 | * @return mixed|null The requested value |
||
65 | */ |
||
66 | 12 | protected function getValue($key) |
|
72 | |||
73 | /** |
||
74 | * Sets the value with the passed key, existing values |
||
75 | * are overwritten. |
||
76 | * |
||
77 | * @param string $key The key of the value |
||
78 | * @param string $value The value to set |
||
79 | * |
||
80 | * @return void |
||
81 | */ |
||
82 | 1 | protected function setValue($key, $value) |
|
86 | |||
87 | /** |
||
88 | * Sets the URL scheme. |
||
89 | * |
||
90 | * @param string $scheme The URL scheme |
||
91 | * |
||
92 | * @return void |
||
93 | */ |
||
94 | public function setScheme($scheme) |
||
98 | |||
99 | /** |
||
100 | * Returns the URL scheme. |
||
101 | * |
||
102 | * @return string|null The URL scheme |
||
103 | */ |
||
104 | 1 | public function getScheme() |
|
108 | |||
109 | /** |
||
110 | * Sets the URL user. |
||
111 | * |
||
112 | * @param string $user The URL user |
||
113 | * |
||
114 | * @return void |
||
115 | */ |
||
116 | public function setUser($user) |
||
120 | |||
121 | /** |
||
122 | * Returns the URL user. |
||
123 | * |
||
124 | * @return string|null The URL user |
||
125 | */ |
||
126 | 1 | public function getUser() |
|
130 | |||
131 | /** |
||
132 | * Sets the URL password. |
||
133 | * |
||
134 | * @param string $pass The URL password |
||
135 | * |
||
136 | * @return void |
||
137 | */ |
||
138 | public function setPass($pass) |
||
142 | |||
143 | /** |
||
144 | * Returns the URL password. |
||
145 | * |
||
146 | * @return string|null The URL password |
||
147 | */ |
||
148 | 1 | public function getPass() |
|
152 | |||
153 | /** |
||
154 | * Sets the URL host. |
||
155 | * |
||
156 | * @param string $host The URL host |
||
157 | * |
||
158 | * @return void |
||
159 | */ |
||
160 | public function setHost($host) |
||
164 | |||
165 | /** |
||
166 | * Returns the URL host. |
||
167 | * |
||
168 | * @return string|null The URL host |
||
169 | */ |
||
170 | 1 | public function getHost() |
|
174 | |||
175 | /** |
||
176 | * Sets the URL port. |
||
177 | * |
||
178 | * @param integer $port The URL port |
||
179 | * |
||
180 | * @return void |
||
181 | */ |
||
182 | public function setPort($port) |
||
186 | |||
187 | /** |
||
188 | * Returns the URL port. |
||
189 | * |
||
190 | * @return integer|null The URL port |
||
191 | */ |
||
192 | 1 | public function getPort() |
|
196 | |||
197 | /** |
||
198 | * Sets the URL path. |
||
199 | * |
||
200 | * @param string $path The URL path |
||
201 | * |
||
202 | * @return void |
||
203 | */ |
||
204 | public function setPath($path) |
||
208 | |||
209 | /** |
||
210 | * Returns the URL path. |
||
211 | * |
||
212 | * @return string|null The URL path |
||
213 | */ |
||
214 | 1 | public function getPath() |
|
218 | |||
219 | /** |
||
220 | * Sets the URL query. |
||
221 | * |
||
222 | * @param string $query The URL query |
||
223 | * |
||
224 | * @return void |
||
225 | */ |
||
226 | public function setQuery($query) |
||
230 | |||
231 | /** |
||
232 | * Returns the URL query. |
||
233 | * |
||
234 | * @return string|null The URL query |
||
235 | */ |
||
236 | 1 | public function getQuery() |
|
240 | |||
241 | /** |
||
242 | * Extracts and returns the path information from the path. |
||
243 | * |
||
244 | * @return string|null The path information |
||
245 | */ |
||
246 | 1 | public function getPathInfo() |
|
252 | |||
253 | /** |
||
254 | * Extracts and returns the filename from the path. |
||
255 | * |
||
256 | * @return string|null The filename |
||
257 | */ |
||
258 | 1 | public function getFilename() |
|
283 | |||
284 | /** |
||
285 | * Returns the context name from the URL. |
||
286 | * |
||
287 | * @return string|null The context name |
||
288 | */ |
||
289 | 1 | public function getContextName() |
|
296 | |||
297 | /** |
||
298 | * Adds a query parameter to the resource identifier, usually this will be a session ID. |
||
299 | * |
||
300 | * @param string $keyValuePair The query parameter we want to add |
||
301 | * |
||
302 | * @return void |
||
303 | */ |
||
304 | public function addQueryParam($keyValuePair) |
||
312 | |||
313 | /** |
||
314 | * Creates a new resource identifier instance with the data extracted from the passed URL. |
||
315 | * |
||
316 | * @param string $url The URL to load the data from |
||
317 | * |
||
318 | * @return void |
||
319 | */ |
||
320 | 1 | public function populateFromUrl($url) |
|
326 | |||
327 | /** |
||
328 | * create a new resource identifier with the URL parts from the passed properties. |
||
329 | * |
||
330 | * @param \AppserverIo\Properties\PropertiesInterface $properties The configuration properties |
||
331 | * |
||
332 | * @return \AppserverIo\Psr\Naming\ResourceIdentifier The initialized instance |
||
333 | */ |
||
334 | public static function createFromProperties(PropertiesInterface $properties) |
||
338 | } |
||
339 |
There are different options of fixing this problem.
If you want to be on the safe side, you can add an additional type-check:
If you are sure that the expression is traversable, you might want to add a doc comment cast to improve IDE auto-completion and static analysis:
Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.