Passed
Push — master ( 4a79ed...7ae6f1 )
by Sebastian
02:30
created
src/URLInfo/Parser.php 2 patches
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.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
         
60 60
         $this->parse();
61 61
         
62
-        if(!$this->detectType()) {
62
+        if (!$this->detectType()) {
63 63
             $this->validate();
64 64
         }
65 65
     }
@@ -93,11 +93,11 @@  discard block
 block discarded – undo
93 93
             'phoneLink'
94 94
         );
95 95
         
96
-        foreach($types as $type)
96
+        foreach ($types as $type)
97 97
         {
98 98
             $method = 'detectType_'.$type;
99 99
             
100
-            if($this->$method() === true) 
100
+            if ($this->$method() === true) 
101 101
             {
102 102
                 $this->isValid = true;
103 103
                 return true;
@@ -115,11 +115,11 @@  discard block
 block discarded – undo
115 115
             'hostIsPresent'
116 116
         );
117 117
         
118
-        foreach($validations as $validation) 
118
+        foreach ($validations as $validation) 
119 119
         {
120 120
             $method = 'validate_'.$validation;
121 121
             
122
-            if($this->$method() !== true) {
122
+            if ($this->$method() !== true) {
123 123
                 return;
124 124
             }
125 125
         }
@@ -132,13 +132,13 @@  discard block
 block discarded – undo
132 132
         // every link needs a host. This case can happen for ex, if
133 133
         // the link starts with a typo with only one slash, like:
134 134
         // "http:/hostname"
135
-        if(isset($this->info['host'])) {
135
+        if (isset($this->info['host'])) {
136 136
             return true;
137 137
         }
138 138
         
139 139
         $this->setError(
140 140
             URLInfo::ERROR_MISSING_HOST,
141
-            t('Cannot determine the link\'s host name.') . ' ' .
141
+            t('Cannot determine the link\'s host name.').' '.
142 142
             t('This usually happens when there\'s a typo somewhere.')
143 143
         );
144 144
 
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
     
148 148
     protected function validate_schemeIsSet() : bool
149 149
     {
150
-        if(isset($this->info['scheme'])) {
150
+        if (isset($this->info['scheme'])) {
151 151
             return true;
152 152
         }
153 153
         
@@ -164,13 +164,13 @@  discard block
 block discarded – undo
164 164
     
165 165
     protected function validate_schemeIsKnown() : bool
166 166
     {
167
-        if(in_array($this->info['scheme'], $this->knownSchemes)) {
167
+        if (in_array($this->info['scheme'], $this->knownSchemes)) {
168 168
             return true;
169 169
         }
170 170
         
171 171
         $this->setError(
172 172
             URLInfo::ERROR_INVALID_SCHEME,
173
-            t('The scheme %1$s is not supported for links.', $this->info['scheme']) . ' ' .
173
+            t('The scheme %1$s is not supported for links.', $this->info['scheme']).' '.
174 174
             t('Valid schemes are: %1$s.', implode(', ', $this->knownSchemes))
175 175
         );
176 176
 
@@ -184,9 +184,9 @@  discard block
 block discarded – undo
184 184
     */
185 185
     protected function filterParsed()
186 186
     {
187
-        foreach($this->info as $key => $val)
187
+        foreach ($this->info as $key => $val)
188 188
         {
189
-            if(is_string($val)) {
189
+            if (is_string($val)) {
190 190
                 $this->info[$key] = trim($val);
191 191
             }
192 192
         }
@@ -194,15 +194,15 @@  discard block
 block discarded – undo
194 194
         $this->info['params'] = array();
195 195
         $this->info['type'] = URLInfo::TYPE_URL;
196 196
         
197
-        if(isset($this->info['host'])) {
197
+        if (isset($this->info['host'])) {
198 198
             $this->info['host'] = str_replace(' ', '', $this->info['host']);
199 199
         }
200 200
         
201
-        if(isset($this->info['path'])) {
201
+        if (isset($this->info['path'])) {
202 202
             $this->info['path'] = str_replace(' ', '', $this->info['path']);
203 203
         }
204 204
         
205
-        if(isset($this->info['query']) && !empty($this->info['query']))
205
+        if (isset($this->info['query']) && !empty($this->info['query']))
206 206
         {
207 207
             $this->info['params'] = \AppUtils\ConvertHelper::parseQueryString($this->info['query']);
208 208
             ksort($this->info['params']);
@@ -211,12 +211,12 @@  discard block
 block discarded – undo
211 211
     
212 212
     protected function detectType_email() : bool
213 213
     {
214
-        if(isset($this->info['scheme']) && $this->info['scheme'] == 'mailto') {
214
+        if (isset($this->info['scheme']) && $this->info['scheme'] == 'mailto') {
215 215
             $this->info['type'] = URLInfo::TYPE_EMAIL;
216 216
             return true;
217 217
         }
218 218
         
219
-        if(isset($this->info['path']) && preg_match(\AppUtils\RegexHelper::REGEX_EMAIL, $this->info['path']))
219
+        if (isset($this->info['path']) && preg_match(\AppUtils\RegexHelper::REGEX_EMAIL, $this->info['path']))
220 220
         {
221 221
             $this->info['scheme'] = 'mailto';
222 222
             $this->info['type'] = URLInfo::TYPE_EMAIL;
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
     
229 229
     protected function detectType_fragmentLink() : bool
230 230
     {
231
-        if(isset($this->info['fragment']) && !isset($this->info['scheme'])) {
231
+        if (isset($this->info['fragment']) && !isset($this->info['scheme'])) {
232 232
             $this->info['type'] = URLInfo::TYPE_FRAGMENT;
233 233
             return true;
234 234
         }
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
     
239 239
     protected function detectType_phoneLink() : bool
240 240
     {
241
-        if(isset($this->info['scheme']) && $this->info['scheme'] == 'tel') {
241
+        if (isset($this->info['scheme']) && $this->info['scheme'] == 'tel') {
242 242
             $this->info['type'] = URLInfo::TYPE_PHONE;
243 243
             return true;
244 244
         }
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
 
264 264
     public function getErrorMessage() : string
265 265
     {
266
-        if(isset($this->error)) {
266
+        if (isset($this->error)) {
267 267
             return $this->error['message'];
268 268
         }
269 269
         
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
     
273 273
     public function getErrorCode() : int
274 274
     {
275
-        if(isset($this->error)) {
275
+        if (isset($this->error)) {
276 276
             return $this->error['code'];
277 277
         }
278 278
         
Please login to merge, or discard this patch.
src/URLInfo/Highlighter.php 3 patches
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.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
             'fragment'
78 78
         );
79 79
         
80
-        foreach($parts as $part) 
80
+        foreach ($parts as $part) 
81 81
         {
82 82
             $method = 'render_'.$part;
83 83
             $result[] = (string)$this->$method();
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
     
89 89
     protected function render_scheme() : string
90 90
     {
91
-        if(!$this->info->hasScheme()) {
91
+        if (!$this->info->hasScheme()) {
92 92
             return '';
93 93
         }
94 94
         
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
     
104 104
     protected function render_username() : string
105 105
     {
106
-        if(!$this->info->hasUsername()) {
106
+        if (!$this->info->hasUsername()) {
107 107
             return '';
108 108
         }
109 109
         
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
     
120 120
     protected function render_host() : string
121 121
     {
122
-        if(!$this->info->hasHost()) {
122
+        if (!$this->info->hasHost()) {
123 123
             return '';
124 124
         }
125 125
         
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
     
132 132
     protected function render_port() : string
133 133
     {
134
-        if(!$this->info->hasPort()) {
134
+        if (!$this->info->hasPort()) {
135 135
             return '';
136 136
         }
137 137
         
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
        
145 145
     protected function render_path() : string
146 146
     {
147
-        if(!$this->info->hasPath()) {
147
+        if (!$this->info->hasPath()) {
148 148
             return '';
149 149
         }
150 150
         
@@ -162,19 +162,19 @@  discard block
 block discarded – undo
162 162
     {
163 163
         $params = $this->info->getParams();
164 164
         
165
-        if(empty($params)) {
165
+        if (empty($params)) {
166 166
             return '';
167 167
         }
168 168
         
169 169
         $tokens = array();
170 170
         $excluded = array();
171 171
         
172
-        if($this->info->isParamExclusionEnabled())
172
+        if ($this->info->isParamExclusionEnabled())
173 173
         {
174 174
             $excluded = $this->info->getExcludedParams();
175 175
         }
176 176
         
177
-        foreach($params as $param => $value)
177
+        foreach ($params as $param => $value)
178 178
         {
179 179
             $parts = sprintf(
180 180
                 '<span class="link-param-name">%s</span>'.
@@ -192,10 +192,10 @@  discard block
 block discarded – undo
192 192
             $tag = '';
193 193
             
194 194
             // is parameter exclusion enabled, and is this an excluded parameter?
195
-            if(isset($excluded[$param]))            
195
+            if (isset($excluded[$param]))            
196 196
             {
197 197
                 // display the excluded parameter, but highlight it
198
-                if($this->info->isHighlightExcludeEnabled())
198
+                if ($this->info->isHighlightExcludeEnabled())
199 199
                 {
200 200
                     $tooltip = $excluded[$param];
201 201
                     
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
      
229 229
     protected function render_fragment() : string
230 230
     {
231
-        if(!$this->info->hasFragment()) {
231
+        if (!$this->info->hasFragment()) {
232 232
             return '';
233 233
         }
234 234
         
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -204,13 +204,11 @@
 block discarded – undo
204 204
                         $tooltip,
205 205
                         $parts
206 206
                     );
207
-                }
208
-                else
207
+                } else
209 208
                 {
210 209
                     continue;
211 210
                 }
212
-            }
213
-            else
211
+            } else
214 212
             {
215 213
                 $tag = sprintf(
216 214
                     '<span class="link-param">%s</span>',
Please login to merge, or discard this patch.
src/URLInfo.php 3 patches
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.
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
      */
122 122
     public function isSecure() : bool
123 123
     {
124
-        if(isset($this->info['scheme']) && $this->info['scheme'] === 'https') {
124
+        if (isset($this->info['scheme']) && $this->info['scheme'] === 'https') {
125 125
             return true;
126 126
         }
127 127
         
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
     public function getPort() : int
197 197
     {
198 198
         $port = $this->getInfoKey('port');
199
-        if(!empty($port)) {
199
+        if (!empty($port)) {
200 200
             return (int)$port;
201 201
         }
202 202
         
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
     
277 277
     protected function getInfoKey(string $name) : string
278 278
     {
279
-        if(isset($this->info[$name])) {
279
+        if (isset($this->info[$name])) {
280 280
             return (string)$this->info[$name];
281 281
         }
282 282
         
@@ -285,34 +285,34 @@  discard block
 block discarded – undo
285 285
     
286 286
     public function getNormalized() : string
287 287
     {
288
-        if(!$this->isValid()) {
288
+        if (!$this->isValid()) {
289 289
             return '';
290 290
         }
291 291
         
292
-        if($this->isAnchor())
292
+        if ($this->isAnchor())
293 293
         {
294 294
             return '#'.$this->getFragment();
295 295
         }
296
-        else if($this->isPhoneNumber())
296
+        else if ($this->isPhoneNumber())
297 297
         {
298 298
             return 'tel://'.$this->getHost();
299 299
         }
300
-        else if($this->isEmail())
300
+        else if ($this->isEmail())
301 301
         {
302 302
             return 'mailto:'.$this->getPath();
303 303
         }
304 304
         
305 305
         $normalized = $this->info['scheme'].'://'.$this->info['host'];
306
-        if(isset($this->info['path'])) {
306
+        if (isset($this->info['path'])) {
307 307
             $normalized .= $this->info['path'];
308 308
         }
309 309
         
310 310
         $params = $this->getParams();
311
-        if(!empty($params)) {
311
+        if (!empty($params)) {
312 312
             $normalized .= '?'.http_build_query($params);
313 313
         }
314 314
         
315
-        if(isset($this->info['fragment'])) {
315
+        if (isset($this->info['fragment'])) {
316 316
             $normalized .= '#'.$this->info['fragment'];
317 317
         }
318 318
         
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
     */
341 341
     public function getHighlighted() : string
342 342
     {
343
-        if(!$this->isValid()) {
343
+        if (!$this->isValid()) {
344 344
             return '';
345 345
         }
346 346
         
@@ -382,13 +382,13 @@  discard block
 block discarded – undo
382 382
     */
383 383
     public function getParams() : array
384 384
     {
385
-        if(!$this->paramExclusion || empty($this->excludedParams)) {
385
+        if (!$this->paramExclusion || empty($this->excludedParams)) {
386 386
             return $this->info['params'];
387 387
         }
388 388
         
389 389
         $keep = array();
390
-        foreach($this->info['params'] as $name => $value) {
391
-            if(!isset($this->excludedParams[$name])) {
390
+        foreach ($this->info['params'] as $name => $value) {
391
+            if (!isset($this->excludedParams[$name])) {
392 392
                 $keep[$name] = $value;
393 393
             }
394 394
         }
@@ -414,7 +414,7 @@  discard block
 block discarded – undo
414 414
     */
415 415
     public function getParam(string $name) : string
416 416
     {
417
-        if(isset($this->info['params'][$name])) {
417
+        if (isset($this->info['params'][$name])) {
418 418
             return $this->info['params'][$name];
419 419
         }
420 420
         
@@ -433,7 +433,7 @@  discard block
 block discarded – undo
433 433
     */
434 434
     public function excludeParam(string $name, string $reason) : URLInfo
435 435
     {
436
-        if(!isset($this->excludedParams[$name]))
436
+        if (!isset($this->excludedParams[$name]))
437 437
         {
438 438
             $this->excludedParams[$name] = $reason;
439 439
             $this->setParamExclusion();
@@ -459,7 +459,7 @@  discard block
 block discarded – undo
459 459
     
460 460
     public function getTypeLabel() : string
461 461
     {
462
-        if(!isset(self::$typeLabels))
462
+        if (!isset(self::$typeLabels))
463 463
         {
464 464
             self::$typeLabels = array(
465 465
                 self::TYPE_EMAIL => t('Email'),
@@ -471,7 +471,7 @@  discard block
 block discarded – undo
471 471
         
472 472
         $type = $this->getType();
473 473
         
474
-        if(!isset(self::$typeLabels[$type]))
474
+        if (!isset(self::$typeLabels[$type]))
475 475
         {
476 476
             throw new BaseException(
477 477
                 sprintf('Unknown URL type label for type [%s].', $type),
@@ -491,7 +491,7 @@  discard block
 block discarded – undo
491 491
     * @param bool $highlight
492 492
     * @return URLInfo
493 493
     */
494
-    public function setHighlightExcluded(bool $highlight=true) : URLInfo
494
+    public function setHighlightExcluded(bool $highlight = true) : URLInfo
495 495
     {
496 496
         $this->highlightExcluded = $highlight;
497 497
         return $this;
@@ -539,7 +539,7 @@  discard block
 block discarded – undo
539 539
      * @see URLInfo::isParamExclusionEnabled()
540 540
      * @see URLInfo::setHighlightExcluded()
541 541
      */
542
-    public function setParamExclusion(bool $enabled=true) : URLInfo
542
+    public function setParamExclusion(bool $enabled = true) : URLInfo
543 543
     {
544 544
         $this->paramExclusion = $enabled;
545 545
         return $this;
@@ -565,13 +565,13 @@  discard block
 block discarded – undo
565 565
     */
566 566
     public function containsExcludedParams() : bool
567 567
     {
568
-        if(empty($this->excludedParams)) {
568
+        if (empty($this->excludedParams)) {
569 569
             return false;
570 570
         }
571 571
         
572 572
         $names = array_keys($this->info['params']);
573
-        foreach($names as $name) {
574
-            if(isset($this->excludedParams[$name])) {
573
+        foreach ($names as $name) {
574
+            if (isset($this->excludedParams[$name])) {
575 575
                 return true;
576 576
             }
577 577
         }
@@ -587,7 +587,7 @@  discard block
 block discarded – undo
587 587
 
588 588
     public function offsetSet($offset, $value) 
589 589
     {
590
-        if(in_array($offset, $this->infoKeys)) {
590
+        if (in_array($offset, $this->infoKeys)) {
591 591
             $this->info[$offset] = $value;
592 592
         }
593 593
     }
@@ -604,11 +604,11 @@  discard block
 block discarded – undo
604 604
     
605 605
     public function offsetGet($offset) 
606 606
     {
607
-        if($offset === 'port') {
607
+        if ($offset === 'port') {
608 608
             return $this->getPort();
609 609
         }
610 610
         
611
-        if(in_array($offset, $this->infoKeys)) {
611
+        if (in_array($offset, $this->infoKeys)) {
612 612
             return $this->getInfoKey($offset);
613 613
         }
614 614
         
@@ -619,7 +619,7 @@  discard block
 block discarded – undo
619 619
     {
620 620
         $cssFolder = realpath(__DIR__.'/../css');
621 621
         
622
-        if($cssFolder === false) {
622
+        if ($cssFolder === false) {
623 623
             throw new BaseException(
624 624
                 'Cannot find package CSS folder.',
625 625
                 null,
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -292,12 +292,10 @@
 block discarded – undo
292 292
         if($this->isAnchor())
293 293
         {
294 294
             return '#'.$this->getFragment();
295
-        }
296
-        else if($this->isPhoneNumber())
295
+        } else if($this->isPhoneNumber())
297 296
         {
298 297
             return 'tel://'.$this->getHost();
299
-        }
300
-        else if($this->isEmail())
298
+        } else if($this->isEmail())
301 299
         {
302 300
             return 'mailto:'.$this->getPath();
303 301
         }
Please login to merge, or discard this patch.