Passed
Push — master ( b083ab...a3db06 )
by Sebastian
03:30
created
src/URLInfo/URIHighlighter.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
             'fragment'
75 75
         );
76 76
         
77
-        foreach($parts as $part) 
77
+        foreach ($parts as $part) 
78 78
         {
79 79
             $method = 'render_'.$part;
80 80
             $result[] = (string)$this->$method();
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
     
86 86
     protected function render_scheme() : string
87 87
     {
88
-        if(!$this->info->hasScheme()) {
88
+        if (!$this->info->hasScheme()) {
89 89
             return '';
90 90
         }
91 91
         
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
     
101 101
     protected function render_username() : string
102 102
     {
103
-        if(!$this->info->hasUsername()) {
103
+        if (!$this->info->hasUsername()) {
104 104
             return '';
105 105
         }
106 106
         
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
     
117 117
     protected function render_host() : string
118 118
     {
119
-        if(!$this->info->hasHost()) {
119
+        if (!$this->info->hasHost()) {
120 120
             return '';
121 121
         }
122 122
         
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
     
129 129
     protected function render_port() : string
130 130
     {
131
-        if(!$this->info->hasPort()) {
131
+        if (!$this->info->hasPort()) {
132 132
             return '';
133 133
         }
134 134
         
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
        
142 142
     protected function render_path() : string
143 143
     {
144
-        if(!$this->info->hasPath()) {
144
+        if (!$this->info->hasPath()) {
145 145
             return '';
146 146
         }
147 147
         
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
     {
167 167
         $previous = $this->info->isParamExclusionEnabled();
168 168
         
169
-        if($previous)
169
+        if ($previous)
170 170
         {
171 171
             $this->info->setParamExclusion(false);
172 172
         }
@@ -182,19 +182,19 @@  discard block
 block discarded – undo
182 182
     {
183 183
         $params = $this->resolveParams();
184 184
         
185
-        if(empty($params)) {
185
+        if (empty($params)) {
186 186
             return '';
187 187
         }
188 188
         
189 189
         $tokens = array();
190 190
         $excluded = array();
191 191
         
192
-        if($this->info->isParamExclusionEnabled())
192
+        if ($this->info->isParamExclusionEnabled())
193 193
         {
194 194
             $excluded = $this->info->getExcludedParams();
195 195
         }
196 196
         
197
-        foreach($params as $param => $value)
197
+        foreach ($params as $param => $value)
198 198
         {
199 199
             // If the parameter is numeric, it will automatically
200 200
             // be an integer, so we need the conversion here.
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
             
216 216
             $tag = $this->resolveTag($excluded, $param);
217 217
             
218
-            if(!empty($tag))
218
+            if (!empty($tag))
219 219
             {
220 220
                 $tokens[] = sprintf($tag, $parts);
221 221
             }
@@ -234,13 +234,13 @@  discard block
 block discarded – undo
234 234
     protected function resolveTag(array $excluded, string $paramName) : string
235 235
     {
236 236
         // regular, non-excluded parameter
237
-        if(!isset($excluded[$paramName]))
237
+        if (!isset($excluded[$paramName]))
238 238
         {
239 239
             return '<span class="link-param">%s</span>';
240 240
         }
241 241
 
242 242
         // highlight excluded parameters is disabled, ignore this parameter
243
-        if(!$this->info->isHighlightExcludeEnabled())
243
+        if (!$this->info->isHighlightExcludeEnabled())
244 244
         {
245 245
             return '';
246 246
         }
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
      
257 257
     protected function render_fragment() : string
258 258
     {
259
-        if(!$this->info->hasFragment()) {
259
+        if (!$this->info->hasFragment()) {
260 260
             return '';
261 261
         }
262 262
         
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
     {
272 272
         $cssFolder = realpath(__DIR__.'/../../css');
273 273
         
274
-        if($cssFolder === false) {
274
+        if ($cssFolder === false) {
275 275
             throw new URLException(
276 276
                 'Cannot find package CSS folder.',
277 277
                 null,
Please login to merge, or discard this patch.
src/URLInfo.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
     * @var array<string,string>|NULL
71 71
     * @see URLInfo::getTypeLabel()
72 72
     */
73
-    protected static ?array $typeLabels = null;
73
+    protected static ? array $typeLabels = null;
74 74
     
75 75
    /**
76 76
     * @var bool
@@ -133,9 +133,9 @@  discard block
 block discarded – undo
133 133
     * @param bool $enabled
134 134
     * @return URLInfo
135 135
     */
136
-    public function setUTFEncoding(bool $enabled=true) : URLInfo
136
+    public function setUTFEncoding(bool $enabled = true) : URLInfo
137 137
     {
138
-        if($this->encodeUTFChars !== $enabled)
138
+        if ($this->encodeUTFChars !== $enabled)
139 139
         {
140 140
             $this->encodeUTFChars = $enabled;
141 141
             $this->parse(); // reparse the URL to apply the changes
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
     {
240 240
         $port = $this->getInfoKey('port');
241 241
         
242
-        if(!empty($port)) {
242
+        if (!empty($port)) {
243 243
             return (int)$port;
244 244
         }
245 245
         
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
     
320 320
     protected function getInfoKey(string $name) : string
321 321
     {
322
-        if(isset($this->info[$name])) {
322
+        if (isset($this->info[$name])) {
323 323
             return (string)$this->info[$name];
324 324
         }
325 325
         
@@ -348,13 +348,13 @@  discard block
 block discarded – undo
348 348
         return $this->normalize(false);
349 349
     }
350 350
     
351
-    protected function normalize(bool $auth=true) : string
351
+    protected function normalize(bool $auth = true) : string
352 352
     {
353
-        if(!$this->isValid()) {
353
+        if (!$this->isValid()) {
354 354
             return '';
355 355
         }
356 356
         
357
-        if(!isset($this->normalizer)) {
357
+        if (!isset($this->normalizer)) {
358 358
             $this->normalizer = new URINormalizer($this);
359 359
         }
360 360
         
@@ -384,7 +384,7 @@  discard block
 block discarded – undo
384 384
     */
385 385
     public function getHighlighted() : string
386 386
     {
387
-        if(!$this->isValid()) {
387
+        if (!$this->isValid()) {
388 388
             return '';
389 389
         }
390 390
         
@@ -424,14 +424,14 @@  discard block
 block discarded – undo
424 424
     */
425 425
     public function getParams() : array
426 426
     {
427
-        if(!$this->paramExclusion || empty($this->excludedParams)) {
427
+        if (!$this->paramExclusion || empty($this->excludedParams)) {
428 428
             return $this->info['params'];
429 429
         }
430 430
         
431 431
         $keep = array();
432
-        foreach($this->info['params'] as $name => $value) 
432
+        foreach ($this->info['params'] as $name => $value) 
433 433
         {
434
-            if(!isset($this->excludedParams[$name])) {
434
+            if (!isset($this->excludedParams[$name])) {
435 435
                 $keep[$name] = $value;
436 436
             }
437 437
         }
@@ -470,9 +470,9 @@  discard block
 block discarded – undo
470 470
     * @param string $reason A human-readable explanation why this is excluded - used when highlighting links.
471 471
     * @return URLInfo
472 472
     */
473
-    public function excludeParam(string $name, string $reason='') : URLInfo
473
+    public function excludeParam(string $name, string $reason = '') : URLInfo
474 474
     {
475
-        if(!isset($this->excludedParams[$name]))
475
+        if (!isset($this->excludedParams[$name]))
476 476
         {
477 477
             $this->excludedParams[$name] = $reason;
478 478
             $this->setParamExclusion();
@@ -498,7 +498,7 @@  discard block
 block discarded – undo
498 498
     
499 499
     public function getTypeLabel() : string
500 500
     {
501
-        if(!isset(self::$typeLabels))
501
+        if (!isset(self::$typeLabels))
502 502
         {
503 503
             self::$typeLabels = array(
504 504
                 self::TYPE_EMAIL => t('Email'),
@@ -510,7 +510,7 @@  discard block
 block discarded – undo
510 510
         
511 511
         $type = $this->getType();
512 512
         
513
-        if(!isset(self::$typeLabels[$type]))
513
+        if (!isset(self::$typeLabels[$type]))
514 514
         {
515 515
             throw new URLException(
516 516
                 sprintf('Unknown URL type label for type [%s].', $type),
@@ -530,7 +530,7 @@  discard block
 block discarded – undo
530 530
     * @param bool $highlight
531 531
     * @return URLInfo
532 532
     */
533
-    public function setHighlightExcluded(bool $highlight=true) : URLInfo
533
+    public function setHighlightExcluded(bool $highlight = true) : URLInfo
534 534
     {
535 535
         $this->highlightExcluded = $highlight;
536 536
         return $this;
@@ -579,7 +579,7 @@  discard block
 block discarded – undo
579 579
      * @see URLInfo::isParamExclusionEnabled()
580 580
      * @see URLInfo::setHighlightExcluded()
581 581
      */
582
-    public function setParamExclusion(bool $enabled=true) : URLInfo
582
+    public function setParamExclusion(bool $enabled = true) : URLInfo
583 583
     {
584 584
         $this->paramExclusion = $enabled;
585 585
         return $this;
@@ -605,13 +605,13 @@  discard block
 block discarded – undo
605 605
     */
606 606
     public function containsExcludedParams() : bool
607 607
     {
608
-        if(empty($this->excludedParams)) {
608
+        if (empty($this->excludedParams)) {
609 609
             return false;
610 610
         }
611 611
         
612 612
         $names = array_keys($this->info['params']);
613
-        foreach($names as $name) {
614
-            if(isset($this->excludedParams[$name])) {
613
+        foreach ($names as $name) {
614
+            if (isset($this->excludedParams[$name])) {
615 615
                 return true;
616 616
             }
617 617
         }
@@ -627,7 +627,7 @@  discard block
 block discarded – undo
627 627
 
628 628
     public function offsetSet($offset, $value)  : void
629 629
     {
630
-        if(in_array($offset, $this->infoKeys, true)) {
630
+        if (in_array($offset, $this->infoKeys, true)) {
631 631
             $this->info[$offset] = $value;
632 632
         }
633 633
     }
@@ -644,11 +644,11 @@  discard block
 block discarded – undo
644 644
     
645 645
     public function offsetGet($offset)
646 646
     {
647
-        if($offset === 'port') {
647
+        if ($offset === 'port') {
648 648
             return $this->getPort();
649 649
         }
650 650
         
651
-        if(in_array($offset, $this->infoKeys, true)) {
651
+        if (in_array($offset, $this->infoKeys, true)) {
652 652
             return $this->getInfoKey($offset);
653 653
         }
654 654
         
@@ -683,7 +683,7 @@  discard block
 block discarded – undo
683 683
      * @param bool $verifySSL
684 684
      * @return bool
685 685
      */
686
-    public function tryConnect(bool $verifySSL=true) : bool
686
+    public function tryConnect(bool $verifySSL = true) : bool
687 687
     {
688 688
         return $this->createConnectionTester()
689 689
             ->setVerifySSL($verifySSL)
@@ -726,7 +726,7 @@  discard block
 block discarded – undo
726 726
     */
727 727
     public function removeParam(string $param) : URLInfo
728 728
     {
729
-        if(isset($this->info['params'][$param]))
729
+        if (isset($this->info['params'][$param]))
730 730
         {
731 731
             unset($this->info['params'][$param]);
732 732
         }
Please login to merge, or discard this patch.