@@ -33,24 +33,24 @@ discard block |
||
33 | 33 | |
34 | 34 | const PATH_MODE_STRIP = 'strip'; |
35 | 35 | |
36 | - /** |
|
37 | - * @var string |
|
38 | - */ |
|
36 | + /** |
|
37 | + * @var string |
|
38 | + */ |
|
39 | 39 | protected $path; |
40 | 40 | |
41 | - /** |
|
42 | - * @var array |
|
43 | - */ |
|
41 | + /** |
|
42 | + * @var array |
|
43 | + */ |
|
44 | 44 | protected $found; |
45 | 45 | |
46 | - /** |
|
47 | - * The path must exist when the class is instantiated: its |
|
48 | - * real path will be determined to work with. |
|
49 | - * |
|
50 | - * @param string $path The absolute path to the target folder. |
|
51 | - * @throws FileHelper_Exception |
|
52 | - * @see FileHelper_FileFinder::ERROR_PATH_DOES_NOT_EXIST |
|
53 | - */ |
|
46 | + /** |
|
47 | + * The path must exist when the class is instantiated: its |
|
48 | + * real path will be determined to work with. |
|
49 | + * |
|
50 | + * @param string $path The absolute path to the target folder. |
|
51 | + * @throws FileHelper_Exception |
|
52 | + * @see FileHelper_FileFinder::ERROR_PATH_DOES_NOT_EXIST |
|
53 | + */ |
|
54 | 54 | public function __construct(string $path) |
55 | 55 | { |
56 | 56 | $real = realpath($path); |
@@ -82,66 +82,66 @@ discard block |
||
82 | 82 | ); |
83 | 83 | } |
84 | 84 | |
85 | - /** |
|
86 | - * Enables extension stripping, to return file names without extension. |
|
87 | - * |
|
88 | - * @return FileHelper_FileFinder |
|
89 | - */ |
|
85 | + /** |
|
86 | + * Enables extension stripping, to return file names without extension. |
|
87 | + * |
|
88 | + * @return FileHelper_FileFinder |
|
89 | + */ |
|
90 | 90 | public function stripExtensions() : FileHelper_FileFinder |
91 | 91 | { |
92 | 92 | return $this->setOption('strip-extensions', true); |
93 | 93 | } |
94 | 94 | |
95 | - /** |
|
96 | - * Enables recursing into subfolders. |
|
97 | - * |
|
98 | - * @return FileHelper_FileFinder |
|
99 | - */ |
|
95 | + /** |
|
96 | + * Enables recursing into subfolders. |
|
97 | + * |
|
98 | + * @return FileHelper_FileFinder |
|
99 | + */ |
|
100 | 100 | public function makeRecursive() : FileHelper_FileFinder |
101 | 101 | { |
102 | 102 | return $this->setOption('recursive', true); |
103 | 103 | } |
104 | 104 | |
105 | - /** |
|
106 | - * Retrieves all extensions that were added to |
|
107 | - * the include list. |
|
108 | - * |
|
109 | - * @return array |
|
110 | - */ |
|
105 | + /** |
|
106 | + * Retrieves all extensions that were added to |
|
107 | + * the include list. |
|
108 | + * |
|
109 | + * @return array |
|
110 | + */ |
|
111 | 111 | public function getIncludeExtensions() : array |
112 | 112 | { |
113 | 113 | return $this->getArrayOption('include-extensions'); |
114 | 114 | } |
115 | 115 | |
116 | - /** |
|
117 | - * Includes a single extension in the file search: only |
|
118 | - * files with this extension will be used in the results. |
|
119 | - * |
|
120 | - * NOTE: Included extensions take precedence before excluded |
|
121 | - * extensions. If any excluded extensions are specified, they |
|
122 | - * will be ignored. |
|
123 | - * |
|
124 | - * @param string $extension Extension name, without dot (`php` for example). |
|
125 | - * @return FileHelper_FileFinder |
|
126 | - * @see FileHelper_FileFinder::includeExtensions() |
|
127 | - */ |
|
116 | + /** |
|
117 | + * Includes a single extension in the file search: only |
|
118 | + * files with this extension will be used in the results. |
|
119 | + * |
|
120 | + * NOTE: Included extensions take precedence before excluded |
|
121 | + * extensions. If any excluded extensions are specified, they |
|
122 | + * will be ignored. |
|
123 | + * |
|
124 | + * @param string $extension Extension name, without dot (`php` for example). |
|
125 | + * @return FileHelper_FileFinder |
|
126 | + * @see FileHelper_FileFinder::includeExtensions() |
|
127 | + */ |
|
128 | 128 | public function includeExtension(string $extension) : FileHelper_FileFinder |
129 | 129 | { |
130 | 130 | return $this->includeExtensions(array($extension)); |
131 | 131 | } |
132 | 132 | |
133 | - /** |
|
134 | - * Includes several extensions in the file search: only |
|
135 | - * files with these extensions wil be used in the results. |
|
136 | - * |
|
137 | - * NOTE: Included extensions take precedence before excluded |
|
138 | - * extensions. If any excluded extensions are specified, they |
|
139 | - * will be ignored. |
|
140 | - * |
|
141 | - * @param array $extensions Extension names, without dot (`php` for example). |
|
142 | - * @return FileHelper_FileFinder |
|
143 | - * @see FileHelper_FileFinder::includeExtension() |
|
144 | - */ |
|
133 | + /** |
|
134 | + * Includes several extensions in the file search: only |
|
135 | + * files with these extensions wil be used in the results. |
|
136 | + * |
|
137 | + * NOTE: Included extensions take precedence before excluded |
|
138 | + * extensions. If any excluded extensions are specified, they |
|
139 | + * will be ignored. |
|
140 | + * |
|
141 | + * @param array $extensions Extension names, without dot (`php` for example). |
|
142 | + * @return FileHelper_FileFinder |
|
143 | + * @see FileHelper_FileFinder::includeExtension() |
|
144 | + */ |
|
145 | 145 | public function includeExtensions(array $extensions) : FileHelper_FileFinder |
146 | 146 | { |
147 | 147 | $items = $this->getIncludeExtensions(); |
@@ -152,37 +152,37 @@ discard block |
||
152 | 152 | return $this; |
153 | 153 | } |
154 | 154 | |
155 | - /** |
|
156 | - * Retrieves a list of all extensions currently set as |
|
157 | - * excluded from the search. |
|
158 | - * |
|
159 | - * @return array |
|
160 | - */ |
|
155 | + /** |
|
156 | + * Retrieves a list of all extensions currently set as |
|
157 | + * excluded from the search. |
|
158 | + * |
|
159 | + * @return array |
|
160 | + */ |
|
161 | 161 | public function getExcludeExtensions() : array |
162 | 162 | { |
163 | 163 | return $this->getArrayOption('exclude-extensions'); |
164 | 164 | } |
165 | 165 | |
166 | - /** |
|
167 | - * Excludes a single extension from the search. |
|
168 | - * |
|
169 | - * @param string $extension Extension name, without dot (`php` for example). |
|
170 | - * @return FileHelper_FileFinder |
|
171 | - * @see FileHelper_FileFinder::excludeExtensions() |
|
172 | - */ |
|
166 | + /** |
|
167 | + * Excludes a single extension from the search. |
|
168 | + * |
|
169 | + * @param string $extension Extension name, without dot (`php` for example). |
|
170 | + * @return FileHelper_FileFinder |
|
171 | + * @see FileHelper_FileFinder::excludeExtensions() |
|
172 | + */ |
|
173 | 173 | public function excludeExtension(string $extension) : FileHelper_FileFinder |
174 | 174 | { |
175 | 175 | return $this->excludeExtensions(array($extension)); |
176 | 176 | } |
177 | 177 | |
178 | - /** |
|
179 | - * Add several extensions to the list of extensions to |
|
180 | - * exclude from the file search. |
|
181 | - * |
|
182 | - * @param array $extensions Extension names, without dot (`php` for example). |
|
183 | - * @return FileHelper_FileFinder |
|
184 | - * @see FileHelper_FileFinder::excludeExtension() |
|
185 | - */ |
|
178 | + /** |
|
179 | + * Add several extensions to the list of extensions to |
|
180 | + * exclude from the file search. |
|
181 | + * |
|
182 | + * @param array $extensions Extension names, without dot (`php` for example). |
|
183 | + * @return FileHelper_FileFinder |
|
184 | + * @see FileHelper_FileFinder::excludeExtension() |
|
185 | + */ |
|
186 | 186 | public function excludeExtensions(array $extensions) : FileHelper_FileFinder |
187 | 187 | { |
188 | 188 | $items = $this->getExcludeExtensions(); |
@@ -193,52 +193,52 @@ discard block |
||
193 | 193 | return $this; |
194 | 194 | } |
195 | 195 | |
196 | - /** |
|
197 | - * In this mode, the entire path to the file will be stripped, |
|
198 | - * leaving only the file name in the files list. |
|
199 | - * |
|
200 | - * @return FileHelper_FileFinder |
|
201 | - */ |
|
196 | + /** |
|
197 | + * In this mode, the entire path to the file will be stripped, |
|
198 | + * leaving only the file name in the files list. |
|
199 | + * |
|
200 | + * @return FileHelper_FileFinder |
|
201 | + */ |
|
202 | 202 | public function setPathmodeStrip() : FileHelper_FileFinder |
203 | 203 | { |
204 | 204 | return $this->setPathmode(self::PATH_MODE_STRIP); |
205 | 205 | } |
206 | 206 | |
207 | - /** |
|
208 | - * In this mode, only the path relative to the source folder |
|
209 | - * will be included in the files list. |
|
210 | - * |
|
211 | - * @return FileHelper_FileFinder |
|
212 | - */ |
|
207 | + /** |
|
208 | + * In this mode, only the path relative to the source folder |
|
209 | + * will be included in the files list. |
|
210 | + * |
|
211 | + * @return FileHelper_FileFinder |
|
212 | + */ |
|
213 | 213 | public function setPathmodeRelative() : FileHelper_FileFinder |
214 | 214 | { |
215 | 215 | return $this->setPathmode(self::PATH_MODE_RELATIVE); |
216 | 216 | } |
217 | 217 | |
218 | - /** |
|
219 | - * In this mode, the full, absolute paths to the files will |
|
220 | - * be included in the files list. |
|
221 | - * |
|
222 | - * @return FileHelper_FileFinder |
|
223 | - */ |
|
218 | + /** |
|
219 | + * In this mode, the full, absolute paths to the files will |
|
220 | + * be included in the files list. |
|
221 | + * |
|
222 | + * @return FileHelper_FileFinder |
|
223 | + */ |
|
224 | 224 | public function setPathmodeAbsolute() : FileHelper_FileFinder |
225 | 225 | { |
226 | 226 | return $this->setPathmode(self::PATH_MODE_ABSOLUTE); |
227 | 227 | } |
228 | 228 | |
229 | - /** |
|
230 | - * This sets a character or string to replace the slashes |
|
231 | - * in the paths with. |
|
232 | - * |
|
233 | - * This is used for example in the `getPHPClassNames()` |
|
234 | - * method, to return files from subfolders as class names |
|
235 | - * using the "_" character: |
|
236 | - * |
|
237 | - * Subfolder/To/File.php => Subfolder_To_File.php |
|
238 | - * |
|
239 | - * @param string $character |
|
240 | - * @return \AppUtils\FileHelper_FileFinder |
|
241 | - */ |
|
229 | + /** |
|
230 | + * This sets a character or string to replace the slashes |
|
231 | + * in the paths with. |
|
232 | + * |
|
233 | + * This is used for example in the `getPHPClassNames()` |
|
234 | + * method, to return files from subfolders as class names |
|
235 | + * using the "_" character: |
|
236 | + * |
|
237 | + * Subfolder/To/File.php => Subfolder_To_File.php |
|
238 | + * |
|
239 | + * @param string $character |
|
240 | + * @return \AppUtils\FileHelper_FileFinder |
|
241 | + */ |
|
242 | 242 | public function setSlashReplacement(string $character) : FileHelper_FileFinder |
243 | 243 | { |
244 | 244 | return $this->setOption('slash-replacement', $character); |
@@ -249,12 +249,12 @@ discard block |
||
249 | 249 | return $this->setOption('pathmode', $mode); |
250 | 250 | } |
251 | 251 | |
252 | - /** |
|
253 | - * Retrieves a list of all matching file names/paths, |
|
254 | - * depending on the selected options. |
|
255 | - * |
|
256 | - * @return array |
|
257 | - */ |
|
252 | + /** |
|
253 | + * Retrieves a list of all matching file names/paths, |
|
254 | + * depending on the selected options. |
|
255 | + * |
|
256 | + * @return array |
|
257 | + */ |
|
258 | 258 | public function getAll() : array |
259 | 259 | { |
260 | 260 | $this->find($this->path, true); |
@@ -262,24 +262,24 @@ discard block |
||
262 | 262 | return $this->found; |
263 | 263 | } |
264 | 264 | |
265 | - /** |
|
266 | - * Retrieves only PHP files. Can be combined with other |
|
267 | - * options like enabling recursion into subfolders. |
|
268 | - * |
|
269 | - * @return array |
|
270 | - */ |
|
265 | + /** |
|
266 | + * Retrieves only PHP files. Can be combined with other |
|
267 | + * options like enabling recursion into subfolders. |
|
268 | + * |
|
269 | + * @return array |
|
270 | + */ |
|
271 | 271 | public function getPHPFiles() : array |
272 | 272 | { |
273 | 273 | $this->includeExtensions(array('php')); |
274 | 274 | return $this->getAll(); |
275 | 275 | } |
276 | 276 | |
277 | - /** |
|
278 | - * Generates PHP class names from file paths: it replaces |
|
279 | - * slashes with underscores, and removes file extensions. |
|
280 | - * |
|
281 | - * @return array An array of PHP file names without extension. |
|
282 | - */ |
|
277 | + /** |
|
278 | + * Generates PHP class names from file paths: it replaces |
|
279 | + * slashes with underscores, and removes file extensions. |
|
280 | + * |
|
281 | + * @return array An array of PHP file names without extension. |
|
282 | + */ |
|
283 | 283 | public function getPHPClassNames() : array |
284 | 284 | { |
285 | 285 | $this->includeExtensions(array('php')); |
@@ -350,13 +350,13 @@ discard block |
||
350 | 350 | return $path; |
351 | 351 | } |
352 | 352 | |
353 | - /** |
|
354 | - * Checks whether the specified extension is allowed |
|
355 | - * with the current settings. |
|
356 | - * |
|
357 | - * @param string $extension |
|
358 | - * @return bool |
|
359 | - */ |
|
353 | + /** |
|
354 | + * Checks whether the specified extension is allowed |
|
355 | + * with the current settings. |
|
356 | + * |
|
357 | + * @param string $extension |
|
358 | + * @return bool |
|
359 | + */ |
|
360 | 360 | protected function filterExclusion(string $extension) : bool |
361 | 361 | { |
362 | 362 | $include = $this->getOption('include-extensions'); |
@@ -378,12 +378,12 @@ discard block |
||
378 | 378 | return true; |
379 | 379 | } |
380 | 380 | |
381 | - /** |
|
382 | - * Adjusts the path according to the selected path mode. |
|
383 | - * |
|
384 | - * @param string $path |
|
385 | - * @return string |
|
386 | - */ |
|
381 | + /** |
|
382 | + * Adjusts the path according to the selected path mode. |
|
383 | + * |
|
384 | + * @param string $path |
|
385 | + * @return string |
|
386 | + */ |
|
387 | 387 | protected function filterPath(string $path) : string |
388 | 388 | { |
389 | 389 | switch($this->getStringOption('pathmode')) |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * @see FileHelper_FileFinder |
8 | 8 | */ |
9 | 9 | |
10 | -declare(strict_types = 1); |
|
10 | +declare(strict_types=1); |
|
11 | 11 | |
12 | 12 | namespace AppUtils; |
13 | 13 | |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | { |
56 | 56 | $real = realpath($path); |
57 | 57 | |
58 | - if($real === false) |
|
58 | + if ($real === false) |
|
59 | 59 | { |
60 | 60 | throw new FileHelper_Exception( |
61 | 61 | 'Target path does not exist', |
@@ -290,22 +290,22 @@ discard block |
||
290 | 290 | return $this->getAll(); |
291 | 291 | } |
292 | 292 | |
293 | - protected function find(string $path, bool $isRoot=false) : void |
|
293 | + protected function find(string $path, bool $isRoot = false) : void |
|
294 | 294 | { |
295 | - if($isRoot) { |
|
295 | + if ($isRoot) { |
|
296 | 296 | $this->found = array(); |
297 | 297 | } |
298 | 298 | |
299 | 299 | $recursive = $this->getBoolOption('recursive'); |
300 | 300 | |
301 | 301 | $d = new \DirectoryIterator($path); |
302 | - foreach($d as $item) |
|
302 | + foreach ($d as $item) |
|
303 | 303 | { |
304 | 304 | $pathname = $item->getPathname(); |
305 | 305 | |
306 | - if($item->isDir()) |
|
306 | + if ($item->isDir()) |
|
307 | 307 | { |
308 | - if($recursive && !$item->isDot()) { |
|
308 | + if ($recursive && !$item->isDot()) { |
|
309 | 309 | $this->find($pathname); |
310 | 310 | } |
311 | 311 | |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | |
315 | 315 | $file = $this->filterFile($pathname); |
316 | 316 | |
317 | - if($file !== null) |
|
317 | + if ($file !== null) |
|
318 | 318 | { |
319 | 319 | $this->found[] = $file; |
320 | 320 | } |
@@ -327,23 +327,23 @@ discard block |
||
327 | 327 | |
328 | 328 | $extension = FileHelper::getExtension($path); |
329 | 329 | |
330 | - if(!$this->filterExclusion($extension)) { |
|
330 | + if (!$this->filterExclusion($extension)) { |
|
331 | 331 | return null; |
332 | 332 | } |
333 | 333 | |
334 | 334 | $path = $this->filterPath($path); |
335 | 335 | |
336 | - if($this->getOption('strip-extensions') === true) |
|
336 | + if ($this->getOption('strip-extensions') === true) |
|
337 | 337 | { |
338 | 338 | $path = str_replace('.'.$extension, '', $path); |
339 | 339 | } |
340 | 340 | |
341 | - if($path === '') { |
|
341 | + if ($path === '') { |
|
342 | 342 | return null; |
343 | 343 | } |
344 | 344 | |
345 | 345 | $replace = $this->getOption('slash-replacement'); |
346 | - if(!empty($replace)) { |
|
346 | + if (!empty($replace)) { |
|
347 | 347 | $path = str_replace('/', $replace, $path); |
348 | 348 | } |
349 | 349 | |
@@ -362,15 +362,15 @@ discard block |
||
362 | 362 | $include = $this->getOption('include-extensions'); |
363 | 363 | $exclude = $this->getOption('exclude-extensions'); |
364 | 364 | |
365 | - if(!empty($include)) |
|
365 | + if (!empty($include)) |
|
366 | 366 | { |
367 | - if(!in_array($extension, $include)) { |
|
367 | + if (!in_array($extension, $include)) { |
|
368 | 368 | return false; |
369 | 369 | } |
370 | 370 | } |
371 | - else if(!empty($exclude)) |
|
371 | + else if (!empty($exclude)) |
|
372 | 372 | { |
373 | - if(in_array($extension, $exclude)) { |
|
373 | + if (in_array($extension, $exclude)) { |
|
374 | 374 | return false; |
375 | 375 | } |
376 | 376 | } |
@@ -386,7 +386,7 @@ discard block |
||
386 | 386 | */ |
387 | 387 | protected function filterPath(string $path) : string |
388 | 388 | { |
389 | - switch($this->getStringOption('pathmode')) |
|
389 | + switch ($this->getStringOption('pathmode')) |
|
390 | 390 | { |
391 | 391 | case self::PATH_MODE_STRIP: |
392 | 392 | return basename($path); |
@@ -367,8 +367,7 @@ |
||
367 | 367 | if(!in_array($extension, $include)) { |
368 | 368 | return false; |
369 | 369 | } |
370 | - } |
|
371 | - else if(!empty($exclude)) |
|
370 | + } else if(!empty($exclude)) |
|
372 | 371 | { |
373 | 372 | if(in_array($extension, $exclude)) { |
374 | 373 | return false; |
@@ -23,44 +23,44 @@ |
||
23 | 23 | */ |
24 | 24 | class Request_URLComparer |
25 | 25 | { |
26 | - /** |
|
27 | - * @var Request |
|
28 | - */ |
|
26 | + /** |
|
27 | + * @var Request |
|
28 | + */ |
|
29 | 29 | protected $request; |
30 | 30 | |
31 | - /** |
|
32 | - * @var string |
|
33 | - */ |
|
31 | + /** |
|
32 | + * @var string |
|
33 | + */ |
|
34 | 34 | protected $sourceURL; |
35 | 35 | |
36 | - /** |
|
37 | - * @var string |
|
38 | - */ |
|
36 | + /** |
|
37 | + * @var string |
|
38 | + */ |
|
39 | 39 | protected $targetURL; |
40 | 40 | |
41 | - /** |
|
42 | - * @var array |
|
43 | - */ |
|
41 | + /** |
|
42 | + * @var array |
|
43 | + */ |
|
44 | 44 | protected $limitParams = array(); |
45 | 45 | |
46 | - /** |
|
47 | - * @var bool |
|
48 | - */ |
|
46 | + /** |
|
47 | + * @var bool |
|
48 | + */ |
|
49 | 49 | protected $isMatch = false; |
50 | 50 | |
51 | - /** |
|
52 | - * @var bool |
|
53 | - */ |
|
51 | + /** |
|
52 | + * @var bool |
|
53 | + */ |
|
54 | 54 | protected $ignoreFragment = true; |
55 | 55 | |
56 | - /** |
|
57 | - * @var URLInfo |
|
58 | - */ |
|
56 | + /** |
|
57 | + * @var URLInfo |
|
58 | + */ |
|
59 | 59 | protected $sourceInfo; |
60 | 60 | |
61 | - /** |
|
62 | - * @var URLInfo |
|
63 | - */ |
|
61 | + /** |
|
62 | + * @var URLInfo |
|
63 | + */ |
|
64 | 64 | protected $targetInfo; |
65 | 65 | |
66 | 66 | public function __construct(Request $request, string $sourceURL, string $targetURL) |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | |
80 | 80 | public function addLimitParam(string $name) : Request_URLComparer |
81 | 81 | { |
82 | - if(!in_array($name, $this->limitParams)) { |
|
82 | + if (!in_array($name, $this->limitParams)) { |
|
83 | 83 | $this->limitParams[] = $name; |
84 | 84 | } |
85 | 85 | |
@@ -88,14 +88,14 @@ discard block |
||
88 | 88 | |
89 | 89 | public function addLimitParams(array $names) : Request_URLComparer |
90 | 90 | { |
91 | - foreach($names as $name) { |
|
91 | + foreach ($names as $name) { |
|
92 | 92 | $this->addLimitParam($name); |
93 | 93 | } |
94 | 94 | |
95 | 95 | return $this; |
96 | 96 | } |
97 | 97 | |
98 | - public function setIgnoreFragment(bool $ignore=true) : Request_URLComparer |
|
98 | + public function setIgnoreFragment(bool $ignore = true) : Request_URLComparer |
|
99 | 99 | { |
100 | 100 | $this->ignoreFragment = $ignore; |
101 | 101 | return $this; |
@@ -121,13 +121,13 @@ discard block |
||
121 | 121 | 'query' |
122 | 122 | ); |
123 | 123 | |
124 | - if(!$this->ignoreFragment) { |
|
124 | + if (!$this->ignoreFragment) { |
|
125 | 125 | $keys[] = 'fragment'; |
126 | 126 | } |
127 | 127 | |
128 | - foreach($keys as $key) |
|
128 | + foreach ($keys as $key) |
|
129 | 129 | { |
130 | - if(!$this->compareKey($key)) { |
|
130 | + if (!$this->compareKey($key)) { |
|
131 | 131 | return false; |
132 | 132 | } |
133 | 133 | } |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | |
143 | 143 | $filter = 'filter_'.$key; |
144 | 144 | |
145 | - if(method_exists($this, $filter)) |
|
145 | + if (method_exists($this, $filter)) |
|
146 | 146 | { |
147 | 147 | $sVal = $this->$filter($sVal); |
148 | 148 | $tVal = $this->$filter($tVal); |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | protected function filter_path(string $path) : string |
155 | 155 | { |
156 | 156 | // fix double slashes in URLs |
157 | - while(stristr($path, '//')) { |
|
157 | + while (stristr($path, '//')) { |
|
158 | 158 | $path = str_replace('//', '/', $path); |
159 | 159 | } |
160 | 160 | |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | |
164 | 164 | protected function filter_query(string $query) : string |
165 | 165 | { |
166 | - if(empty($query)) { |
|
166 | + if (empty($query)) { |
|
167 | 167 | return ''; |
168 | 168 | } |
169 | 169 | |
@@ -178,15 +178,15 @@ discard block |
||
178 | 178 | |
179 | 179 | protected function limitParams(array $params) : array |
180 | 180 | { |
181 | - if(empty($this->limitParams)) { |
|
181 | + if (empty($this->limitParams)) { |
|
182 | 182 | return $params; |
183 | 183 | } |
184 | 184 | |
185 | 185 | $keep = array(); |
186 | 186 | |
187 | - foreach($this->limitParams as $name) |
|
187 | + foreach ($this->limitParams as $name) |
|
188 | 188 | { |
189 | - if(isset($params[$name])) { |
|
189 | + if (isset($params[$name])) { |
|
190 | 190 | $keep[$name] = $params[$name]; |
191 | 191 | } |
192 | 192 | } |
@@ -56,26 +56,26 @@ |
||
56 | 56 | { |
57 | 57 | $normalized = $this->info->getScheme().'://'; |
58 | 58 | |
59 | - if($this->info->hasUsername()) { |
|
59 | + if ($this->info->hasUsername()) { |
|
60 | 60 | $normalized .= urlencode($this->info->getUsername()).':'.urlencode($this->info->getPassword()).'@'; |
61 | 61 | } |
62 | 62 | |
63 | 63 | $normalized .= $this->info->getHost(); |
64 | 64 | |
65 | - if($this->info->hasPort()) { |
|
65 | + if ($this->info->hasPort()) { |
|
66 | 66 | $normalized .= ':'.$this->info->getPort(); |
67 | 67 | } |
68 | 68 | |
69 | - if($this->info->hasPath()) { |
|
69 | + if ($this->info->hasPath()) { |
|
70 | 70 | $normalized .= $this->info->getPath(); |
71 | 71 | } |
72 | 72 | |
73 | 73 | $params = $this->info->getParams(); |
74 | - if(!empty($params)) { |
|
74 | + if (!empty($params)) { |
|
75 | 75 | $normalized .= '?'.http_build_query($params); |
76 | 76 | } |
77 | 77 | |
78 | - if($this->info->hasFragment()) { |
|
78 | + if ($this->info->hasFragment()) { |
|
79 | 79 | $normalized .= '#'.$this->info->getFragment(); |
80 | 80 | } |
81 | 81 |
@@ -39,42 +39,42 @@ discard block |
||
39 | 39 | const TYPE_PHONE = 'phone'; |
40 | 40 | const TYPE_URL = 'url'; |
41 | 41 | |
42 | - /** |
|
43 | - * The original URL that was passed to the constructor. |
|
44 | - * @var string |
|
45 | - */ |
|
42 | + /** |
|
43 | + * The original URL that was passed to the constructor. |
|
44 | + * @var string |
|
45 | + */ |
|
46 | 46 | protected $rawURL; |
47 | 47 | |
48 | - /** |
|
49 | - * @var array |
|
50 | - */ |
|
48 | + /** |
|
49 | + * @var array |
|
50 | + */ |
|
51 | 51 | protected $info; |
52 | 52 | |
53 | - /** |
|
54 | - * @var string[] |
|
55 | - */ |
|
53 | + /** |
|
54 | + * @var string[] |
|
55 | + */ |
|
56 | 56 | protected $excludedParams = array(); |
57 | 57 | |
58 | - /** |
|
59 | - * @var bool |
|
60 | - * @see URLInfo::setParamExclusion() |
|
61 | - */ |
|
58 | + /** |
|
59 | + * @var bool |
|
60 | + * @see URLInfo::setParamExclusion() |
|
61 | + */ |
|
62 | 62 | protected $paramExclusion = false; |
63 | 63 | |
64 | - /** |
|
65 | - * @var array |
|
66 | - * @see URLInfo::getTypeLabel() |
|
67 | - */ |
|
64 | + /** |
|
65 | + * @var array |
|
66 | + * @see URLInfo::getTypeLabel() |
|
67 | + */ |
|
68 | 68 | protected static $typeLabels; |
69 | 69 | |
70 | - /** |
|
71 | - * @var bool |
|
72 | - */ |
|
70 | + /** |
|
71 | + * @var bool |
|
72 | + */ |
|
73 | 73 | protected $highlightExcluded = false; |
74 | 74 | |
75 | - /** |
|
76 | - * @var array |
|
77 | - */ |
|
75 | + /** |
|
76 | + * @var array |
|
77 | + */ |
|
78 | 78 | protected $infoKeys = array( |
79 | 79 | 'scheme', |
80 | 80 | 'host', |
@@ -86,19 +86,19 @@ discard block |
||
86 | 86 | 'fragment' |
87 | 87 | ); |
88 | 88 | |
89 | - /** |
|
90 | - * @var string |
|
91 | - */ |
|
89 | + /** |
|
90 | + * @var string |
|
91 | + */ |
|
92 | 92 | protected $url; |
93 | 93 | |
94 | - /** |
|
95 | - * @var URLInfo_Parser |
|
96 | - */ |
|
94 | + /** |
|
95 | + * @var URLInfo_Parser |
|
96 | + */ |
|
97 | 97 | protected $parser; |
98 | 98 | |
99 | - /** |
|
100 | - * @var URLInfo_Normalizer |
|
101 | - */ |
|
99 | + /** |
|
100 | + * @var URLInfo_Normalizer |
|
101 | + */ |
|
102 | 102 | protected $normalizer; |
103 | 103 | |
104 | 104 | public function __construct(string $url) |
@@ -110,13 +110,13 @@ discard block |
||
110 | 110 | $this->info = $this->parser->getInfo(); |
111 | 111 | } |
112 | 112 | |
113 | - /** |
|
114 | - * Filters an URL: removes control characters and the |
|
115 | - * like to have a clean URL to work with. |
|
116 | - * |
|
117 | - * @param string $url |
|
118 | - * @return string |
|
119 | - */ |
|
113 | + /** |
|
114 | + * Filters an URL: removes control characters and the |
|
115 | + * like to have a clean URL to work with. |
|
116 | + * |
|
117 | + * @param string $url |
|
118 | + * @return string |
|
119 | + */ |
|
120 | 120 | public static function filterURL(string $url) |
121 | 121 | { |
122 | 122 | return URLInfo_Filter::filter($url); |
@@ -146,12 +146,12 @@ discard block |
||
146 | 146 | return $this->info['type'] === self::TYPE_PHONE; |
147 | 147 | } |
148 | 148 | |
149 | - /** |
|
150 | - * Whether the URL is a regular URL, not one of the |
|
151 | - * other types like a phone number or email address. |
|
152 | - * |
|
153 | - * @return bool |
|
154 | - */ |
|
149 | + /** |
|
150 | + * Whether the URL is a regular URL, not one of the |
|
151 | + * other types like a phone number or email address. |
|
152 | + * |
|
153 | + * @return bool |
|
154 | + */ |
|
155 | 155 | public function isURL() : bool |
156 | 156 | { |
157 | 157 | $host = $this->getHost(); |
@@ -163,20 +163,20 @@ discard block |
||
163 | 163 | return $this->parser->isValid(); |
164 | 164 | } |
165 | 165 | |
166 | - /** |
|
167 | - * Retrieves the host name, or an empty string if none is present. |
|
168 | - * |
|
169 | - * @return string |
|
170 | - */ |
|
166 | + /** |
|
167 | + * Retrieves the host name, or an empty string if none is present. |
|
168 | + * |
|
169 | + * @return string |
|
170 | + */ |
|
171 | 171 | public function getHost() : string |
172 | 172 | { |
173 | 173 | return $this->getInfoKey('host'); |
174 | 174 | } |
175 | 175 | |
176 | - /** |
|
177 | - * Retrieves the path, or an empty string if none is present. |
|
178 | - * @return string |
|
179 | - */ |
|
176 | + /** |
|
177 | + * Retrieves the path, or an empty string if none is present. |
|
178 | + * @return string |
|
179 | + */ |
|
180 | 180 | public function getPath() : string |
181 | 181 | { |
182 | 182 | return $this->getInfoKey('path'); |
@@ -192,10 +192,10 @@ discard block |
||
192 | 192 | return $this->getInfoKey('scheme'); |
193 | 193 | } |
194 | 194 | |
195 | - /** |
|
196 | - * Retrieves the port specified in the URL, or -1 if none is preseent. |
|
197 | - * @return int |
|
198 | - */ |
|
195 | + /** |
|
196 | + * Retrieves the port specified in the URL, or -1 if none is preseent. |
|
197 | + * @return int |
|
198 | + */ |
|
199 | 199 | public function getPort() : int |
200 | 200 | { |
201 | 201 | $port = $this->getInfoKey('port'); |
@@ -207,13 +207,13 @@ discard block |
||
207 | 207 | return -1; |
208 | 208 | } |
209 | 209 | |
210 | - /** |
|
211 | - * Retrieves the raw query string, or an empty string if none is present. |
|
212 | - * |
|
213 | - * @return string |
|
214 | - * |
|
215 | - * @see URLInfo::getParams() |
|
216 | - */ |
|
210 | + /** |
|
211 | + * Retrieves the raw query string, or an empty string if none is present. |
|
212 | + * |
|
213 | + * @return string |
|
214 | + * |
|
215 | + * @see URLInfo::getParams() |
|
216 | + */ |
|
217 | 217 | public function getQuery() : string |
218 | 218 | { |
219 | 219 | return $this->getInfoKey('query'); |
@@ -229,20 +229,20 @@ discard block |
||
229 | 229 | return $this->getInfoKey('pass'); |
230 | 230 | } |
231 | 231 | |
232 | - /** |
|
233 | - * Whether the URL contains a port number. |
|
234 | - * @return bool |
|
235 | - */ |
|
232 | + /** |
|
233 | + * Whether the URL contains a port number. |
|
234 | + * @return bool |
|
235 | + */ |
|
236 | 236 | public function hasPort() : bool |
237 | 237 | { |
238 | 238 | return $this->getPort() !== -1; |
239 | 239 | } |
240 | 240 | |
241 | - /** |
|
242 | - * Alias for the hasParams() method. |
|
243 | - * @return bool |
|
244 | - * @see URLInfo::hasParams() |
|
245 | - */ |
|
241 | + /** |
|
242 | + * Alias for the hasParams() method. |
|
243 | + * @return bool |
|
244 | + * @see URLInfo::hasParams() |
|
245 | + */ |
|
246 | 246 | public function hasQuery() : bool |
247 | 247 | { |
248 | 248 | return $this->hasParams(); |
@@ -300,25 +300,25 @@ discard block |
||
300 | 300 | return $this->normalizer->normalize(); |
301 | 301 | } |
302 | 302 | |
303 | - /** |
|
304 | - * Creates a hash of the URL, which can be used for comparisons. |
|
305 | - * Since any parameters in the URL's query are sorted alphabetically, |
|
306 | - * the same links with a different parameter order will have the |
|
307 | - * same hash. |
|
308 | - * |
|
309 | - * @return string |
|
310 | - */ |
|
303 | + /** |
|
304 | + * Creates a hash of the URL, which can be used for comparisons. |
|
305 | + * Since any parameters in the URL's query are sorted alphabetically, |
|
306 | + * the same links with a different parameter order will have the |
|
307 | + * same hash. |
|
308 | + * |
|
309 | + * @return string |
|
310 | + */ |
|
311 | 311 | public function getHash() |
312 | 312 | { |
313 | 313 | return \AppUtils\ConvertHelper::string2shortHash($this->getNormalized()); |
314 | 314 | } |
315 | 315 | |
316 | - /** |
|
317 | - * Highlights the URL using HTML tags with specific highlighting |
|
318 | - * class names. |
|
319 | - * |
|
320 | - * @return string Will return an empty string if the URL is not valid. |
|
321 | - */ |
|
316 | + /** |
|
317 | + * Highlights the URL using HTML tags with specific highlighting |
|
318 | + * class names. |
|
319 | + * |
|
320 | + * @return string Will return an empty string if the URL is not valid. |
|
321 | + */ |
|
322 | 322 | public function getHighlighted() : string |
323 | 323 | { |
324 | 324 | if(!$this->isValid()) { |
@@ -352,15 +352,15 @@ discard block |
||
352 | 352 | return count($params); |
353 | 353 | } |
354 | 354 | |
355 | - /** |
|
356 | - * Retrieves all parameters specified in the url, |
|
357 | - * if any, as an associative array. |
|
358 | - * |
|
359 | - * NOTE: Ignores parameters that have been added |
|
360 | - * to the excluded parameters list. |
|
361 | - * |
|
362 | - * @return array |
|
363 | - */ |
|
355 | + /** |
|
356 | + * Retrieves all parameters specified in the url, |
|
357 | + * if any, as an associative array. |
|
358 | + * |
|
359 | + * NOTE: Ignores parameters that have been added |
|
360 | + * to the excluded parameters list. |
|
361 | + * |
|
362 | + * @return array |
|
363 | + */ |
|
364 | 364 | public function getParams() : array |
365 | 365 | { |
366 | 366 | if(!$this->paramExclusion || empty($this->excludedParams)) { |
@@ -378,22 +378,22 @@ discard block |
||
378 | 378 | return $keep; |
379 | 379 | } |
380 | 380 | |
381 | - /** |
|
382 | - * Retrieves the names of all parameters present in the URL, if any. |
|
383 | - * @return string[] |
|
384 | - */ |
|
381 | + /** |
|
382 | + * Retrieves the names of all parameters present in the URL, if any. |
|
383 | + * @return string[] |
|
384 | + */ |
|
385 | 385 | public function getParamNames() : array |
386 | 386 | { |
387 | 387 | $params = $this->getParams(); |
388 | 388 | return array_keys($params); |
389 | 389 | } |
390 | 390 | |
391 | - /** |
|
392 | - * Retrieves a specific parameter value from the URL. |
|
393 | - * |
|
394 | - * @param string $name |
|
395 | - * @return string The parameter value, or an empty string if it does not exist. |
|
396 | - */ |
|
391 | + /** |
|
392 | + * Retrieves a specific parameter value from the URL. |
|
393 | + * |
|
394 | + * @param string $name |
|
395 | + * @return string The parameter value, or an empty string if it does not exist. |
|
396 | + */ |
|
397 | 397 | public function getParam(string $name) : string |
398 | 398 | { |
399 | 399 | if(isset($this->info['params'][$name])) { |
@@ -403,16 +403,16 @@ discard block |
||
403 | 403 | return ''; |
404 | 404 | } |
405 | 405 | |
406 | - /** |
|
407 | - * Excludes an URL parameter entirely if present: |
|
408 | - * the parser will act as if the parameter was not |
|
409 | - * even present in the source URL, effectively |
|
410 | - * stripping it. |
|
411 | - * |
|
412 | - * @param string $name |
|
413 | - * @param string $reason A human readable explanation why this is excluded - used when highlighting links. |
|
414 | - * @return URLInfo |
|
415 | - */ |
|
406 | + /** |
|
407 | + * Excludes an URL parameter entirely if present: |
|
408 | + * the parser will act as if the parameter was not |
|
409 | + * even present in the source URL, effectively |
|
410 | + * stripping it. |
|
411 | + * |
|
412 | + * @param string $name |
|
413 | + * @param string $reason A human readable explanation why this is excluded - used when highlighting links. |
|
414 | + * @return URLInfo |
|
415 | + */ |
|
416 | 416 | public function excludeParam(string $name, string $reason) : URLInfo |
417 | 417 | { |
418 | 418 | if(!isset($this->excludedParams[$name])) |
@@ -465,25 +465,25 @@ discard block |
||
465 | 465 | return self::$typeLabels[$this->getType()]; |
466 | 466 | } |
467 | 467 | |
468 | - /** |
|
469 | - * Whether excluded parameters should be highlighted in |
|
470 | - * a different color in the URL when using the |
|
471 | - * {@link URLInfo::getHighlighted()} method. |
|
472 | - * |
|
473 | - * @param bool $highlight |
|
474 | - * @return URLInfo |
|
475 | - */ |
|
468 | + /** |
|
469 | + * Whether excluded parameters should be highlighted in |
|
470 | + * a different color in the URL when using the |
|
471 | + * {@link URLInfo::getHighlighted()} method. |
|
472 | + * |
|
473 | + * @param bool $highlight |
|
474 | + * @return URLInfo |
|
475 | + */ |
|
476 | 476 | public function setHighlightExcluded(bool $highlight=true) : URLInfo |
477 | 477 | { |
478 | 478 | $this->highlightExcluded = $highlight; |
479 | 479 | return $this; |
480 | 480 | } |
481 | 481 | |
482 | - /** |
|
483 | - * Returns an array with all relevant URL information. |
|
484 | - * |
|
485 | - * @return array |
|
486 | - */ |
|
482 | + /** |
|
483 | + * Returns an array with all relevant URL information. |
|
484 | + * |
|
485 | + * @return array |
|
486 | + */ |
|
487 | 487 | public function toArray() : array |
488 | 488 | { |
489 | 489 | return array( |
@@ -527,24 +527,24 @@ discard block |
||
527 | 527 | return $this; |
528 | 528 | } |
529 | 529 | |
530 | - /** |
|
531 | - * Whether the parameter exclusion mode is enabled: |
|
532 | - * In this case, if any parameters have been added to the |
|
533 | - * exclusion list, all relevant methods will exclude these. |
|
534 | - * |
|
535 | - * @return bool |
|
536 | - */ |
|
530 | + /** |
|
531 | + * Whether the parameter exclusion mode is enabled: |
|
532 | + * In this case, if any parameters have been added to the |
|
533 | + * exclusion list, all relevant methods will exclude these. |
|
534 | + * |
|
535 | + * @return bool |
|
536 | + */ |
|
537 | 537 | public function isParamExclusionEnabled() : bool |
538 | 538 | { |
539 | 539 | return $this->paramExclusion; |
540 | 540 | } |
541 | 541 | |
542 | - /** |
|
543 | - * Checks whether the link contains any parameters that |
|
544 | - * are on the list of excluded parameters. |
|
545 | - * |
|
546 | - * @return bool |
|
547 | - */ |
|
542 | + /** |
|
543 | + * Checks whether the link contains any parameters that |
|
544 | + * are on the list of excluded parameters. |
|
545 | + * |
|
546 | + * @return bool |
|
547 | + */ |
|
548 | 548 | public function containsExcludedParams() : bool |
549 | 549 | { |
550 | 550 | if(empty($this->excludedParams)) { |
@@ -612,17 +612,17 @@ discard block |
||
612 | 612 | return $this->highlightExcluded; |
613 | 613 | } |
614 | 614 | |
615 | - /** |
|
616 | - * Checks if the URL exists, i.e. can be connected to. Will return |
|
617 | - * true if the returned HTTP status code is `200` or `302`. |
|
618 | - * |
|
619 | - * NOTE: If the target URL requires HTTP authentication, the username |
|
620 | - * and password should be integrated into the URL. |
|
621 | - * |
|
622 | - * @param bool $verifySSL Whether to enable SSL certificate checks. Warning: do not use this in production. |
|
623 | - * @return bool |
|
624 | - * @throws BaseException |
|
625 | - */ |
|
615 | + /** |
|
616 | + * Checks if the URL exists, i.e. can be connected to. Will return |
|
617 | + * true if the returned HTTP status code is `200` or `302`. |
|
618 | + * |
|
619 | + * NOTE: If the target URL requires HTTP authentication, the username |
|
620 | + * and password should be integrated into the URL. |
|
621 | + * |
|
622 | + * @param bool $verifySSL Whether to enable SSL certificate checks. Warning: do not use this in production. |
|
623 | + * @return bool |
|
624 | + * @throws BaseException |
|
625 | + */ |
|
626 | 626 | public function tryConnect(bool $verifySSL=true) : bool |
627 | 627 | { |
628 | 628 | requireCURL(); |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | { |
201 | 201 | $port = $this->getInfoKey('port'); |
202 | 202 | |
203 | - if(!empty($port)) { |
|
203 | + if (!empty($port)) { |
|
204 | 204 | return (int)$port; |
205 | 205 | } |
206 | 206 | |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | |
281 | 281 | protected function getInfoKey(string $name) : string |
282 | 282 | { |
283 | - if(isset($this->info[$name])) { |
|
283 | + if (isset($this->info[$name])) { |
|
284 | 284 | return (string)$this->info[$name]; |
285 | 285 | } |
286 | 286 | |
@@ -289,11 +289,11 @@ discard block |
||
289 | 289 | |
290 | 290 | public function getNormalized() : string |
291 | 291 | { |
292 | - if(!$this->isValid()) { |
|
292 | + if (!$this->isValid()) { |
|
293 | 293 | return ''; |
294 | 294 | } |
295 | 295 | |
296 | - if(!isset($this->normalizer)) { |
|
296 | + if (!isset($this->normalizer)) { |
|
297 | 297 | $this->normalizer = new URLInfo_Normalizer($this); |
298 | 298 | } |
299 | 299 | |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | */ |
322 | 322 | public function getHighlighted() : string |
323 | 323 | { |
324 | - if(!$this->isValid()) { |
|
324 | + if (!$this->isValid()) { |
|
325 | 325 | return ''; |
326 | 326 | } |
327 | 327 | |
@@ -363,14 +363,14 @@ discard block |
||
363 | 363 | */ |
364 | 364 | public function getParams() : array |
365 | 365 | { |
366 | - if(!$this->paramExclusion || empty($this->excludedParams)) { |
|
366 | + if (!$this->paramExclusion || empty($this->excludedParams)) { |
|
367 | 367 | return $this->info['params']; |
368 | 368 | } |
369 | 369 | |
370 | 370 | $keep = array(); |
371 | - foreach($this->info['params'] as $name => $value) |
|
371 | + foreach ($this->info['params'] as $name => $value) |
|
372 | 372 | { |
373 | - if(!isset($this->excludedParams[$name])) { |
|
373 | + if (!isset($this->excludedParams[$name])) { |
|
374 | 374 | $keep[$name] = $value; |
375 | 375 | } |
376 | 376 | } |
@@ -396,7 +396,7 @@ discard block |
||
396 | 396 | */ |
397 | 397 | public function getParam(string $name) : string |
398 | 398 | { |
399 | - if(isset($this->info['params'][$name])) { |
|
399 | + if (isset($this->info['params'][$name])) { |
|
400 | 400 | return $this->info['params'][$name]; |
401 | 401 | } |
402 | 402 | |
@@ -415,7 +415,7 @@ discard block |
||
415 | 415 | */ |
416 | 416 | public function excludeParam(string $name, string $reason) : URLInfo |
417 | 417 | { |
418 | - if(!isset($this->excludedParams[$name])) |
|
418 | + if (!isset($this->excludedParams[$name])) |
|
419 | 419 | { |
420 | 420 | $this->excludedParams[$name] = $reason; |
421 | 421 | $this->setParamExclusion(); |
@@ -441,7 +441,7 @@ discard block |
||
441 | 441 | |
442 | 442 | public function getTypeLabel() : string |
443 | 443 | { |
444 | - if(!isset(self::$typeLabels)) |
|
444 | + if (!isset(self::$typeLabels)) |
|
445 | 445 | { |
446 | 446 | self::$typeLabels = array( |
447 | 447 | self::TYPE_EMAIL => t('Email'), |
@@ -453,7 +453,7 @@ discard block |
||
453 | 453 | |
454 | 454 | $type = $this->getType(); |
455 | 455 | |
456 | - if(!isset(self::$typeLabels[$type])) |
|
456 | + if (!isset(self::$typeLabels[$type])) |
|
457 | 457 | { |
458 | 458 | throw new BaseException( |
459 | 459 | sprintf('Unknown URL type label for type [%s].', $type), |
@@ -473,7 +473,7 @@ discard block |
||
473 | 473 | * @param bool $highlight |
474 | 474 | * @return URLInfo |
475 | 475 | */ |
476 | - public function setHighlightExcluded(bool $highlight=true) : URLInfo |
|
476 | + public function setHighlightExcluded(bool $highlight = true) : URLInfo |
|
477 | 477 | { |
478 | 478 | $this->highlightExcluded = $highlight; |
479 | 479 | return $this; |
@@ -521,7 +521,7 @@ discard block |
||
521 | 521 | * @see URLInfo::isParamExclusionEnabled() |
522 | 522 | * @see URLInfo::setHighlightExcluded() |
523 | 523 | */ |
524 | - public function setParamExclusion(bool $enabled=true) : URLInfo |
|
524 | + public function setParamExclusion(bool $enabled = true) : URLInfo |
|
525 | 525 | { |
526 | 526 | $this->paramExclusion = $enabled; |
527 | 527 | return $this; |
@@ -547,13 +547,13 @@ discard block |
||
547 | 547 | */ |
548 | 548 | public function containsExcludedParams() : bool |
549 | 549 | { |
550 | - if(empty($this->excludedParams)) { |
|
550 | + if (empty($this->excludedParams)) { |
|
551 | 551 | return false; |
552 | 552 | } |
553 | 553 | |
554 | 554 | $names = array_keys($this->info['params']); |
555 | - foreach($names as $name) { |
|
556 | - if(isset($this->excludedParams[$name])) { |
|
555 | + foreach ($names as $name) { |
|
556 | + if (isset($this->excludedParams[$name])) { |
|
557 | 557 | return true; |
558 | 558 | } |
559 | 559 | } |
@@ -569,7 +569,7 @@ discard block |
||
569 | 569 | |
570 | 570 | public function offsetSet($offset, $value) |
571 | 571 | { |
572 | - if(in_array($offset, $this->infoKeys)) { |
|
572 | + if (in_array($offset, $this->infoKeys)) { |
|
573 | 573 | $this->info[$offset] = $value; |
574 | 574 | } |
575 | 575 | } |
@@ -586,11 +586,11 @@ discard block |
||
586 | 586 | |
587 | 587 | public function offsetGet($offset) |
588 | 588 | { |
589 | - if($offset === 'port') { |
|
589 | + if ($offset === 'port') { |
|
590 | 590 | return $this->getPort(); |
591 | 591 | } |
592 | 592 | |
593 | - if(in_array($offset, $this->infoKeys)) { |
|
593 | + if (in_array($offset, $this->infoKeys)) { |
|
594 | 594 | return $this->getInfoKey($offset); |
595 | 595 | } |
596 | 596 | |
@@ -623,12 +623,12 @@ discard block |
||
623 | 623 | * @return bool |
624 | 624 | * @throws BaseException |
625 | 625 | */ |
626 | - public function tryConnect(bool $verifySSL=true) : bool |
|
626 | + public function tryConnect(bool $verifySSL = true) : bool |
|
627 | 627 | { |
628 | 628 | requireCURL(); |
629 | 629 | |
630 | 630 | $ch = curl_init(); |
631 | - if($ch === false) |
|
631 | + if ($ch === false) |
|
632 | 632 | { |
633 | 633 | throw new BaseException( |
634 | 634 | 'Could not initialize a new cURL instance.', |
@@ -644,13 +644,13 @@ discard block |
||
644 | 644 | curl_setopt($ch, CURLOPT_TIMEOUT, 10); |
645 | 645 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
646 | 646 | |
647 | - if(!$verifySSL) |
|
647 | + if (!$verifySSL) |
|
648 | 648 | { |
649 | 649 | curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); |
650 | 650 | curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); |
651 | 651 | } |
652 | 652 | |
653 | - if($this->hasUsername()) |
|
653 | + if ($this->hasUsername()) |
|
654 | 654 | { |
655 | 655 | curl_setopt($ch, CURLOPT_USERNAME, $this->getUsername()); |
656 | 656 | curl_setopt($ch, CURLOPT_PASSWORD, $this->getPassword()); |