Passed
Push — master ( 4a79ed...7ae6f1 )
by Sebastian
02:30
created
src/URLInfo/Parser.php 1 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 1 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.
src/URLInfo.php 1 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.