Passed
Push — master ( 4a79ed...7ae6f1 )
by Sebastian
02:30
created
src/URLInfo/Parser.php 1 patch
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -20,24 +20,24 @@  discard block
 block discarded – undo
20 20
  */
21 21
 class URLInfo_Parser
22 22
 {
23
-   /**
24
-    * @var string
25
-    */
23
+    /**
24
+     * @var string
25
+     */
26 26
     protected $url;
27 27
     
28
-   /**
29
-    * @var bool
30
-    */
28
+    /**
29
+     * @var bool
30
+     */
31 31
     protected $isValid = false;
32 32
     
33
-   /**
34
-    * @var array
35
-    */
33
+    /**
34
+     * @var array
35
+     */
36 36
     protected $info;
37 37
     
38
-   /**
39
-    * @var array|NULL
40
-    */
38
+    /**
39
+     * @var array|NULL
40
+     */
41 41
     protected $error;
42 42
     
43 43
     /**
@@ -177,11 +177,11 @@  discard block
 block discarded – undo
177 177
         return false;
178 178
     }
179 179
 
180
-   /**
181
-    * Goes through all information in the parse_url result
182
-    * array, and attempts to fix any user errors in formatting
183
-    * that can be recovered from, mostly regarding stray spaces.
184
-    */
180
+    /**
181
+     * Goes through all information in the parse_url result
182
+     * array, and attempts to fix any user errors in formatting
183
+     * that can be recovered from, mostly regarding stray spaces.
184
+     */
185 185
     protected function filterParsed()
186 186
     {
187 187
         foreach($this->info as $key => $val)
Please login to merge, or discard this patch.
src/URLInfo/Highlighter.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -20,9 +20,9 @@
 block discarded – undo
20 20
  */
21 21
 class URLInfo_Highlighter
22 22
 {
23
-   /**
24
-    * @var URLInfo
25
-    */
23
+    /**
24
+     * @var URLInfo
25
+     */
26 26
     protected $info;
27 27
     
28 28
     public function __construct(URLInfo $info)
Please login to merge, or discard this patch.
src/URLInfo.php 1 patch
Indentation   +141 added lines, -141 removed lines patch added patch discarded remove patch
@@ -37,42 +37,42 @@  discard block
 block discarded – undo
37 37
     const TYPE_PHONE = 'phone';
38 38
     const TYPE_URL = 'url';
39 39
     
40
-   /**
41
-    * The original URL that was passed to the constructor.
42
-    * @var string
43
-    */
40
+    /**
41
+     * The original URL that was passed to the constructor.
42
+     * @var string
43
+     */
44 44
     protected $rawURL;
45 45
 
46
-   /**
47
-    * @var array
48
-    */
46
+    /**
47
+     * @var array
48
+     */
49 49
     protected $info;
50 50
     
51
-   /**
52
-    * @var string[]
53
-    */
51
+    /**
52
+     * @var string[]
53
+     */
54 54
     protected $excludedParams = array();
55 55
     
56
-   /**
57
-    * @var bool
58
-    * @see URLInfo::setParamExclusion()
59
-    */
56
+    /**
57
+     * @var bool
58
+     * @see URLInfo::setParamExclusion()
59
+     */
60 60
     protected $paramExclusion = false;
61 61
     
62
-   /**
63
-    * @var array
64
-    * @see URLInfo::getTypeLabel()
65
-    */
62
+    /**
63
+     * @var array
64
+     * @see URLInfo::getTypeLabel()
65
+     */
66 66
     protected static $typeLabels;
67 67
     
68
-   /**
69
-    * @var bool
70
-    */
68
+    /**
69
+     * @var bool
70
+     */
71 71
     protected $highlightExcluded = false;
72 72
     
73
-   /**
74
-    * @var array
75
-    */
73
+    /**
74
+     * @var array
75
+     */
76 76
     protected $infoKeys = array(
77 77
         'scheme',
78 78
         'host',
@@ -84,14 +84,14 @@  discard block
 block discarded – undo
84 84
         'fragment'
85 85
     );
86 86
     
87
-   /**
88
-    * @var string
89
-    */
87
+    /**
88
+     * @var string
89
+     */
90 90
     protected $url;
91 91
     
92
-   /**
93
-    * @var URLInfo_Parser
94
-    */
92
+    /**
93
+     * @var URLInfo_Parser
94
+     */
95 95
     protected $parser;
96 96
     
97 97
     public function __construct(string $url)
@@ -103,13 +103,13 @@  discard block
 block discarded – undo
103 103
         $this->info = $this->parser->getInfo();
104 104
     }
105 105
     
106
-   /**
107
-    * Filters an URL: removes control characters and the
108
-    * like to have a clean URL to work with.
109
-    * 
110
-    * @param string $url
111
-    * @return string
112
-    */
106
+    /**
107
+     * Filters an URL: removes control characters and the
108
+     * like to have a clean URL to work with.
109
+     * 
110
+     * @param string $url
111
+     * @return string
112
+     */
113 113
     public static function filterURL(string $url)
114 114
     {
115 115
         return URLInfo_Filter::filter($url);
@@ -143,12 +143,12 @@  discard block
 block discarded – undo
143 143
         return $this->info['type'] === self::TYPE_PHONE;
144 144
     }
145 145
     
146
-   /**
147
-    * Whether the URL is a regular URL, not one of the 
148
-    * other types like a phone number or email address.
149
-    * 
150
-    * @return bool
151
-    */
146
+    /**
147
+     * Whether the URL is a regular URL, not one of the 
148
+     * other types like a phone number or email address.
149
+     * 
150
+     * @return bool
151
+     */
152 152
     public function isURL() : bool
153 153
     {
154 154
         $host = $this->getHost();
@@ -160,20 +160,20 @@  discard block
 block discarded – undo
160 160
         return $this->parser->isValid();
161 161
     }
162 162
     
163
-   /**
164
-    * Retrieves the host name, or an empty string if none is present.
165
-    * 
166
-    * @return string
167
-    */
163
+    /**
164
+     * Retrieves the host name, or an empty string if none is present.
165
+     * 
166
+     * @return string
167
+     */
168 168
     public function getHost() : string
169 169
     {
170 170
         return $this->getInfoKey('host');
171 171
     }
172 172
     
173
-   /**
174
-    * Retrieves the path, or an empty string if none is present.
175
-    * @return string
176
-    */
173
+    /**
174
+     * Retrieves the path, or an empty string if none is present.
175
+     * @return string
176
+     */
177 177
     public function getPath() : string
178 178
     {
179 179
         return $this->getInfoKey('path');
@@ -189,10 +189,10 @@  discard block
 block discarded – undo
189 189
         return $this->getInfoKey('scheme');
190 190
     }
191 191
     
192
-   /**
193
-    * Retrieves the port specified in the URL, or -1 if none is preseent.
194
-    * @return int
195
-    */
192
+    /**
193
+     * Retrieves the port specified in the URL, or -1 if none is preseent.
194
+     * @return int
195
+     */
196 196
     public function getPort() : int
197 197
     {
198 198
         $port = $this->getInfoKey('port');
@@ -203,13 +203,13 @@  discard block
 block discarded – undo
203 203
         return -1;
204 204
     }
205 205
     
206
-   /**
207
-    * Retrieves the raw query string, or an empty string if none is present.
208
-    * 
209
-    * @return string
210
-    * 
211
-    * @see URLInfo::getParams()
212
-    */
206
+    /**
207
+     * Retrieves the raw query string, or an empty string if none is present.
208
+     * 
209
+     * @return string
210
+     * 
211
+     * @see URLInfo::getParams()
212
+     */
213 213
     public function getQuery() : string
214 214
     {
215 215
         return $this->getInfoKey('query');
@@ -225,20 +225,20 @@  discard block
 block discarded – undo
225 225
         return $this->getInfoKey('pass');
226 226
     }
227 227
     
228
-   /**
229
-    * Whether the URL contains a port number.
230
-    * @return bool
231
-    */
228
+    /**
229
+     * Whether the URL contains a port number.
230
+     * @return bool
231
+     */
232 232
     public function hasPort() : bool
233 233
     {
234 234
         return $this->getPort() !== -1;
235 235
     }
236 236
     
237
-   /**
238
-    * Alias for the hasParams() method.
239
-    * @return bool
240
-    * @see URLInfo::hasParams()
241
-    */
237
+    /**
238
+     * Alias for the hasParams() method.
239
+     * @return bool
240
+     * @see URLInfo::hasParams()
241
+     */
242 242
     public function hasQuery() : bool
243 243
     {
244 244
         return $this->hasParams();
@@ -319,25 +319,25 @@  discard block
 block discarded – undo
319 319
         return $normalized;
320 320
     }
321 321
     
322
-   /**
323
-    * Creates a hash of the URL, which can be used for comparisons.
324
-    * Since any parameters in the URL's query are sorted alphabetically,
325
-    * the same links with a different parameter order will have the 
326
-    * same hash.
327
-    * 
328
-    * @return string
329
-    */
322
+    /**
323
+     * Creates a hash of the URL, which can be used for comparisons.
324
+     * Since any parameters in the URL's query are sorted alphabetically,
325
+     * the same links with a different parameter order will have the 
326
+     * same hash.
327
+     * 
328
+     * @return string
329
+     */
330 330
     public function getHash()
331 331
     {
332 332
         return \AppUtils\ConvertHelper::string2shortHash($this->getNormalized());
333 333
     }
334 334
 
335
-   /**
336
-    * Highlights the URL using HTML tags with specific highlighting
337
-    * class names.
338
-    * 
339
-    * @return string Will return an empty string if the URL is not valid.
340
-    */
335
+    /**
336
+     * Highlights the URL using HTML tags with specific highlighting
337
+     * class names.
338
+     * 
339
+     * @return string Will return an empty string if the URL is not valid.
340
+     */
341 341
     public function getHighlighted() : string
342 342
     {
343 343
         if(!$this->isValid()) {
@@ -371,15 +371,15 @@  discard block
 block discarded – undo
371 371
         return count($params);
372 372
     }
373 373
     
374
-   /**
375
-    * Retrieves all parameters specified in the url,
376
-    * if any, as an associative array. 
377
-    * 
378
-    * NOTE: Ignores parameters that have been added
379
-    * to the excluded parameters list.
380
-    *
381
-    * @return array
382
-    */
374
+    /**
375
+     * Retrieves all parameters specified in the url,
376
+     * if any, as an associative array. 
377
+     * 
378
+     * NOTE: Ignores parameters that have been added
379
+     * to the excluded parameters list.
380
+     *
381
+     * @return array
382
+     */
383 383
     public function getParams() : array
384 384
     {
385 385
         if(!$this->paramExclusion || empty($this->excludedParams)) {
@@ -396,22 +396,22 @@  discard block
 block discarded – undo
396 396
         return $keep;
397 397
     }
398 398
     
399
-   /**
400
-    * Retrieves the names of all parameters present in the URL, if any.
401
-    * @return string[]
402
-    */
399
+    /**
400
+     * Retrieves the names of all parameters present in the URL, if any.
401
+     * @return string[]
402
+     */
403 403
     public function getParamNames() : array
404 404
     {
405 405
         $params = $this->getParams();
406 406
         return array_keys($params);
407 407
     }
408 408
     
409
-   /**
410
-    * Retrieves a specific parameter value from the URL.
411
-    * 
412
-    * @param string $name
413
-    * @return string The parameter value, or an empty string if it does not exist.
414
-    */
409
+    /**
410
+     * Retrieves a specific parameter value from the URL.
411
+     * 
412
+     * @param string $name
413
+     * @return string The parameter value, or an empty string if it does not exist.
414
+     */
415 415
     public function getParam(string $name) : string
416 416
     {
417 417
         if(isset($this->info['params'][$name])) {
@@ -421,16 +421,16 @@  discard block
 block discarded – undo
421 421
         return '';
422 422
     }
423 423
     
424
-   /**
425
-    * Excludes an URL parameter entirely if present:
426
-    * the parser will act as if the parameter was not
427
-    * even present in the source URL, effectively
428
-    * stripping it.
429
-    *
430
-    * @param string $name
431
-    * @param string $reason A human readable explanation why this is excluded - used when highlighting links.
432
-    * @return URLInfo
433
-    */
424
+    /**
425
+     * Excludes an URL parameter entirely if present:
426
+     * the parser will act as if the parameter was not
427
+     * even present in the source URL, effectively
428
+     * stripping it.
429
+     *
430
+     * @param string $name
431
+     * @param string $reason A human readable explanation why this is excluded - used when highlighting links.
432
+     * @return URLInfo
433
+     */
434 434
     public function excludeParam(string $name, string $reason) : URLInfo
435 435
     {
436 436
         if(!isset($this->excludedParams[$name]))
@@ -483,25 +483,25 @@  discard block
 block discarded – undo
483 483
         return self::$typeLabels[$this->getType()];
484 484
     }
485 485
 
486
-   /**
487
-    * Whether excluded parameters should be highlighted in
488
-    * a different color in the URL when using the
489
-    * {@link URLInfo::getHighlighted()} method.
490
-    *
491
-    * @param bool $highlight
492
-    * @return URLInfo
493
-    */
486
+    /**
487
+     * Whether excluded parameters should be highlighted in
488
+     * a different color in the URL when using the
489
+     * {@link URLInfo::getHighlighted()} method.
490
+     *
491
+     * @param bool $highlight
492
+     * @return URLInfo
493
+     */
494 494
     public function setHighlightExcluded(bool $highlight=true) : URLInfo
495 495
     {
496 496
         $this->highlightExcluded = $highlight;
497 497
         return $this;
498 498
     }
499 499
     
500
-   /**
501
-    * Returns an array with all relevant URL information.
502
-    * 
503
-    * @return array
504
-    */
500
+    /**
501
+     * Returns an array with all relevant URL information.
502
+     * 
503
+     * @return array
504
+     */
505 505
     public function toArray() : array
506 506
     {
507 507
         return array(
@@ -545,24 +545,24 @@  discard block
 block discarded – undo
545 545
         return $this;
546 546
     }
547 547
     
548
-   /**
549
-    * Whether the parameter exclusion mode is enabled:
550
-    * In this case, if any parameters have been added to the
551
-    * exclusion list, all relevant methods will exclude these.
552
-    *
553
-    * @return bool
554
-    */
548
+    /**
549
+     * Whether the parameter exclusion mode is enabled:
550
+     * In this case, if any parameters have been added to the
551
+     * exclusion list, all relevant methods will exclude these.
552
+     *
553
+     * @return bool
554
+     */
555 555
     public function isParamExclusionEnabled() : bool
556 556
     {
557 557
         return $this->paramExclusion;
558 558
     }
559 559
     
560
-   /**
561
-    * Checks whether the link contains any parameters that
562
-    * are on the list of excluded parameters.
563
-    *
564
-    * @return bool
565
-    */
560
+    /**
561
+     * Checks whether the link contains any parameters that
562
+     * are on the list of excluded parameters.
563
+     *
564
+     * @return bool
565
+     */
566 566
     public function containsExcludedParams() : bool
567 567
     {
568 568
         if(empty($this->excludedParams)) {
Please login to merge, or discard this patch.