Passed
Push — master ( 606be1...b28623 )
by Sebastian
02:43
created
src/URLInfo.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -128,9 +128,9 @@  discard block
 block discarded – undo
128 128
     * @param bool $enabled
129 129
     * @return URLInfo
130 130
     */
131
-    public function setUTFEncoding(bool $enabled=true) : URLInfo
131
+    public function setUTFEncoding(bool $enabled = true) : URLInfo
132 132
     {
133
-        if($this->encodeUTFChars !== $enabled)
133
+        if ($this->encodeUTFChars !== $enabled)
134 134
         {
135 135
             $this->encodeUTFChars = $enabled;
136 136
             $this->parse(); // re-parse the URL to apply the changes
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
     {
235 235
         $port = $this->getInfoKey('port');
236 236
         
237
-        if(!empty($port)) {
237
+        if (!empty($port)) {
238 238
             return (int)$port;
239 239
         }
240 240
         
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
     
315 315
     protected function getInfoKey(string $name) : string
316 316
     {
317
-        if(isset($this->info[$name])) {
317
+        if (isset($this->info[$name])) {
318 318
             return (string)$this->info[$name];
319 319
         }
320 320
         
@@ -343,13 +343,13 @@  discard block
 block discarded – undo
343 343
         return $this->normalize(false);
344 344
     }
345 345
     
346
-    protected function normalize(bool $auth=true) : string
346
+    protected function normalize(bool $auth = true) : string
347 347
     {
348
-        if(!$this->isValid()) {
348
+        if (!$this->isValid()) {
349 349
             return '';
350 350
         }
351 351
         
352
-        if(!isset($this->normalizer)) {
352
+        if (!isset($this->normalizer)) {
353 353
             $this->normalizer = new URLInfo_Normalizer($this);
354 354
         }
355 355
         
@@ -379,7 +379,7 @@  discard block
 block discarded – undo
379 379
     */
380 380
     public function getHighlighted() : string
381 381
     {
382
-        if(!$this->isValid()) {
382
+        if (!$this->isValid()) {
383 383
             return '';
384 384
         }
385 385
         
@@ -421,14 +421,14 @@  discard block
 block discarded – undo
421 421
     */
422 422
     public function getParams() : array
423 423
     {
424
-        if(!$this->paramExclusion || empty($this->excludedParams)) {
424
+        if (!$this->paramExclusion || empty($this->excludedParams)) {
425 425
             return $this->info['params'];
426 426
         }
427 427
         
428 428
         $keep = array();
429
-        foreach($this->info['params'] as $name => $value) 
429
+        foreach ($this->info['params'] as $name => $value) 
430 430
         {
431
-            if(!isset($this->excludedParams[$name])) {
431
+            if (!isset($this->excludedParams[$name])) {
432 432
                 $keep[$name] = $value;
433 433
             }
434 434
         }
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
     */
455 455
     public function getParam(string $name) : string
456 456
     {
457
-        if(isset($this->info['params'][$name])) {
457
+        if (isset($this->info['params'][$name])) {
458 458
             return $this->info['params'][$name];
459 459
         }
460 460
         
@@ -473,7 +473,7 @@  discard block
 block discarded – undo
473 473
     */
474 474
     public function excludeParam(string $name, string $reason) : URLInfo
475 475
     {
476
-        if(!isset($this->excludedParams[$name]))
476
+        if (!isset($this->excludedParams[$name]))
477 477
         {
478 478
             $this->excludedParams[$name] = $reason;
479 479
             $this->setParamExclusion();
@@ -499,7 +499,7 @@  discard block
 block discarded – undo
499 499
     
500 500
     public function getTypeLabel() : string
501 501
     {
502
-        if(!isset(self::$typeLabels))
502
+        if (!isset(self::$typeLabels))
503 503
         {
504 504
             self::$typeLabels = array(
505 505
                 self::TYPE_EMAIL => t('Email'),
@@ -511,7 +511,7 @@  discard block
 block discarded – undo
511 511
         
512 512
         $type = $this->getType();
513 513
         
514
-        if(!isset(self::$typeLabels[$type]))
514
+        if (!isset(self::$typeLabels[$type]))
515 515
         {
516 516
             throw new BaseException(
517 517
                 sprintf('Unknown URL type label for type [%s].', $type),
@@ -531,7 +531,7 @@  discard block
 block discarded – undo
531 531
     * @param bool $highlight
532 532
     * @return URLInfo
533 533
     */
534
-    public function setHighlightExcluded(bool $highlight=true) : URLInfo
534
+    public function setHighlightExcluded(bool $highlight = true) : URLInfo
535 535
     {
536 536
         $this->highlightExcluded = $highlight;
537 537
         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) 
629 629
     {
630
-        if(in_array($offset, $this->infoKeys)) {
630
+        if (in_array($offset, $this->infoKeys)) {
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)) {
651
+        if (in_array($offset, $this->infoKeys)) {
652 652
             return $this->getInfoKey($offset);
653 653
         }
654 654
         
@@ -680,12 +680,12 @@  discard block
 block discarded – undo
680 680
     * @return bool
681 681
     * @throws BaseException
682 682
     */
683
-    public function tryConnect(bool $verifySSL=true) : bool
683
+    public function tryConnect(bool $verifySSL = true) : bool
684 684
     {
685 685
         requireCURL();
686 686
         
687 687
         $ch = curl_init();
688
-        if(!is_resource($ch))
688
+        if (!is_resource($ch))
689 689
         {
690 690
             throw new BaseException(
691 691
                 'Could not initialize a new cURL instance.',
@@ -701,13 +701,13 @@  discard block
 block discarded – undo
701 701
         curl_setopt($ch, CURLOPT_TIMEOUT, 10);
702 702
         curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
703 703
         
704
-        if(!$verifySSL) 
704
+        if (!$verifySSL) 
705 705
         {
706 706
             curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
707 707
             curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
708 708
         }
709 709
         
710
-        if($this->hasUsername()) 
710
+        if ($this->hasUsername()) 
711 711
         {
712 712
             curl_setopt($ch, CURLOPT_USERNAME, $this->getUsername());
713 713
             curl_setopt($ch, CURLOPT_PASSWORD, $this->getPassword());
Please login to merge, or discard this patch.
src/URLInfo/Parser.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
         
83 83
         $this->parse();
84 84
         
85
-        if(!$this->detectType()) {
85
+        if (!$this->detectType()) {
86 86
             $this->validate();
87 87
         }
88 88
     }
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
         
109 109
         // if the URL contains any URL characters, and we
110 110
         // do not want them URL encoded, restore them.
111
-        if(!$this->encodeUTF && !empty($this->unicodeChars))
111
+        if (!$this->encodeUTF && !empty($this->unicodeChars))
112 112
         {
113 113
             $this->info = $this->restoreUnicodeChars($this->info);
114 114
         }
@@ -125,13 +125,13 @@  discard block
 block discarded – undo
125 125
         
126 126
         $keep = array();
127 127
         
128
-        foreach($chars as $char)
128
+        foreach ($chars as $char)
129 129
         {
130
-            if(preg_match('/\p{L}/usix', $char))
130
+            if (preg_match('/\p{L}/usix', $char))
131 131
             {
132 132
                 $encoded = rawurlencode($char);
133 133
                 
134
-                if($encoded != $char)
134
+                if ($encoded != $char)
135 135
                 {
136 136
                     $this->unicodeChars[$encoded] = $char;
137 137
                     $char = $encoded;
@@ -152,11 +152,11 @@  discard block
 block discarded – undo
152 152
             'phoneLink'
153 153
         );
154 154
         
155
-        foreach($types as $type)
155
+        foreach ($types as $type)
156 156
         {
157 157
             $method = 'detectType_'.$type;
158 158
             
159
-            if($this->$method() === true) 
159
+            if ($this->$method() === true) 
160 160
             {
161 161
                 $this->isValid = true;
162 162
                 return true;
@@ -174,11 +174,11 @@  discard block
 block discarded – undo
174 174
             'hostIsPresent'
175 175
         );
176 176
         
177
-        foreach($validations as $validation) 
177
+        foreach ($validations as $validation) 
178 178
         {
179 179
             $method = 'validate_'.$validation;
180 180
             
181
-            if($this->$method() !== true) {
181
+            if ($this->$method() !== true) {
182 182
                 return;
183 183
             }
184 184
         }
@@ -191,13 +191,13 @@  discard block
 block discarded – undo
191 191
         // every link needs a host. This case can happen for ex, if
192 192
         // the link starts with a typo with only one slash, like:
193 193
         // "http:/hostname"
194
-        if(isset($this->info['host'])) {
194
+        if (isset($this->info['host'])) {
195 195
             return true;
196 196
         }
197 197
         
198 198
         $this->setError(
199 199
             URLInfo::ERROR_MISSING_HOST,
200
-            t('Cannot determine the link\'s host name.') . ' ' .
200
+            t('Cannot determine the link\'s host name.').' '.
201 201
             t('This usually happens when there\'s a typo somewhere.')
202 202
         );
203 203
 
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
     
207 207
     protected function validate_schemeIsSet() : bool
208 208
     {
209
-        if(isset($this->info['scheme'])) {
209
+        if (isset($this->info['scheme'])) {
210 210
             return true;
211 211
         }
212 212
         
@@ -223,13 +223,13 @@  discard block
 block discarded – undo
223 223
     
224 224
     protected function validate_schemeIsKnown() : bool
225 225
     {
226
-        if(in_array($this->info['scheme'], $this->knownSchemes)) {
226
+        if (in_array($this->info['scheme'], $this->knownSchemes)) {
227 227
             return true;
228 228
         }
229 229
         
230 230
         $this->setError(
231 231
             URLInfo::ERROR_INVALID_SCHEME,
232
-            t('The scheme %1$s is not supported for links.', $this->info['scheme']) . ' ' .
232
+            t('The scheme %1$s is not supported for links.', $this->info['scheme']).' '.
233 233
             t('Valid schemes are: %1$s.', implode(', ', $this->knownSchemes))
234 234
         );
235 235
 
@@ -246,23 +246,23 @@  discard block
 block discarded – undo
246 246
         $this->info['params'] = array();
247 247
         $this->info['type'] = URLInfo::TYPE_URL;
248 248
         
249
-        if(isset($this->info['user'])) {
249
+        if (isset($this->info['user'])) {
250 250
             $this->info['user'] = urldecode($this->info['user']);
251 251
         }
252 252
 
253
-        if(isset($this->info['pass'])) {
253
+        if (isset($this->info['pass'])) {
254 254
             $this->info['pass'] = urldecode($this->info['pass']);
255 255
         }
256 256
         
257
-        if(isset($this->info['host'])) {
257
+        if (isset($this->info['host'])) {
258 258
             $this->info['host'] = str_replace(' ', '', $this->info['host']);
259 259
         }
260 260
         
261
-        if(isset($this->info['path'])) {
261
+        if (isset($this->info['path'])) {
262 262
             $this->info['path'] = str_replace(' ', '', $this->info['path']);
263 263
         }
264 264
         
265
-        if(isset($this->info['query']) && !empty($this->info['query']))
265
+        if (isset($this->info['query']) && !empty($this->info['query']))
266 266
         {
267 267
             $this->info['params'] = \AppUtils\ConvertHelper::parseQueryString($this->info['query']);
268 268
             ksort($this->info['params']);
@@ -280,9 +280,9 @@  discard block
 block discarded – undo
280 280
     {
281 281
         $result = array();
282 282
         
283
-        foreach($subject as $key => $val)
283
+        foreach ($subject as $key => $val)
284 284
         {
285
-            if(is_array($val))
285
+            if (is_array($val))
286 286
             {
287 287
                 $val = $this->restoreUnicodeChars($val);
288 288
             }
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
     */
309 309
     protected function restoreUnicodeChar(string $string) : string
310 310
     {
311
-        if(strstr($string, '%'))
311
+        if (strstr($string, '%'))
312 312
         {
313 313
             return str_replace(array_keys($this->unicodeChars), array_values($this->unicodeChars), $string);
314 314
         }
@@ -318,12 +318,12 @@  discard block
 block discarded – undo
318 318
     
319 319
     protected function detectType_email() : bool
320 320
     {
321
-        if(isset($this->info['scheme']) && $this->info['scheme'] == 'mailto') {
321
+        if (isset($this->info['scheme']) && $this->info['scheme'] == 'mailto') {
322 322
             $this->info['type'] = URLInfo::TYPE_EMAIL;
323 323
             return true;
324 324
         }
325 325
         
326
-        if(isset($this->info['path']) && preg_match(\AppUtils\RegexHelper::REGEX_EMAIL, $this->info['path']))
326
+        if (isset($this->info['path']) && preg_match(\AppUtils\RegexHelper::REGEX_EMAIL, $this->info['path']))
327 327
         {
328 328
             $this->info['scheme'] = 'mailto';
329 329
             $this->info['type'] = URLInfo::TYPE_EMAIL;
@@ -335,7 +335,7 @@  discard block
 block discarded – undo
335 335
     
336 336
     protected function detectType_fragmentLink() : bool
337 337
     {
338
-        if(isset($this->info['fragment']) && !isset($this->info['scheme'])) {
338
+        if (isset($this->info['fragment']) && !isset($this->info['scheme'])) {
339 339
             $this->info['type'] = URLInfo::TYPE_FRAGMENT;
340 340
             return true;
341 341
         }
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
     
346 346
     protected function detectType_phoneLink() : bool
347 347
     {
348
-        if(isset($this->info['scheme']) && $this->info['scheme'] == 'tel') {
348
+        if (isset($this->info['scheme']) && $this->info['scheme'] == 'tel') {
349 349
             $this->info['type'] = URLInfo::TYPE_PHONE;
350 350
             return true;
351 351
         }
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
     */
381 381
     public function getErrorMessage() : string
382 382
     {
383
-        if(isset($this->error)) {
383
+        if (isset($this->error)) {
384 384
             return $this->error['message'];
385 385
         }
386 386
         
@@ -395,7 +395,7 @@  discard block
 block discarded – undo
395 395
     */
396 396
     public function getErrorCode() : int
397 397
     {
398
-        if(isset($this->error)) {
398
+        if (isset($this->error)) {
399 399
             return $this->error['code'];
400 400
         }
401 401
         
Please login to merge, or discard this patch.
src/ConvertHelper/ControlCharacters.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
    /**
26 26
     * @var string[]
27 27
     */
28
-    protected static $controlChars =  array(
28
+    protected static $controlChars = array(
29 29
         '0000-0008', // control chars
30 30
         '000E-000F', // control chars
31 31
         '0010-001F', // control chars
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
     public function __construct()
51 51
     {
52 52
         // create the regex from the unicode characters list
53
-        if(!isset(self::$controlCharsRegex))
53
+        if (!isset(self::$controlCharsRegex))
54 54
         {
55 55
             $chars = $this->getCharsAsHex();
56 56
             
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
             // in the regular expression.
59 59
             $stack = array();
60 60
             
61
-            foreach($chars as $char) 
61
+            foreach ($chars as $char) 
62 62
             {
63 63
                 $stack[] = '\x{'.$char.'}';
64 64
             }
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
         
84 84
         $stack = array();
85 85
         
86
-        foreach(self::$controlChars as $char)
86
+        foreach (self::$controlChars as $char)
87 87
         {
88 88
             $tokens = explode('-', $char);
89 89
             $start = $tokens[0];
@@ -92,24 +92,24 @@  discard block
 block discarded – undo
92 92
             
93 93
             $range = array();
94 94
             
95
-            foreach(self::$hexAlphabet as $number) 
95
+            foreach (self::$hexAlphabet as $number) 
96 96
             {
97 97
                 $range[] = $prefix.$number;
98 98
             }
99 99
             
100 100
             $use = false;
101 101
             
102
-            foreach($range as $number) 
102
+            foreach ($range as $number) 
103 103
             {
104
-                if($number == $start) {
104
+                if ($number == $start) {
105 105
                     $use = true;
106 106
                 }
107 107
                 
108
-                if($use) {
108
+                if ($use) {
109 109
                     $stack[] = $number;
110 110
                 }
111 111
                 
112
-                if($number == $end) {
112
+                if ($number == $end) {
113 113
                     break;
114 114
                 }
115 115
             }
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
         $chars = $this->getCharsAsHex();
133 133
         
134 134
         $result = array();
135
-        foreach($chars as $char) {
135
+        foreach ($chars as $char) {
136 136
             $result[] = hex2bin($char);
137 137
         }
138 138
         
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
         $chars = $this->getCharsAsHex();
151 151
         
152 152
         $result = array();
153
-        foreach($chars as $char) {
153
+        foreach ($chars as $char) {
154 154
             $result[] = '\u'.strtolower($char);
155 155
         }
156 156
         
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
     */
171 171
     public function stripControlCharacters(string $string) : string
172 172
     {
173
-        if(empty($string)) 
173
+        if (empty($string)) 
174 174
         {
175 175
             return $string;
176 176
         }
@@ -178,13 +178,13 @@  discard block
 block discarded – undo
178 178
         $result = preg_replace(self::$controlCharsRegex, '', $string);
179 179
         
180 180
         // can happen if the text contains invalid UTF8
181
-        if($result === null)
181
+        if ($result === null)
182 182
         {
183 183
             $string = ConvertHelper::string2utf8($string);
184 184
             
185 185
             $result = preg_replace(self::$controlCharsRegex, '', $string);
186 186
             
187
-            if($result === null)
187
+            if ($result === null)
188 188
             {
189 189
                 throw new ConvertHelper_Exception(
190 190
                     'Cannot strip control characters: malformatted string encountered.',
Please login to merge, or discard this patch.
src/ConvertHelper.php 1 patch
Spacing   +82 added lines, -82 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
      * @param int $tabSize The amount of spaces per tab.
54 54
      * @return string
55 55
      */
56
-    public static function tabs2spaces(string $string, int $tabSize=4) : string
56
+    public static function tabs2spaces(string $string, int $tabSize = 4) : string
57 57
     {
58 58
         return str_replace("\t", str_repeat(' ', $tabSize), $string);
59 59
     }
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
     * @param int $tabSize The amount of spaces per tab in the source string.
66 66
     * @return string
67 67
     */
68
-    public static function spaces2tabs(string $string, int $tabSize=4) : string
68
+    public static function spaces2tabs(string $string, int $tabSize = 4) : string
69 69
     {
70 70
         return str_replace(str_repeat(' ', $tabSize), "\t", $string);
71 71
     }
@@ -125,10 +125,10 @@  discard block
 block discarded – undo
125 125
 
126 126
         // specifically handle zero
127 127
         if ($seconds <= 0) {
128
-            return '0 ' . t('seconds');
128
+            return '0 '.t('seconds');
129 129
         }
130 130
         
131
-        if($seconds < 1) {
131
+        if ($seconds < 1) {
132 132
             return t('less than a second');
133 133
         }
134 134
 
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
         foreach ($units as $def) {
137 137
             $quot = intval($seconds / $def['value']);
138 138
             if ($quot) {
139
-                $item = $quot . ' ';
139
+                $item = $quot.' ';
140 140
                 if (abs($quot) > 1) {
141 141
                     $item .= $def['plural'];
142 142
                 } else {
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
             return $last;
154 154
         }
155 155
 
156
-        return implode(', ', $tokens) . ' ' . t('and') . ' ' . $last;
156
+        return implode(', ', $tokens).' '.t('and').' '.$last;
157 157
     }
158 158
 
159 159
    /**
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
     {
173 173
          $converter = new ConvertHelper_DurationConverter();
174 174
          
175
-         if($datefrom instanceof \DateTime)
175
+         if ($datefrom instanceof \DateTime)
176 176
          {
177 177
              $converter->setDateFrom($datefrom);
178 178
          }
@@ -181,11 +181,11 @@  discard block
 block discarded – undo
181 181
              $converter->setDateFrom(self::timestamp2date($datefrom)); 
182 182
          }
183 183
 
184
-         if($dateto instanceof \DateTime)
184
+         if ($dateto instanceof \DateTime)
185 185
          {
186 186
              $converter->setDateTo($dateto);
187 187
          }
188
-         else if($dateto > 0)
188
+         else if ($dateto > 0)
189 189
          {
190 190
              $converter->setDateTo(self::timestamp2date($dateto));
191 191
          }
@@ -205,9 +205,9 @@  discard block
 block discarded – undo
205 205
         return $geshi->parse_code();
206 206
     }
207 207
     
208
-    public static function highlight_xml($xml, $formatSource=false)
208
+    public static function highlight_xml($xml, $formatSource = false)
209 209
     {
210
-        if($formatSource) 
210
+        if ($formatSource) 
211 211
         {
212 212
             $dom = new \DOMDocument();
213 213
             $dom->loadXML($xml);
@@ -274,16 +274,16 @@  discard block
 block discarded – undo
274 274
             return $text;
275 275
         }
276 276
 
277
-        $text = trim(mb_substr($text, 0, $targetLength)) . $append;
277
+        $text = trim(mb_substr($text, 0, $targetLength)).$append;
278 278
 
279 279
         return $text;
280 280
     }
281 281
 
282
-    public static function var_dump($var, $html=true) : string
282
+    public static function var_dump($var, $html = true) : string
283 283
     {
284 284
         $info = parseVariable($var);
285 285
         
286
-        if($html) {
286
+        if ($html) {
287 287
             return $info->toHTML();
288 288
         }
289 289
         
@@ -298,11 +298,11 @@  discard block
 block discarded – undo
298 298
     * @param bool $html Whether to style the dump as HTML.
299 299
     * @return string
300 300
     */
301
-    public static function print_r($var, bool $return=false, bool $html=true) : string
301
+    public static function print_r($var, bool $return = false, bool $html = true) : string
302 302
     {
303 303
         $result = parseVariable($var)->enableType()->toString();
304 304
         
305
-        if($html) 
305
+        if ($html) 
306 306
         {
307 307
             $result = 
308 308
             '<pre style="background:#fff;color:#333;padding:16px;border:solid 1px #bbb;border-radius:4px">'.
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
             '</pre>';
311 311
         }
312 312
         
313
-        if(!$return) 
313
+        if (!$return) 
314 314
         {
315 315
             echo $result;
316 316
         }
@@ -338,17 +338,17 @@  discard block
 block discarded – undo
338 338
     */
339 339
     public static function string2bool($string) : bool
340 340
     {
341
-        if($string === '' || $string === null || !is_scalar($string)) 
341
+        if ($string === '' || $string === null || !is_scalar($string)) 
342 342
         {
343 343
             return false;
344 344
         }
345 345
         
346
-        if(is_bool($string)) 
346
+        if (is_bool($string)) 
347 347
         {
348 348
             return $string;
349 349
         }
350 350
 
351
-        if(array_key_exists($string, self::$booleanStrings)) 
351
+        if (array_key_exists($string, self::$booleanStrings)) 
352 352
         {
353 353
             return self::$booleanStrings[$string];
354 354
         }
@@ -403,10 +403,10 @@  discard block
 block discarded – undo
403 403
     public static function date2listLabel(\DateTime $date, $includeTime = false, $shortMonth = false)
404 404
     {
405 405
         $today = new \DateTime();
406
-        if($date->format('d.m.Y') == $today->format('d.m.Y')) {
406
+        if ($date->format('d.m.Y') == $today->format('d.m.Y')) {
407 407
             $label = t('Today');
408 408
         } else {
409
-            $label = $date->format('d') . '. ' . self::month2string((int)$date->format('m'), $shortMonth) . ' ';
409
+            $label = $date->format('d').'. '.self::month2string((int)$date->format('m'), $shortMonth).' ';
410 410
             if ($date->format('Y') != date('Y')) {
411 411
                 $label .= $date->format('Y');
412 412
             }
@@ -566,12 +566,12 @@  discard block
 block discarded – undo
566 566
         $output = '';
567 567
         $split = str_split($unicodeChar);
568 568
         
569
-        foreach($split as $octet) 
569
+        foreach ($split as $octet) 
570 570
         {
571 571
             $ordInt = ord($octet);
572 572
             // Convert from int (base 10) to hex (base 16), for PHP \x syntax
573 573
             $ordHex = base_convert((string)$ordInt, 10, 16);
574
-            $output .= '\x' . $ordHex;
574
+            $output .= '\x'.$ordHex;
575 575
         }
576 576
         
577 577
         return $output;
@@ -604,19 +604,19 @@  discard block
 block discarded – undo
604 604
     
605 605
     protected static function convertScalarForComparison($scalar)
606 606
     {
607
-        if($scalar === '' || is_null($scalar)) {
607
+        if ($scalar === '' || is_null($scalar)) {
608 608
             return null;
609 609
         }
610 610
         
611
-        if(is_bool($scalar)) {
611
+        if (is_bool($scalar)) {
612 612
             return self::bool2string($scalar);
613 613
         }
614 614
         
615
-        if(is_array($scalar)) {
615
+        if (is_array($scalar)) {
616 616
             $scalar = md5(serialize($scalar));
617 617
         }
618 618
         
619
-        if($scalar !== null && !is_scalar($scalar)) {
619
+        if ($scalar !== null && !is_scalar($scalar)) {
620 620
             throw new ConvertHelper_Exception(
621 621
                 'Not a scalar value in comparison',
622 622
                 null,
@@ -665,7 +665,7 @@  discard block
 block discarded – undo
665 665
     public static function bool2string($boolean, bool $yesno = false) : string
666 666
     {
667 667
         // allow 'yes', 'true', 'no', 'false' string notations as well
668
-        if(!is_bool($boolean)) {
668
+        if (!is_bool($boolean)) {
669 669
             $boolean = self::string2bool($boolean);
670 670
         }
671 671
         
@@ -706,15 +706,15 @@  discard block
 block discarded – undo
706 706
     public static function array2attributeString($array)
707 707
     {
708 708
         $tokens = array();
709
-        foreach($array as $attr => $value) {
710
-            if($value == '' || $value == null) {
709
+        foreach ($array as $attr => $value) {
710
+            if ($value == '' || $value == null) {
711 711
                 continue;
712 712
             }
713 713
             
714 714
             $tokens[] = $attr.'="'.$value.'"';
715 715
         }
716 716
         
717
-        if(empty($tokens)) {
717
+        if (empty($tokens)) {
718 718
             return '';
719 719
         }
720 720
         
@@ -729,10 +729,10 @@  discard block
 block discarded – undo
729 729
     * @param string $string
730 730
     * @return string
731 731
     */
732
-    public static function string2attributeJS($string, $quoted=true)
732
+    public static function string2attributeJS($string, $quoted = true)
733 733
     {
734 734
         $converted = addslashes(htmlspecialchars(strip_tags($string), ENT_QUOTES, 'UTF-8'));
735
-        if($quoted) {
735
+        if ($quoted) {
736 736
             $converted = "'".$converted."'";
737 737
         } 
738 738
         
@@ -750,11 +750,11 @@  discard block
 block discarded – undo
750 750
     */
751 751
     public static function isBoolean($value) : bool
752 752
     {
753
-        if(is_bool($value)) {
753
+        if (is_bool($value)) {
754 754
             return true;
755 755
         }
756 756
         
757
-        if(!is_scalar($value)) {
757
+        if (!is_scalar($value)) {
758 758
             return false;
759 759
         }
760 760
         
@@ -770,7 +770,7 @@  discard block
 block discarded – undo
770 770
     public static function array2styleString(array $subject) : string
771 771
     {
772 772
         $tokens = array();
773
-        foreach($subject as $name => $value) {
773
+        foreach ($subject as $name => $value) {
774 774
             $tokens[] = $name.':'.$value;
775 775
         }
776 776
         
@@ -828,7 +828,7 @@  discard block
 block discarded – undo
828 828
     * 
829 829
     * @see JSHelper::buildRegexStatement()
830 830
     */
831
-    public static function regex2js(string $regex, string $statementType=JSHelper::JS_REGEX_OBJECT)
831
+    public static function regex2js(string $regex, string $statementType = JSHelper::JS_REGEX_OBJECT)
832 832
     {
833 833
         return JSHelper::buildRegexStatement($regex, $statementType);
834 834
     }
@@ -845,11 +845,11 @@  discard block
 block discarded – undo
845 845
     * @throws ConvertHelper_Exception
846 846
     * @return string
847 847
     */
848
-    public static function var2json($variable, int $options=0, int $depth=512) : string
848
+    public static function var2json($variable, int $options = 0, int $depth = 512) : string
849 849
     {
850 850
         $result = json_encode($variable, $options, $depth);
851 851
         
852
-        if($result !== false) {
852
+        if ($result !== false) {
853 853
             return $result;
854 854
         }
855 855
         
@@ -874,10 +874,10 @@  discard block
 block discarded – undo
874 874
     public static function stripUTFBom($string)
875 875
     {
876 876
         $boms = FileHelper::getUTFBOMs();
877
-        foreach($boms as $bomChars) {
877
+        foreach ($boms as $bomChars) {
878 878
             $length = mb_strlen($bomChars);
879 879
             $text = mb_substr($string, 0, $length);
880
-            if($text==$bomChars) {
880
+            if ($text == $bomChars) {
881 881
                 return mb_substr($string, $length);
882 882
             }
883 883
         }
@@ -894,7 +894,7 @@  discard block
 block discarded – undo
894 894
     */
895 895
     public static function string2utf8($string)
896 896
     {
897
-        if(!self::isStringASCII($string)) {
897
+        if (!self::isStringASCII($string)) {
898 898
             return \ForceUTF8\Encoding::toUTF8($string);
899 899
         }
900 900
         
@@ -912,11 +912,11 @@  discard block
 block discarded – undo
912 912
     */
913 913
     public static function isStringASCII($string) : bool
914 914
     {
915
-        if($string === '' || $string === NULL) {
915
+        if ($string === '' || $string === NULL) {
916 916
             return true;
917 917
         }
918 918
         
919
-        if(!is_string($string)) {
919
+        if (!is_string($string)) {
920 920
             return false;
921 921
         }
922 922
         
@@ -950,7 +950,7 @@  discard block
 block discarded – undo
950 950
     * @param array $options
951 951
     * @return float
952 952
     */
953
-    public static function matchString($source, $target, $options=array())
953
+    public static function matchString($source, $target, $options = array())
954 954
     {
955 955
         $defaults = array(
956 956
             'maxLevenshtein' => 10,
@@ -960,12 +960,12 @@  discard block
 block discarded – undo
960 960
         $options = array_merge($defaults, $options);
961 961
         
962 962
         // avoid doing this via levenshtein
963
-        if($source == $target) {
963
+        if ($source == $target) {
964 964
             return 100;
965 965
         }
966 966
         
967 967
         $diff = levenshtein($source, $target);
968
-        if($diff > $options['maxLevenshtein']) {
968
+        if ($diff > $options['maxLevenshtein']) {
969 969
             return 0;
970 970
         }
971 971
         
@@ -1049,24 +1049,24 @@  discard block
 block discarded – undo
1049 1049
     * @see ConvertHelper::INTERVAL_HOURS
1050 1050
     * @see ConvertHelper::INTERVAL_DAYS
1051 1051
     */
1052
-    public static function interval2total(\DateInterval $interval, $unit=self::INTERVAL_SECONDS) : int
1052
+    public static function interval2total(\DateInterval $interval, $unit = self::INTERVAL_SECONDS) : int
1053 1053
     {
1054 1054
         $total = (int)$interval->format('%a');
1055 1055
         if ($unit == self::INTERVAL_DAYS) {
1056 1056
             return $total;
1057 1057
         }
1058 1058
         
1059
-        $total = ($total * 24) + ((int)$interval->h );
1059
+        $total = ($total * 24) + ((int)$interval->h);
1060 1060
         if ($unit == self::INTERVAL_HOURS) {
1061 1061
             return $total;
1062 1062
         }
1063 1063
     
1064
-        $total = ($total * 60) + ((int)$interval->i );
1064
+        $total = ($total * 60) + ((int)$interval->i);
1065 1065
         if ($unit == self::INTERVAL_MINUTES) {
1066 1066
             return $total;
1067 1067
         }
1068 1068
 
1069
-        $total = ($total * 60) + ((int)$interval->s );
1069
+        $total = ($total * 60) + ((int)$interval->s);
1070 1070
         if ($unit == self::INTERVAL_SECONDS) {
1071 1071
             return $total;
1072 1072
         }
@@ -1095,13 +1095,13 @@  discard block
 block discarded – undo
1095 1095
     * @param bool $short
1096 1096
     * @return string|NULL
1097 1097
     */
1098
-    public static function date2dayName(\DateTime $date, bool $short=false)
1098
+    public static function date2dayName(\DateTime $date, bool $short = false)
1099 1099
     {
1100 1100
         $day = $date->format('l');
1101 1101
         $invariant = self::getDayNamesInvariant();
1102 1102
         
1103 1103
         $idx = array_search($day, $invariant);
1104
-        if($idx !== false) {
1104
+        if ($idx !== false) {
1105 1105
             $localized = self::getDayNames($short);
1106 1106
             return $localized[$idx];
1107 1107
         }
@@ -1124,10 +1124,10 @@  discard block
 block discarded – undo
1124 1124
     * @param bool $short
1125 1125
     * @return array
1126 1126
     */
1127
-    public static function getDayNames(bool $short=false) : array
1127
+    public static function getDayNames(bool $short = false) : array
1128 1128
     {
1129
-        if($short) {
1130
-            if(!isset(self::$daysShort)) {
1129
+        if ($short) {
1130
+            if (!isset(self::$daysShort)) {
1131 1131
                 self::$daysShort = array(
1132 1132
                     t('Mon'),
1133 1133
                     t('Tue'),
@@ -1142,7 +1142,7 @@  discard block
 block discarded – undo
1142 1142
             return self::$daysShort;
1143 1143
         }
1144 1144
         
1145
-        if(!isset(self::$days)) {
1145
+        if (!isset(self::$days)) {
1146 1146
             self::$days = array(
1147 1147
                 t('Monday'),
1148 1148
                 t('Tuesday'),
@@ -1167,17 +1167,17 @@  discard block
 block discarded – undo
1167 1167
      */
1168 1168
     public static function implodeWithAnd(array $list, $sep = ', ', $conjunction = null)
1169 1169
     {
1170
-        if(empty($list)) {
1170
+        if (empty($list)) {
1171 1171
             return '';
1172 1172
         }
1173 1173
         
1174
-        if(empty($conjunction)) {
1174
+        if (empty($conjunction)) {
1175 1175
             $conjunction = t('and');
1176 1176
         }
1177 1177
         
1178 1178
         $last = array_pop($list);
1179
-        if($list) {
1180
-            return implode($sep, $list) . $conjunction . ' ' . $last;
1179
+        if ($list) {
1180
+            return implode($sep, $list).$conjunction.' '.$last;
1181 1181
         }
1182 1182
         
1183 1183
         return $last;
@@ -1196,7 +1196,7 @@  discard block
 block discarded – undo
1196 1196
     public static function string2array(string $string) : array
1197 1197
     {
1198 1198
         $result = preg_split('//u', $string, null, PREG_SPLIT_NO_EMPTY);
1199
-        if($result !== false) {
1199
+        if ($result !== false) {
1200 1200
             return $result;
1201 1201
         }
1202 1202
         
@@ -1211,12 +1211,12 @@  discard block
 block discarded – undo
1211 1211
     */
1212 1212
     public static function isStringHTML(string $string) : bool
1213 1213
     {
1214
-        if(preg_match('%<[a-z/][\s\S]*>%siU', $string)) {
1214
+        if (preg_match('%<[a-z/][\s\S]*>%siU', $string)) {
1215 1215
             return true;
1216 1216
         }
1217 1217
         
1218 1218
         $decoded = html_entity_decode($string);
1219
-        if($decoded !== $string) {
1219
+        if ($decoded !== $string) {
1220 1220
             return true;
1221 1221
         }
1222 1222
         
@@ -1325,14 +1325,14 @@  discard block
 block discarded – undo
1325 1325
     * @param bool $caseInsensitive
1326 1326
     * @return ConvertHelper_StringMatch[]
1327 1327
     */
1328
-    public static function findString(string $needle, string $haystack, bool $caseInsensitive=false)
1328
+    public static function findString(string $needle, string $haystack, bool $caseInsensitive = false)
1329 1329
     {
1330
-        if($needle === '') {
1330
+        if ($needle === '') {
1331 1331
             return array();
1332 1332
         }
1333 1333
         
1334 1334
         $function = 'mb_strpos';
1335
-        if($caseInsensitive) {
1335
+        if ($caseInsensitive) {
1336 1336
             $function = 'mb_stripos';
1337 1337
         }
1338 1338
         
@@ -1340,7 +1340,7 @@  discard block
 block discarded – undo
1340 1340
         $positions = array();
1341 1341
         $length = mb_strlen($needle);
1342 1342
         
1343
-        while( ($pos = $function($haystack, $needle, $pos)) !== false) 
1343
+        while (($pos = $function($haystack, $needle, $pos)) !== false) 
1344 1344
         {
1345 1345
             $match = mb_substr($haystack, $pos, $length);
1346 1346
             $positions[] = new ConvertHelper_StringMatch($pos, $match);
@@ -1360,7 +1360,7 @@  discard block
 block discarded – undo
1360 1360
     */
1361 1361
     public static function explodeTrim(string $delimiter, string $string) : array
1362 1362
     {
1363
-        if(empty($string) || empty($delimiter)) {
1363
+        if (empty($string) || empty($delimiter)) {
1364 1364
             return array();
1365 1365
         }
1366 1366
         
@@ -1368,8 +1368,8 @@  discard block
 block discarded – undo
1368 1368
         $tokens = array_map('trim', $tokens);
1369 1369
         
1370 1370
         $keep = array();
1371
-        foreach($tokens as $token) {
1372
-            if($token !== '') {
1371
+        foreach ($tokens as $token) {
1372
+            if ($token !== '') {
1373 1373
                 $keep[] = $token;
1374 1374
             }
1375 1375
         }
@@ -1387,11 +1387,11 @@  discard block
 block discarded – undo
1387 1387
     */
1388 1388
     public static function detectEOLCharacter(string $subjectString) : ?ConvertHelper_EOL
1389 1389
     {
1390
-        if(empty($subjectString)) {
1390
+        if (empty($subjectString)) {
1391 1391
             return null;
1392 1392
         }
1393 1393
         
1394
-        if(!isset(self::$eolChars))
1394
+        if (!isset(self::$eolChars))
1395 1395
         {
1396 1396
             $cr = chr((int)hexdec('0d'));
1397 1397
             $lf = chr((int)hexdec('0a'));
@@ -1422,18 +1422,18 @@  discard block
 block discarded – undo
1422 1422
         
1423 1423
         $max = 0;
1424 1424
         $results = array();
1425
-        foreach(self::$eolChars as $def) 
1425
+        foreach (self::$eolChars as $def) 
1426 1426
         {
1427 1427
             $amount = substr_count($subjectString, $def['char']);
1428 1428
             
1429
-            if($amount > $max)
1429
+            if ($amount > $max)
1430 1430
             {
1431 1431
                 $max = $amount;
1432 1432
                 $results[] = $def;
1433 1433
             }
1434 1434
         }
1435 1435
         
1436
-        if(empty($results)) {
1436
+        if (empty($results)) {
1437 1437
             return null;
1438 1438
         }
1439 1439
         
@@ -1453,9 +1453,9 @@  discard block
 block discarded – undo
1453 1453
     */
1454 1454
     public static function arrayRemoveKeys(array &$array, array $keys) : void
1455 1455
     {
1456
-        foreach($keys as $key) 
1456
+        foreach ($keys as $key) 
1457 1457
         {
1458
-            if(array_key_exists($key, $array)) {
1458
+            if (array_key_exists($key, $array)) {
1459 1459
                 unset($array[$key]); 
1460 1460
             }
1461 1461
         }
@@ -1470,17 +1470,17 @@  discard block
 block discarded – undo
1470 1470
     */
1471 1471
     public static function isInteger($value) : bool
1472 1472
     {
1473
-        if(is_int($value)) {
1473
+        if (is_int($value)) {
1474 1474
             return true;
1475 1475
         }
1476 1476
         
1477 1477
         // booleans get converted to numbers, so they would
1478 1478
         // actually match the regex.
1479
-        if(is_bool($value)) {
1479
+        if (is_bool($value)) {
1480 1480
             return false;
1481 1481
         }
1482 1482
         
1483
-        if(is_string($value) && $value !== '') {
1483
+        if (is_string($value) && $value !== '') {
1484 1484
             return preg_match('/\A-?\d+\z/', $value) === 1;
1485 1485
         }
1486 1486
         
Please login to merge, or discard this patch.