Passed
Push — master ( 256bda...f1ca2b )
by Sebastian
02:41
created
src/URLInfo.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -123,9 +123,9 @@  discard block
 block discarded – undo
123 123
     * @param bool $enabled
124 124
     * @return URLInfo
125 125
     */
126
-    public function setUTFEncoding(bool $enabled=true) : URLInfo
126
+    public function setUTFEncoding(bool $enabled = true) : URLInfo
127 127
     {
128
-        if($this->encodeUTFChars !== $enabled)
128
+        if ($this->encodeUTFChars !== $enabled)
129 129
         {
130 130
             $this->encodeUTFChars = $enabled;
131 131
             $this->parse(); // re-parse the URL to apply the changes
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
     {
230 230
         $port = $this->getInfoKey('port');
231 231
         
232
-        if(!empty($port)) {
232
+        if (!empty($port)) {
233 233
             return (int)$port;
234 234
         }
235 235
         
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
     
310 310
     protected function getInfoKey(string $name) : string
311 311
     {
312
-        if(isset($this->info[$name])) {
312
+        if (isset($this->info[$name])) {
313 313
             return (string)$this->info[$name];
314 314
         }
315 315
         
@@ -338,13 +338,13 @@  discard block
 block discarded – undo
338 338
         return $this->normalize(false);
339 339
     }
340 340
     
341
-    protected function normalize(bool $auth=true) : string
341
+    protected function normalize(bool $auth = true) : string
342 342
     {
343
-        if(!$this->isValid()) {
343
+        if (!$this->isValid()) {
344 344
             return '';
345 345
         }
346 346
         
347
-        if(!isset($this->normalizer)) {
347
+        if (!isset($this->normalizer)) {
348 348
             $this->normalizer = new URLInfo_Normalizer($this);
349 349
         }
350 350
         
@@ -374,7 +374,7 @@  discard block
 block discarded – undo
374 374
     */
375 375
     public function getHighlighted() : string
376 376
     {
377
-        if(!$this->isValid()) {
377
+        if (!$this->isValid()) {
378 378
             return '';
379 379
         }
380 380
         
@@ -416,14 +416,14 @@  discard block
 block discarded – undo
416 416
     */
417 417
     public function getParams() : array
418 418
     {
419
-        if(!$this->paramExclusion || empty($this->excludedParams)) {
419
+        if (!$this->paramExclusion || empty($this->excludedParams)) {
420 420
             return $this->info['params'];
421 421
         }
422 422
         
423 423
         $keep = array();
424
-        foreach($this->info['params'] as $name => $value) 
424
+        foreach ($this->info['params'] as $name => $value) 
425 425
         {
426
-            if(!isset($this->excludedParams[$name])) {
426
+            if (!isset($this->excludedParams[$name])) {
427 427
                 $keep[$name] = $value;
428 428
             }
429 429
         }
@@ -449,7 +449,7 @@  discard block
 block discarded – undo
449 449
     */
450 450
     public function getParam(string $name) : string
451 451
     {
452
-        if(isset($this->info['params'][$name])) {
452
+        if (isset($this->info['params'][$name])) {
453 453
             return $this->info['params'][$name];
454 454
         }
455 455
         
@@ -468,7 +468,7 @@  discard block
 block discarded – undo
468 468
     */
469 469
     public function excludeParam(string $name, string $reason) : URLInfo
470 470
     {
471
-        if(!isset($this->excludedParams[$name]))
471
+        if (!isset($this->excludedParams[$name]))
472 472
         {
473 473
             $this->excludedParams[$name] = $reason;
474 474
             $this->setParamExclusion();
@@ -494,7 +494,7 @@  discard block
 block discarded – undo
494 494
     
495 495
     public function getTypeLabel() : string
496 496
     {
497
-        if(!isset(self::$typeLabels))
497
+        if (!isset(self::$typeLabels))
498 498
         {
499 499
             self::$typeLabels = array(
500 500
                 self::TYPE_EMAIL => t('Email'),
@@ -506,7 +506,7 @@  discard block
 block discarded – undo
506 506
         
507 507
         $type = $this->getType();
508 508
         
509
-        if(!isset(self::$typeLabels[$type]))
509
+        if (!isset(self::$typeLabels[$type]))
510 510
         {
511 511
             throw new BaseException(
512 512
                 sprintf('Unknown URL type label for type [%s].', $type),
@@ -526,7 +526,7 @@  discard block
 block discarded – undo
526 526
     * @param bool $highlight
527 527
     * @return URLInfo
528 528
     */
529
-    public function setHighlightExcluded(bool $highlight=true) : URLInfo
529
+    public function setHighlightExcluded(bool $highlight = true) : URLInfo
530 530
     {
531 531
         $this->highlightExcluded = $highlight;
532 532
         return $this;
@@ -574,7 +574,7 @@  discard block
 block discarded – undo
574 574
      * @see URLInfo::isParamExclusionEnabled()
575 575
      * @see URLInfo::setHighlightExcluded()
576 576
      */
577
-    public function setParamExclusion(bool $enabled=true) : URLInfo
577
+    public function setParamExclusion(bool $enabled = true) : URLInfo
578 578
     {
579 579
         $this->paramExclusion = $enabled;
580 580
         return $this;
@@ -600,13 +600,13 @@  discard block
 block discarded – undo
600 600
     */
601 601
     public function containsExcludedParams() : bool
602 602
     {
603
-        if(empty($this->excludedParams)) {
603
+        if (empty($this->excludedParams)) {
604 604
             return false;
605 605
         }
606 606
         
607 607
         $names = array_keys($this->info['params']);
608
-        foreach($names as $name) {
609
-            if(isset($this->excludedParams[$name])) {
608
+        foreach ($names as $name) {
609
+            if (isset($this->excludedParams[$name])) {
610 610
                 return true;
611 611
             }
612 612
         }
@@ -622,7 +622,7 @@  discard block
 block discarded – undo
622 622
 
623 623
     public function offsetSet($offset, $value) 
624 624
     {
625
-        if(in_array($offset, $this->infoKeys)) {
625
+        if (in_array($offset, $this->infoKeys)) {
626 626
             $this->info[$offset] = $value;
627 627
         }
628 628
     }
@@ -639,11 +639,11 @@  discard block
 block discarded – undo
639 639
     
640 640
     public function offsetGet($offset) 
641 641
     {
642
-        if($offset === 'port') {
642
+        if ($offset === 'port') {
643 643
             return $this->getPort();
644 644
         }
645 645
         
646
-        if(in_array($offset, $this->infoKeys)) {
646
+        if (in_array($offset, $this->infoKeys)) {
647 647
             return $this->getInfoKey($offset);
648 648
         }
649 649
         
@@ -675,7 +675,7 @@  discard block
 block discarded – undo
675 675
     * @return bool
676 676
     * @throws BaseException
677 677
     */
678
-    public function tryConnect(bool $verifySSL=true) : bool
678
+    public function tryConnect(bool $verifySSL = true) : bool
679 679
     {
680 680
         return $this->createConnectionTester()
681 681
         ->setVerifySSL($verifySSL)
@@ -718,7 +718,7 @@  discard block
 block discarded – undo
718 718
     */
719 719
     public function removeParam(string $param) : URLInfo
720 720
     {
721
-        if(isset($this->info['params'][$param]))
721
+        if (isset($this->info['params'][$param]))
722 722
         {
723 723
             unset($this->info['params'][$param]);
724 724
         }
Please login to merge, or discard this patch.
src/URLInfo/ConnectionTester.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
     * @param bool $verifySSL
49 49
     * @return URLInfo_ConnectionTester
50 50
     */
51
-    public function setVerifySSL(bool $verifySSL=true) : URLInfo_ConnectionTester
51
+    public function setVerifySSL(bool $verifySSL = true) : URLInfo_ConnectionTester
52 52
     {
53 53
         $this->setOption('verify-ssl', $verifySSL);
54 54
             return $this;
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
         return $this->getBoolOption('verify-ssl');
60 60
     }
61 61
     
62
-    public function setVerboseMode(bool $enabled=true) : URLInfo_ConnectionTester
62
+    public function setVerboseMode(bool $enabled = true) : URLInfo_ConnectionTester
63 63
     {
64 64
         $this->setOption('curl-verbose', $enabled);
65 65
         return $this;
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
         
94 94
         $ch = curl_init();
95 95
         
96
-        if(!is_resource($ch))
96
+        if (!is_resource($ch))
97 97
         {
98 98
             throw new BaseException(
99 99
                 'Could not initialize a new cURL instance.',
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
     */
111 111
     private function configureOptions($ch) : void
112 112
     {
113
-        if($this->isVerboseModeEnabled())
113
+        if ($this->isVerboseModeEnabled())
114 114
         {
115 115
             curl_setopt($ch, CURLOPT_VERBOSE, true);
116 116
         }
@@ -120,13 +120,13 @@  discard block
 block discarded – undo
120 120
         curl_setopt($ch, CURLOPT_TIMEOUT, $this->getTimeout());
121 121
         curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
122 122
         
123
-        if(!$this->isVerifySSLEnabled())
123
+        if (!$this->isVerifySSLEnabled())
124 124
         {
125 125
             curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
126 126
             curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
127 127
         }
128 128
         
129
-        if($this->url->hasUsername())
129
+        if ($this->url->hasUsername())
130 130
         {
131 131
             curl_setopt($ch, CURLOPT_USERNAME, $this->url->getUsername());
132 132
             curl_setopt($ch, CURLOPT_PASSWORD, $this->url->getPassword());
Please login to merge, or discard this patch.
src/FileHelper.php 1 patch
Spacing   +103 added lines, -103 removed lines patch added patch discarded remove patch
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
         
83 83
         $contents = file_get_contents($file);
84 84
         
85
-        if($contents === false) 
85
+        if ($contents === false) 
86 86
         {
87 87
             throw new FileHelper_Exception(
88 88
                 'Cannot load serialized content from file.',
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
         
97 97
         $result = @unserialize($contents);
98 98
         
99
-        if($result !== false) {
99
+        if ($result !== false) {
100 100
             return $result;
101 101
         }
102 102
         
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
     
113 113
     public static function deleteTree($rootFolder)
114 114
     {
115
-        if(!file_exists($rootFolder)) {
115
+        if (!file_exists($rootFolder)) {
116 116
             return true;
117 117
         }
118 118
         
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
     */
154 154
     public static function createFolder($path)
155 155
     {
156
-        if(is_dir($path) || mkdir($path, 0777, true)) {
156
+        if (is_dir($path) || mkdir($path, 0777, true)) {
157 157
             return;
158 158
         }
159 159
         
@@ -188,11 +188,11 @@  discard block
 block discarded – undo
188 188
 
189 189
             if ($item->isDir()) 
190 190
             {
191
-                FileHelper::copyTree(str_replace('\\', '/', $itemPath), $target . '/' . $baseName);
191
+                FileHelper::copyTree(str_replace('\\', '/', $itemPath), $target.'/'.$baseName);
192 192
             } 
193
-            else if($item->isFile()) 
193
+            else if ($item->isFile()) 
194 194
             {
195
-                self::copyFile($itemPath, $target . '/' . $baseName);
195
+                self::copyFile($itemPath, $target.'/'.$baseName);
196 196
             }
197 197
         }
198 198
     }
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
     {
218 218
         self::requireFileExists($sourcePath, self::ERROR_SOURCE_FILE_NOT_FOUND);
219 219
         
220
-        if(!is_readable($sourcePath))
220
+        if (!is_readable($sourcePath))
221 221
         {
222 222
             throw new FileHelper_Exception(
223 223
                 sprintf('Source file [%s] to copy is not readable.', basename($sourcePath)),
@@ -231,11 +231,11 @@  discard block
 block discarded – undo
231 231
         
232 232
         $targetFolder = dirname($targetPath);
233 233
         
234
-        if(!file_exists($targetFolder))
234
+        if (!file_exists($targetFolder))
235 235
         {
236 236
             self::createFolder($targetFolder);
237 237
         }
238
-        else if(!is_writable($targetFolder)) 
238
+        else if (!is_writable($targetFolder)) 
239 239
         {
240 240
             throw new FileHelper_Exception(
241 241
                 sprintf('Target folder [%s] is not writable.', basename($targetFolder)),
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
             );
248 248
         }
249 249
         
250
-        if(copy($sourcePath, $targetPath)) {
250
+        if (copy($sourcePath, $targetPath)) {
251 251
             return;
252 252
         }
253 253
         
@@ -274,11 +274,11 @@  discard block
 block discarded – undo
274 274
     */
275 275
     public static function deleteFile(string $filePath) : void
276 276
     {
277
-        if(!file_exists($filePath)) {
277
+        if (!file_exists($filePath)) {
278 278
             return;
279 279
         }
280 280
         
281
-        if(unlink($filePath)) {
281
+        if (unlink($filePath)) {
282 282
             return;
283 283
         }
284 284
         
@@ -302,10 +302,10 @@  discard block
 block discarded – undo
302 302
     * @return \parseCSV
303 303
     * @todo Move this to the CSV helper.
304 304
     */
305
-    public static function createCSVParser(string $delimiter = ';', string $enclosure = '"', string $escape = '\\', bool $heading=false) : \parseCSV
305
+    public static function createCSVParser(string $delimiter = ';', string $enclosure = '"', string $escape = '\\', bool $heading = false) : \parseCSV
306 306
     {
307
-        if($delimiter==='') { $delimiter = ';'; }
308
-        if($enclosure==='') { $enclosure = '"'; }
307
+        if ($delimiter === '') { $delimiter = ';'; }
308
+        if ($enclosure === '') { $enclosure = '"'; }
309 309
         
310 310
         $parser = new \parseCSV(null, null, null, array());
311 311
 
@@ -333,11 +333,11 @@  discard block
 block discarded – undo
333 333
     * @see parseCSVFile()
334 334
     * @see FileHelper::ERROR_PARSING_CSV
335 335
     */
336
-    public static function parseCSVString(string $csv, string $delimiter = ';', string $enclosure = '"', string $escape = '\\', bool $heading=false) : array
336
+    public static function parseCSVString(string $csv, string $delimiter = ';', string $enclosure = '"', string $escape = '\\', bool $heading = false) : array
337 337
     {
338 338
         $parser = self::createCSVParser($delimiter, $enclosure, $escape, $heading);
339 339
         $result = $parser->parse_string(/** @scrutinizer ignore-type */ $csv);
340
-        if(is_array($result)) {
340
+        if (is_array($result)) {
341 341
             return $result;
342 342
         }
343 343
         
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
      * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST
367 367
      * @see FileHelper::ERROR_CANNOT_READ_FILE_CONTENTS
368 368
      */
369
-    public static function parseCSVFile(string $filePath, string $delimiter = ';', string $enclosure = '"', string $escape = '\\', bool $heading=false) : array
369
+    public static function parseCSVFile(string $filePath, string $delimiter = ';', string $enclosure = '"', string $escape = '\\', bool $heading = false) : array
370 370
     {
371 371
         $content = self::readContents($filePath);
372 372
 
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
     public static function detectMimeType(string $fileName) : ?string
384 384
     {
385 385
         $ext = self::getExtension($fileName);
386
-        if(empty($ext)) {
386
+        if (empty($ext)) {
387 387
             return null;
388 388
         }
389 389
 
@@ -404,11 +404,11 @@  discard block
 block discarded – undo
404 404
      * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST
405 405
      * @see FileHelper::ERROR_UNKNOWN_FILE_MIME_TYPE
406 406
      */
407
-    public static function sendFile(string $filePath, $fileName = null, bool $asAttachment=true)
407
+    public static function sendFile(string $filePath, $fileName = null, bool $asAttachment = true)
408 408
     {
409 409
         self::requireFileExists($filePath);
410 410
         
411
-        if(empty($fileName)) {
411
+        if (empty($fileName)) {
412 412
             $fileName = basename($filePath);
413 413
         }
414 414
 
@@ -426,10 +426,10 @@  discard block
 block discarded – undo
426 426
         
427 427
         header("Cache-Control: public", true);
428 428
         header("Content-Description: File Transfer", true);
429
-        header("Content-Type: " . $mime, true);
429
+        header("Content-Type: ".$mime, true);
430 430
 
431 431
         $disposition = 'inline';
432
-        if($asAttachment) {
432
+        if ($asAttachment) {
433 433
             $disposition = 'attachment';
434 434
         }
435 435
         
@@ -457,7 +457,7 @@  discard block
 block discarded – undo
457 457
         requireCURL();
458 458
         
459 459
         $ch = curl_init();
460
-        if(!is_resource($ch)) 
460
+        if (!is_resource($ch)) 
461 461
         {
462 462
             throw new FileHelper_Exception(
463 463
                 'Could not initialize a new cURL instance.',
@@ -478,7 +478,7 @@  discard block
 block discarded – undo
478 478
         
479 479
         $output = curl_exec($ch);
480 480
 
481
-        if($output === false) {
481
+        if ($output === false) {
482 482
             throw new FileHelper_Exception(
483 483
                 'Unable to open URL',
484 484
                 sprintf(
@@ -492,7 +492,7 @@  discard block
 block discarded – undo
492 492
 
493 493
         curl_close($ch);
494 494
 
495
-        if(is_string($output)) 
495
+        if (is_string($output)) 
496 496
         {
497 497
             return $output;
498 498
         }
@@ -514,7 +514,7 @@  discard block
 block discarded – undo
514 514
     */
515 515
     public static function isPHPFile($pathOrDirIterator)
516 516
     {
517
-    	if(self::getExtension($pathOrDirIterator) == 'php') {
517
+    	if (self::getExtension($pathOrDirIterator) == 'php') {
518 518
     		return true;
519 519
     	}
520 520
     	
@@ -531,14 +531,14 @@  discard block
 block discarded – undo
531 531
     */
532 532
     public static function getExtension($pathOrDirIterator, bool $lowercase = true) : string
533 533
     {
534
-        if($pathOrDirIterator instanceof \DirectoryIterator) {
534
+        if ($pathOrDirIterator instanceof \DirectoryIterator) {
535 535
             $filename = $pathOrDirIterator->getFilename();
536 536
         } else {
537 537
             $filename = basename($pathOrDirIterator);
538 538
         }
539 539
          
540 540
         $ext = pathinfo($filename, PATHINFO_EXTENSION);
541
-        if($lowercase) {
541
+        if ($lowercase) {
542 542
         	$ext = mb_strtolower($ext);
543 543
         }
544 544
         
@@ -560,13 +560,13 @@  discard block
 block discarded – undo
560 560
     public static function getFilename($pathOrDirIterator, $extension = true)
561 561
     {
562 562
         $path = $pathOrDirIterator;
563
-    	if($pathOrDirIterator instanceof \DirectoryIterator) {
563
+    	if ($pathOrDirIterator instanceof \DirectoryIterator) {
564 564
     		$path = $pathOrDirIterator->getFilename();
565 565
     	}
566 566
     	
567 567
     	$path = self::normalizePath($path);
568 568
     	
569
-    	if(!$extension) {
569
+    	if (!$extension) {
570 570
     	    return pathinfo($path, PATHINFO_FILENAME);
571 571
     	}
572 572
     	
@@ -584,12 +584,12 @@  discard block
 block discarded – undo
584 584
     * @see FileHelper::ERROR_CANNOT_FIND_JSON_FILE
585 585
     * @see FileHelper::ERROR_CANNOT_DECODE_JSON_FILE
586 586
     */ 
587
-    public static function parseJSONFile(string $file, $targetEncoding=null, $sourceEncoding=null)
587
+    public static function parseJSONFile(string $file, $targetEncoding = null, $sourceEncoding = null)
588 588
     {
589 589
         self::requireFileExists($file, self::ERROR_CANNOT_FIND_JSON_FILE);
590 590
         
591 591
         $content = file_get_contents($file);
592
-        if(!$content) {
592
+        if (!$content) {
593 593
             throw new FileHelper_Exception(
594 594
                 'Cannot get file contents',
595 595
                 sprintf(
@@ -600,12 +600,12 @@  discard block
 block discarded – undo
600 600
             );
601 601
         }
602 602
         
603
-        if(isset($targetEncoding)) {
603
+        if (isset($targetEncoding)) {
604 604
             $content = mb_convert_encoding($content, $targetEncoding, $sourceEncoding);
605 605
         }
606 606
         
607 607
         $json = json_decode($content, true);
608
-        if($json === false || $json === NULL) {
608
+        if ($json === false || $json === NULL) {
609 609
             throw new FileHelper_Exception(
610 610
                 'Cannot decode json data',
611 611
                 sprintf(
@@ -645,13 +645,13 @@  discard block
 block discarded – undo
645 645
         
646 646
         $name = str_replace(array_keys($replaces), array_values($replaces), $name);
647 647
         
648
-        while(strstr($name, '  ')) {
648
+        while (strstr($name, '  ')) {
649 649
             $name = str_replace('  ', ' ', $name);
650 650
         }
651 651
 
652 652
         $name = str_replace(array_keys($replaces), array_values($replaces), $name);
653 653
         
654
-        while(strstr($name, '..')) {
654
+        while (strstr($name, '..')) {
655 655
             $name = str_replace('..', '.', $name);
656 656
         }
657 657
         
@@ -683,7 +683,7 @@  discard block
 block discarded – undo
683 683
     * @return array An indexed array with files.
684 684
     * @see FileHelper::createFileFinder()
685 685
     */
686
-    public static function findHTMLFiles(string $targetFolder, array $options=array()) : array
686
+    public static function findHTMLFiles(string $targetFolder, array $options = array()) : array
687 687
     {
688 688
         return self::findFiles($targetFolder, array('html'), $options);
689 689
     }
@@ -700,7 +700,7 @@  discard block
 block discarded – undo
700 700
     * @return array An indexed array of PHP files.
701 701
     * @see FileHelper::createFileFinder()
702 702
     */
703
-    public static function findPHPFiles(string $targetFolder, array $options=array()) : array
703
+    public static function findPHPFiles(string $targetFolder, array $options = array()) : array
704 704
     {
705 705
         return self::findFiles($targetFolder, array('php'), $options);
706 706
     }
@@ -720,22 +720,22 @@  discard block
 block discarded – undo
720 720
     * @return array
721 721
     * @see FileHelper::createFileFinder()
722 722
     */
723
-    public static function findFiles(string $targetFolder, array $extensions=array(), array $options=array(), array $files=array()) : array
723
+    public static function findFiles(string $targetFolder, array $extensions = array(), array $options = array(), array $files = array()) : array
724 724
     {
725 725
         $finder = self::createFileFinder($targetFolder);
726 726
 
727 727
         $finder->setPathmodeStrip();
728 728
         
729
-        if(isset($options['relative-path']) && $options['relative-path'] === true) 
729
+        if (isset($options['relative-path']) && $options['relative-path'] === true) 
730 730
         {
731 731
             $finder->setPathmodeRelative();
732 732
         } 
733
-        else if(isset($options['absolute-path']) && $options['absolute-path'] === true)
733
+        else if (isset($options['absolute-path']) && $options['absolute-path'] === true)
734 734
         {
735 735
             $finder->setPathmodeAbsolute();
736 736
         }
737 737
         
738
-        if(isset($options['strip-extension'])) 
738
+        if (isset($options['strip-extension'])) 
739 739
         {
740 740
             $finder->stripExtensions();
741 741
         }
@@ -753,12 +753,12 @@  discard block
 block discarded – undo
753 753
     * @param bool $keepPath Whether to keep the path component, if any. Default PHP pathinfo behavior is not to.
754 754
     * @return string
755 755
     */
756
-    public static function removeExtension(string $filename, bool $keepPath=false) : string
756
+    public static function removeExtension(string $filename, bool $keepPath = false) : string
757 757
     {
758 758
         // normalize paths to allow windows style slashes even on nix servers
759 759
         $filename = self::normalizePath($filename);
760 760
         
761
-        if(!$keepPath) 
761
+        if (!$keepPath) 
762 762
         {
763 763
             return pathinfo($filename, PATHINFO_FILENAME);
764 764
         }
@@ -791,7 +791,7 @@  discard block
 block discarded – undo
791 791
     public static function detectUTFBom(string $filename) : ?string
792 792
     {
793 793
         $fp = fopen($filename, 'r');
794
-        if($fp === false) 
794
+        if ($fp === false) 
795 795
         {
796 796
             throw new FileHelper_Exception(
797 797
                 'Cannot open file for reading',
@@ -806,10 +806,10 @@  discard block
 block discarded – undo
806 806
 
807 807
         $boms = self::getUTFBOMs();
808 808
         
809
-        foreach($boms as $bom => $value) 
809
+        foreach ($boms as $bom => $value) 
810 810
         {
811 811
             $length = mb_strlen($value);
812
-            if(mb_substr($text, 0, $length) == $value) {
812
+            if (mb_substr($text, 0, $length) == $value) {
813 813
                 return $bom;
814 814
             }
815 815
         }
@@ -828,13 +828,13 @@  discard block
 block discarded – undo
828 828
     */
829 829
     public static function getUTFBOMs()
830 830
     {
831
-        if(!isset(self::$utfBoms)) {
831
+        if (!isset(self::$utfBoms)) {
832 832
             self::$utfBoms = array(
833
-                'UTF32-BE' => chr(0x00) . chr(0x00) . chr(0xFE) . chr(0xFF),
834
-                'UTF32-LE' => chr(0xFF) . chr(0xFE) . chr(0x00) . chr(0x00),
835
-                'UTF16-BE' => chr(0xFE) . chr(0xFF),
836
-                'UTF16-LE' => chr(0xFF) . chr(0xFE),
837
-                'UTF8' => chr(0xEF) . chr(0xBB) . chr(0xBF)
833
+                'UTF32-BE' => chr(0x00).chr(0x00).chr(0xFE).chr(0xFF),
834
+                'UTF32-LE' => chr(0xFF).chr(0xFE).chr(0x00).chr(0x00),
835
+                'UTF16-BE' => chr(0xFE).chr(0xFF),
836
+                'UTF16-LE' => chr(0xFF).chr(0xFE),
837
+                'UTF8' => chr(0xEF).chr(0xBB).chr(0xBF)
838 838
             );
839 839
         }
840 840
         
@@ -855,7 +855,7 @@  discard block
 block discarded – undo
855 855
         $encodings = self::getKnownUnicodeEncodings();
856 856
 
857 857
         $keep = array();
858
-        foreach($encodings as $string) 
858
+        foreach ($encodings as $string) 
859 859
         {
860 860
             $withHyphen = str_replace('UTF', 'UTF-', $string);
861 861
             
@@ -902,16 +902,16 @@  discard block
 block discarded – undo
902 902
     * @see FileHelper::ERROR_SAVE_FILE_NOT_WRITABLE
903 903
     * @see FileHelper::ERROR_SAVE_FILE_WRITE_FAILED
904 904
     */
905
-    public static function saveAsJSON($data, string $file, bool $pretty=false)
905
+    public static function saveAsJSON($data, string $file, bool $pretty = false)
906 906
     {
907 907
         $options = null;
908
-        if($pretty) {
908
+        if ($pretty) {
909 909
             $options = JSON_PRETTY_PRINT;
910 910
         }
911 911
         
912 912
         $json = json_encode($data, $options);
913 913
         
914
-        if($json===false) 
914
+        if ($json === false) 
915 915
         {
916 916
             $errorCode = json_last_error();
917 917
             
@@ -937,14 +937,14 @@  discard block
 block discarded – undo
937 937
     * @see FileHelper::ERROR_SAVE_FILE_NOT_WRITABLE
938 938
     * @see FileHelper::ERROR_SAVE_FILE_WRITE_FAILED
939 939
     */
940
-    public static function saveFile(string $filePath, string $content='') : void
940
+    public static function saveFile(string $filePath, string $content = '') : void
941 941
     {
942 942
         $filePath = self::normalizePath($filePath);
943 943
         
944 944
         // target file already exists
945
-        if(file_exists($filePath))
945
+        if (file_exists($filePath))
946 946
         {
947
-            if(!is_writable($filePath))
947
+            if (!is_writable($filePath))
948 948
             {
949 949
                 throw new FileHelper_Exception(
950 950
                     sprintf('Cannot save file: target file [%s] exists, but is not writable.', basename($filePath)),
@@ -964,7 +964,7 @@  discard block
 block discarded – undo
964 964
             // create the folder as needed
965 965
             self::createFolder($targetFolder);
966 966
             
967
-            if(!is_writable($targetFolder)) 
967
+            if (!is_writable($targetFolder)) 
968 968
             {
969 969
                 throw new FileHelper_Exception(
970 970
                     sprintf('Cannot save file: target folder [%s] is not writable.', basename($targetFolder)),
@@ -977,7 +977,7 @@  discard block
 block discarded – undo
977 977
             }
978 978
         }
979 979
         
980
-        if(is_dir($filePath))
980
+        if (is_dir($filePath))
981 981
         {
982 982
             throw new FileHelper_Exception(
983 983
                 sprintf('Cannot save file: the target [%s] is a directory.', basename($filePath)),
@@ -989,7 +989,7 @@  discard block
 block discarded – undo
989 989
             );
990 990
         }
991 991
         
992
-        if(file_put_contents($filePath, $content) !== false) {
992
+        if (file_put_contents($filePath, $content) !== false) {
993 993
             return;
994 994
         }
995 995
         
@@ -1027,7 +1027,7 @@  discard block
 block discarded – undo
1027 1027
     {
1028 1028
         static $checked = array();
1029 1029
         
1030
-        if(isset($checked[$command])) {
1030
+        if (isset($checked[$command])) {
1031 1031
             return $checked[$command];
1032 1032
         }
1033 1033
         
@@ -1040,7 +1040,7 @@  discard block
 block discarded – undo
1040 1040
         
1041 1041
         $os = strtolower(PHP_OS_FAMILY);
1042 1042
         
1043
-        if(!isset($osCommands[$os])) 
1043
+        if (!isset($osCommands[$os])) 
1044 1044
         {
1045 1045
             throw new FileHelper_Exception(
1046 1046
                 'Unsupported OS for CLI commands',
@@ -1066,7 +1066,7 @@  discard block
 block discarded – undo
1066 1066
             $pipes
1067 1067
         );
1068 1068
         
1069
-        if($process === false) {
1069
+        if ($process === false) {
1070 1070
             $checked[$command] = false;
1071 1071
             return false;
1072 1072
         }
@@ -1097,7 +1097,7 @@  discard block
 block discarded – undo
1097 1097
     */
1098 1098
     public static function checkPHPFileSyntax($path)
1099 1099
     {
1100
-        if(!self::canMakePHPCalls()) {
1100
+        if (!self::canMakePHPCalls()) {
1101 1101
             return true;
1102 1102
         }
1103 1103
         
@@ -1108,7 +1108,7 @@  discard block
 block discarded – undo
1108 1108
         // when the validation is successful, the first entry
1109 1109
         // in the array contains the success message. When it
1110 1110
         // is invalid, the first entry is always empty.
1111
-        if(!empty($output[0])) {
1111
+        if (!empty($output[0])) {
1112 1112
             return true;
1113 1113
         }
1114 1114
         
@@ -1129,7 +1129,7 @@  discard block
 block discarded – undo
1129 1129
     public static function getModifiedDate($path)
1130 1130
     {
1131 1131
         $time = filemtime($path);
1132
-        if($time !== false) {
1132
+        if ($time !== false) {
1133 1133
             $date = new \DateTime();
1134 1134
             $date->setTimestamp($time);
1135 1135
             return $date;
@@ -1158,7 +1158,7 @@  discard block
 block discarded – undo
1158 1158
     */
1159 1159
     public static function getSubfolders($targetFolder, $options = array())
1160 1160
     {
1161
-        if(!is_dir($targetFolder)) 
1161
+        if (!is_dir($targetFolder)) 
1162 1162
         {
1163 1163
             throw new FileHelper_Exception(
1164 1164
                 'Target folder does not exist',
@@ -1182,29 +1182,29 @@  discard block
 block discarded – undo
1182 1182
         
1183 1183
         $d = new \DirectoryIterator($targetFolder);
1184 1184
         
1185
-        foreach($d as $item) 
1185
+        foreach ($d as $item) 
1186 1186
         {
1187
-            if($item->isDir() && !$item->isDot()) 
1187
+            if ($item->isDir() && !$item->isDot()) 
1188 1188
             {
1189 1189
                 $name = $item->getFilename();
1190 1190
                 
1191
-                if(!$options['absolute-path']) {
1191
+                if (!$options['absolute-path']) {
1192 1192
                     $result[] = $name;
1193 1193
                 } else {
1194 1194
                     $result[] = $targetFolder.'/'.$name;
1195 1195
                 }
1196 1196
                 
1197
-                if(!$options['recursive']) 
1197
+                if (!$options['recursive']) 
1198 1198
                 {
1199 1199
                     continue;
1200 1200
                 }
1201 1201
                 
1202 1202
                 $subs = self::getSubfolders($targetFolder.'/'.$name, $options);
1203
-                foreach($subs as $sub) 
1203
+                foreach ($subs as $sub) 
1204 1204
                 {
1205 1205
                     $relative = $name.'/'.$sub;
1206 1206
                     
1207
-                    if(!$options['absolute-path']) {
1207
+                    if (!$options['absolute-path']) {
1208 1208
                         $result[] = $relative;
1209 1209
                     } else {
1210 1210
                         $result[] = $targetFolder.'/'.$relative;
@@ -1254,7 +1254,7 @@  discard block
 block discarded – undo
1254 1254
         $unit = preg_replace('/[^bkmgtpezy]/i', '', $size); // Remove the non-unit characters from the size.
1255 1255
         $size = floatval(preg_replace('/[^0-9\.]/', '', $size)); // Remove the non-numeric characters from the size.
1256 1256
         
1257
-        if($unit) 
1257
+        if ($unit) 
1258 1258
         {
1259 1259
             // Find the position of the unit in the ordered string which is the power of magnitude to multiply a kilobyte by.
1260 1260
             return round($size * pow(1024, stripos('bkmgtpezy', $unit[0])));
@@ -1273,7 +1273,7 @@  discard block
 block discarded – undo
1273 1273
     * @param int $depth The folder depth to reduce the path to
1274 1274
     * @return string
1275 1275
     */
1276
-    public static function relativizePathByDepth(string $path, int $depth=2) : string
1276
+    public static function relativizePathByDepth(string $path, int $depth = 2) : string
1277 1277
     {
1278 1278
         $path = self::normalizePath($path);
1279 1279
         
@@ -1281,17 +1281,17 @@  discard block
 block discarded – undo
1281 1281
         $tokens = array_filter($tokens); // remove empty entries (trailing slash for example)
1282 1282
         $tokens = array_values($tokens); // re-index keys
1283 1283
         
1284
-        if(empty($tokens)) {
1284
+        if (empty($tokens)) {
1285 1285
             return '';
1286 1286
         }
1287 1287
         
1288 1288
         // remove the drive if present
1289
-        if(strstr($tokens[0], ':')) {
1289
+        if (strstr($tokens[0], ':')) {
1290 1290
             array_shift($tokens);
1291 1291
         }
1292 1292
         
1293 1293
         // path was only the drive
1294
-        if(count($tokens) == 0) {
1294
+        if (count($tokens) == 0) {
1295 1295
             return '';
1296 1296
         }
1297 1297
 
@@ -1300,8 +1300,8 @@  discard block
 block discarded – undo
1300 1300
         
1301 1301
         // reduce the path to the specified depth
1302 1302
         $length = count($tokens);
1303
-        if($length > $depth) {
1304
-            $tokens = array_slice($tokens, $length-$depth);
1303
+        if ($length > $depth) {
1304
+            $tokens = array_slice($tokens, $length - $depth);
1305 1305
         }
1306 1306
 
1307 1307
         // append the last element again
@@ -1349,14 +1349,14 @@  discard block
 block discarded – undo
1349 1349
     * 
1350 1350
     * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST
1351 1351
     */
1352
-    public static function requireFileExists(string $path, $errorCode=null) : string
1352
+    public static function requireFileExists(string $path, $errorCode = null) : string
1353 1353
     {
1354 1354
         $result = realpath($path);
1355
-        if($result !== false) {
1355
+        if ($result !== false) {
1356 1356
             return $result;
1357 1357
         }
1358 1358
         
1359
-        if($errorCode === null) {
1359
+        if ($errorCode === null) {
1360 1360
             $errorCode = self::ERROR_FILE_DOES_NOT_EXIST;
1361 1361
         }
1362 1362
         
@@ -1385,15 +1385,15 @@  discard block
 block discarded – undo
1385 1385
         
1386 1386
         $file = new \SplFileObject($path);
1387 1387
         
1388
-        if($file->eof()) {
1388
+        if ($file->eof()) {
1389 1389
             return '';
1390 1390
         }
1391 1391
         
1392
-        $targetLine = $lineNumber-1;
1392
+        $targetLine = $lineNumber - 1;
1393 1393
         
1394 1394
         $file->seek($targetLine);
1395 1395
         
1396
-        if($file->key() !== $targetLine) {
1396
+        if ($file->key() !== $targetLine) {
1397 1397
              return null;
1398 1398
         }
1399 1399
         
@@ -1419,7 +1419,7 @@  discard block
 block discarded – undo
1419 1419
         $number = $spl->key();
1420 1420
         
1421 1421
         // if seeking to the end the cursor is still at 0, there are no lines. 
1422
-        if($number === 0) 
1422
+        if ($number === 0) 
1423 1423
         {
1424 1424
             // since it's a very small file, to get reliable results,
1425 1425
             // we read its contents and use that to determine what
@@ -1427,13 +1427,13 @@  discard block
 block discarded – undo
1427 1427
             // that this is not pactical to solve with the SplFileObject.
1428 1428
             $content = file_get_contents($path);
1429 1429
             
1430
-            if(empty($content)) {
1430
+            if (empty($content)) {
1431 1431
                 return 0;
1432 1432
             }
1433 1433
         }
1434 1434
         
1435 1435
         // return the line number we were able to reach + 1 (key is zero-based)
1436
-        return $number+1;
1436
+        return $number + 1;
1437 1437
     }
1438 1438
     
1439 1439
    /**
@@ -1480,13 +1480,13 @@  discard block
 block discarded – undo
1480 1480
     * @see FileHelper::ERROR_CANNOT_OPEN_FILE_TO_READ_LINES
1481 1481
     * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST
1482 1482
     */
1483
-    public static function readLines(string $filePath, int $amount=0) : array
1483
+    public static function readLines(string $filePath, int $amount = 0) : array
1484 1484
     {
1485 1485
         self::requireFileExists($filePath);
1486 1486
         
1487 1487
         $fn = fopen($filePath, "r");
1488 1488
         
1489
-        if($fn === false) 
1489
+        if ($fn === false) 
1490 1490
         {
1491 1491
             throw new FileHelper_Exception(
1492 1492
                 'Could not open file for reading.',
@@ -1502,19 +1502,19 @@  discard block
 block discarded – undo
1502 1502
         $counter = 0;
1503 1503
         $first = true;
1504 1504
         
1505
-        while(!feof($fn)) 
1505
+        while (!feof($fn)) 
1506 1506
         {
1507 1507
             $counter++;
1508 1508
             
1509 1509
             $line = fgets($fn);
1510 1510
             
1511 1511
             // can happen with zero length files
1512
-            if($line === false) {
1512
+            if ($line === false) {
1513 1513
                 continue;
1514 1514
             }
1515 1515
             
1516 1516
             // the first line may contain a unicode BOM marker.
1517
-            if($first) 
1517
+            if ($first) 
1518 1518
             {
1519 1519
                 $line = ConvertHelper::stripUTFBom($line);
1520 1520
                 $first = false;
@@ -1522,7 +1522,7 @@  discard block
 block discarded – undo
1522 1522
             
1523 1523
             $result[] = $line;
1524 1524
             
1525
-            if($amount > 0 && $counter == $amount) {
1525
+            if ($amount > 0 && $counter == $amount) {
1526 1526
                 break;
1527 1527
             }
1528 1528
         }
@@ -1548,7 +1548,7 @@  discard block
 block discarded – undo
1548 1548
         
1549 1549
         $result = file_get_contents($filePath);
1550 1550
         
1551
-        if($result !== false) {
1551
+        if ($result !== false) {
1552 1552
             return $result;
1553 1553
         }
1554 1554
         
@@ -1578,7 +1578,7 @@  discard block
 block discarded – undo
1578 1578
     {
1579 1579
         $actual = realpath($path);
1580 1580
         
1581
-        if($actual === false) 
1581
+        if ($actual === false) 
1582 1582
         {
1583 1583
             throw new FileHelper_Exception(
1584 1584
                 'Folder does not exist',
@@ -1590,7 +1590,7 @@  discard block
 block discarded – undo
1590 1590
             );
1591 1591
         }
1592 1592
         
1593
-        if(is_dir($path)) 
1593
+        if (is_dir($path)) 
1594 1594
         {
1595 1595
             return self::normalizePath($actual);
1596 1596
         }
Please login to merge, or discard this patch.
src/RequestHelper.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
 
242 242
         $output = curl_exec($ch);
243 243
 
244
-        if(isset($this->logfilePointer))
244
+        if (isset($this->logfilePointer))
245 245
         {
246 246
             fclose($this->logfilePointer);
247 247
         }
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
         // CURL will complain about an empty response when the 
254 254
         // server sends a 100-continue code. That should not be
255 255
         // regarded as an error.
256
-        if($output === false && $this->response->getCode() !== 100)
256
+        if ($output === false && $this->response->getCode() !== 100)
257 257
         {
258 258
             $curlCode = curl_errno($ch);
259 259
             
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
     {
290 290
         $ch = curl_init();
291 291
         
292
-        if(!is_resource($ch))
292
+        if (!is_resource($ch))
293 293
         {
294 294
             throw new RequestHelper_Exception(
295 295
                 'Could not initialize a new cURL instance.',
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
         }
300 300
 
301 301
         $this->setHeader('Content-Length', (string)$this->boundaries->getContentLength());
302
-        $this->setHeader('Content-Type', 'multipart/form-data; boundary=' . $this->mimeBoundary);
302
+        $this->setHeader('Content-Type', 'multipart/form-data; boundary='.$this->mimeBoundary);
303 303
 
304 304
         curl_setopt($ch, CURLOPT_POST, true);
305 305
         curl_setopt($ch, CURLOPT_URL, $url->getNormalizedWithoutAuth());
@@ -312,18 +312,18 @@  discard block
 block discarded – undo
312 312
         
313 313
         $loggingEnabled = $this->configureLogging($ch);
314 314
         
315
-        if(!$loggingEnabled) 
315
+        if (!$loggingEnabled) 
316 316
         {
317 317
             curl_setopt($ch, CURLINFO_HEADER_OUT, true);
318 318
         }
319 319
         
320
-        if($this->verifySSL)
320
+        if ($this->verifySSL)
321 321
         {
322 322
             curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
323 323
             curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
324 324
         }
325 325
         
326
-        if($url->hasUsername())
326
+        if ($url->hasUsername())
327 327
         {
328 328
             curl_setopt($ch, CURLOPT_USERNAME, $url->getUsername());
329 329
             curl_setopt($ch, CURLOPT_PASSWORD, $url->getPassword());
@@ -338,14 +338,14 @@  discard block
 block discarded – undo
338 338
     */
339 339
     protected function configureLogging($ch) : bool
340 340
     {
341
-        if(empty($this->logfile))
341
+        if (empty($this->logfile))
342 342
         {
343 343
             return false;
344 344
         }
345 345
         
346 346
         $res = fopen($this->logfile, 'w+');
347 347
         
348
-        if($res === false)
348
+        if ($res === false)
349 349
         {
350 350
             throw new RequestHelper_Exception(
351 351
                 'Cannot open logfile for writing.',
@@ -375,7 +375,7 @@  discard block
 block discarded – undo
375 375
         
376 376
         $this->setHeader('Expect', '');
377 377
         
378
-        foreach($this->headers as $name => $value) {
378
+        foreach ($this->headers as $name => $value) {
379 379
             $result[] = $name.': '.$value;
380 380
         }
381 381
         
@@ -392,7 +392,7 @@  discard block
 block discarded – undo
392 392
     {
393 393
         $response = $this->getResponse();
394 394
         
395
-        if($response !== null) {
395
+        if ($response !== null) {
396 396
             return $response->getHeaders();
397 397
         }
398 398
 
@@ -428,7 +428,7 @@  discard block
 block discarded – undo
428 428
     */
429 429
     public function getHeader(string $name) : string
430 430
     {
431
-        if(isset($this->headers[$name]))
431
+        if (isset($this->headers[$name]))
432 432
         {
433 433
             return $this->headers[$name];
434 434
         }
Please login to merge, or discard this patch.
src/StringBuilder.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
     {
69 69
         $string = strval($string);
70 70
         
71
-        if(!empty($string)) 
71
+        if (!empty($string)) 
72 72
         {
73 73
             $this->strings[] = $string;
74 74
         }
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
     {
148 148
         array_unshift($arguments, $format);
149 149
         
150
-        if(!class_exists('\AppLocalize\Localization'))
150
+        if (!class_exists('\AppLocalize\Localization'))
151 151
         {
152 152
             return $this->sf(...$arguments);
153 153
         }
@@ -288,10 +288,10 @@  discard block
 block discarded – undo
288 288
     * @param bool $newTab
289 289
     * @return $this
290 290
     */
291
-    public function link(string $label, string $url, bool $newTab=false) : StringBuilder
291
+    public function link(string $label, string $url, bool $newTab = false) : StringBuilder
292 292
     {
293 293
         $target = '';
294
-        if($newTab) {
294
+        if ($newTab) {
295 295
             $target = ' target="_blank"';
296 296
         }
297 297
        
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
     */
338 338
     protected function spanned($string, $classes) : StringBuilder
339 339
     {
340
-        if(!is_array($classes)) 
340
+        if (!is_array($classes)) 
341 341
         {
342 342
             $classes = array(strval($classes));
343 343
         }
Please login to merge, or discard this patch.
src/XMLHelper.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 
244 244
         if (!empty($text)) {
245 245
             $fragment = $this->dom->createDocumentFragment();
246
-            if(!@$fragment->appendXML($text)) {
246
+            if (!@$fragment->appendXML($text)) {
247 247
                 throw new XMLHelper_Exception(
248 248
                     'Cannot append XML fragment',
249 249
                     sprintf(
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
     * @param array<string,mixed> $attributes
286 286
     * @return DOMNode
287 287
     */
288
-    public function createRoot(string $name, array $attributes=array())
288
+    public function createRoot(string $name, array $attributes = array())
289 289
     {
290 290
         $root = $this->dom->appendChild($this->dom->createElement($name));
291 291
         $this->addAttributes($root, $attributes);
@@ -311,8 +311,8 @@  discard block
 block discarded – undo
311 311
         $string = str_replace('&lt;', 'LT_ESCAPE', $string);
312 312
         $string = str_replace('&gt;', 'GT_ESCAPE', $string);
313 313
 
314
-        $string = str_replace('&nbsp;',' ',  $string);
315
-        $string = str_replace('&','&amp;',  $string);
314
+        $string = str_replace('&nbsp;', ' ', $string);
315
+        $string = str_replace('&', '&amp;', $string);
316 316
 
317 317
         return $string;
318 318
     }
@@ -331,9 +331,9 @@  discard block
 block discarded – undo
331 331
     */
332 332
     public static function downloadXML(string $xml, string $filename = 'download.xml') : void
333 333
     {
334
-        if(!headers_sent() && !self::$simulation) 
334
+        if (!headers_sent() && !self::$simulation) 
335 335
         {
336
-            header('Content-Disposition: attachment; filename="' . $filename . '"');
336
+            header('Content-Disposition: attachment; filename="'.$filename.'"');
337 337
         }
338 338
         
339 339
         echo $xml;
@@ -347,12 +347,12 @@  discard block
 block discarded – undo
347 347
     */
348 348
     public static function displayXML(string $xml) : void
349 349
     {
350
-        if(!headers_sent() && !self::$simulation) 
350
+        if (!headers_sent() && !self::$simulation) 
351 351
         {
352 352
             header('Content-Type:text/xml; charset=utf-8');
353 353
         }
354 354
         
355
-        if(self::$simulation) 
355
+        if (self::$simulation) 
356 356
         {
357 357
             $xml = '<pre>'.htmlspecialchars($xml).'</pre>';
358 358
         }
@@ -370,16 +370,16 @@  discard block
 block discarded – undo
370 370
      * @param array<string,string> $customInfo Associative array with name => value pairs for custom tags to add to the output xml
371 371
      * @see buildErrorXML()
372 372
      */
373
-    public static function displayErrorXML($code, string $message, string $title, array $customInfo=array())
373
+    public static function displayErrorXML($code, string $message, string $title, array $customInfo = array())
374 374
     {
375
-        if(!headers_sent() && !self::$simulation) {
376
-            header('HTTP/1.1 400 Bad Request: ' . $title, true, 400);
375
+        if (!headers_sent() && !self::$simulation) {
376
+            header('HTTP/1.1 400 Bad Request: '.$title, true, 400);
377 377
         }
378 378
 
379 379
         self::displayXML(self::buildErrorXML($code, $message, $title, $customInfo));
380 380
     }
381 381
     
382
-    public static function setSimulation(bool $simulate=true) : void
382
+    public static function setSimulation(bool $simulate = true) : void
383 383
     {
384 384
         self::$simulation = $simulate;
385 385
     }
@@ -428,7 +428,7 @@  discard block
 block discarded – undo
428 428
     * @param array<string,string> $customInfo
429 429
     * @return string
430 430
     */
431
-    public static function buildErrorXML($code, string $message, string $title, array $customInfo=array())
431
+    public static function buildErrorXML($code, string $message, string $title, array $customInfo = array())
432 432
     {
433 433
         $xml = new DOMDocument('1.0', 'UTF-8');
434 434
         $xml->formatOutput = true;
@@ -442,7 +442,7 @@  discard block
 block discarded – undo
442 442
         $helper->addTextTag($root, 'title', $title);
443 443
         $helper->addTextTag($root, 'request_uri', $_SERVER['REQUEST_URI']);
444 444
         
445
-        foreach($customInfo as $name => $value) {
445
+        foreach ($customInfo as $name => $value) {
446 446
             $helper->addTextTag($root, $name, $value);
447 447
         }
448 448
 
Please login to merge, or discard this patch.
src/Highlighter.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
     */
109 109
     public static function json($subject) : string
110 110
     {
111
-        if(!is_string($subject))
111
+        if (!is_string($subject))
112 112
         {
113 113
             $subject = json_encode($subject, JSON_PRETTY_PRINT);
114 114
         }
@@ -125,9 +125,9 @@  discard block
 block discarded – undo
125 125
     * @param bool $formatSource Whether to format the source with indentation to make it readable.
126 126
     * @return string
127 127
     */
128
-    public static function xml(string $xml, bool $formatSource=false) : string
128
+    public static function xml(string $xml, bool $formatSource = false) : string
129 129
     {
130
-        if($formatSource)
130
+        if ($formatSource)
131 131
         {
132 132
             $dom = new DOMDocument();
133 133
             $dom->preserveWhiteSpace = false;
@@ -148,9 +148,9 @@  discard block
 block discarded – undo
148 148
     * @param bool $formatSource
149 149
     * @return string
150 150
     */
151
-    public static function html(string $html, bool $formatSource=false) : string
151
+    public static function html(string $html, bool $formatSource = false) : string
152 152
     {
153
-        if($formatSource)
153
+        if ($formatSource)
154 154
         {
155 155
             $dom = new DOMDocument();
156 156
             $dom->preserveWhiteSpace = false;
Please login to merge, or discard this patch.
src/ConvertHelper.php 1 patch
Spacing   +81 added lines, -81 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
      * @param int $tabSize The amount of spaces per tab.
51 51
      * @return string
52 52
      */
53
-    public static function tabs2spaces(string $string, int $tabSize=4) : string
53
+    public static function tabs2spaces(string $string, int $tabSize = 4) : string
54 54
     {
55 55
         return str_replace("\t", str_repeat(' ', $tabSize), $string);
56 56
     }
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
     * @param int $tabSize The amount of spaces per tab in the source string.
63 63
     * @return string
64 64
     */
65
-    public static function spaces2tabs(string $string, int $tabSize=4) : string
65
+    public static function spaces2tabs(string $string, int $tabSize = 4) : string
66 66
     {
67 67
         return str_replace(str_repeat(' ', $tabSize), "\t", $string);
68 68
     }
@@ -122,10 +122,10 @@  discard block
 block discarded – undo
122 122
 
123 123
         // specifically handle zero
124 124
         if ($seconds <= 0) {
125
-            return '0 ' . t('seconds');
125
+            return '0 '.t('seconds');
126 126
         }
127 127
         
128
-        if($seconds < 1) {
128
+        if ($seconds < 1) {
129 129
             return t('less than a second');
130 130
         }
131 131
 
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
         foreach ($units as $def) {
134 134
             $quot = intval($seconds / $def['value']);
135 135
             if ($quot) {
136
-                $item = $quot . ' ';
136
+                $item = $quot.' ';
137 137
                 if (abs($quot) > 1) {
138 138
                     $item .= $def['plural'];
139 139
                 } else {
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
             return $last;
151 151
         }
152 152
 
153
-        return implode(', ', $tokens) . ' ' . t('and') . ' ' . $last;
153
+        return implode(', ', $tokens).' '.t('and').' '.$last;
154 154
     }
155 155
 
156 156
    /**
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
     {
170 170
          $converter = new ConvertHelper_DurationConverter();
171 171
          
172
-         if($datefrom instanceof \DateTime)
172
+         if ($datefrom instanceof \DateTime)
173 173
          {
174 174
              $converter->setDateFrom($datefrom);
175 175
          }
@@ -178,11 +178,11 @@  discard block
 block discarded – undo
178 178
              $converter->setDateFrom(self::timestamp2date($datefrom)); 
179 179
          }
180 180
 
181
-         if($dateto instanceof \DateTime)
181
+         if ($dateto instanceof \DateTime)
182 182
          {
183 183
              $converter->setDateTo($dateto);
184 184
          }
185
-         else if($dateto > 0)
185
+         else if ($dateto > 0)
186 186
          {
187 187
              $converter->setDateTo(self::timestamp2date($dateto));
188 188
          }
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
     * @deprecated Use the Highlighter class directly instead.
213 213
     * @see Highlighter::xml()
214 214
     */
215
-    public static function highlight_xml(string $xml, bool $formatSource=false) : string
215
+    public static function highlight_xml(string $xml, bool $formatSource = false) : string
216 216
     {
217 217
         return Highlighter::xml($xml, $formatSource);
218 218
     }
@@ -273,16 +273,16 @@  discard block
 block discarded – undo
273 273
             return $text;
274 274
         }
275 275
 
276
-        $text = trim(mb_substr($text, 0, $targetLength)) . $append;
276
+        $text = trim(mb_substr($text, 0, $targetLength)).$append;
277 277
 
278 278
         return $text;
279 279
     }
280 280
 
281
-    public static function var_dump($var, $html=true) : string
281
+    public static function var_dump($var, $html = true) : string
282 282
     {
283 283
         $info = parseVariable($var);
284 284
         
285
-        if($html) {
285
+        if ($html) {
286 286
             return $info->toHTML();
287 287
         }
288 288
         
@@ -297,11 +297,11 @@  discard block
 block discarded – undo
297 297
     * @param bool $html Whether to style the dump as HTML.
298 298
     * @return string
299 299
     */
300
-    public static function print_r($var, bool $return=false, bool $html=true) : string
300
+    public static function print_r($var, bool $return = false, bool $html = true) : string
301 301
     {
302 302
         $result = parseVariable($var)->enableType()->toString();
303 303
         
304
-        if($html) 
304
+        if ($html) 
305 305
         {
306 306
             $result = 
307 307
             '<pre style="background:#fff;color:#333;padding:16px;border:solid 1px #bbb;border-radius:4px">'.
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
             '</pre>';
310 310
         }
311 311
         
312
-        if(!$return) 
312
+        if (!$return) 
313 313
         {
314 314
             echo $result;
315 315
         }
@@ -337,17 +337,17 @@  discard block
 block discarded – undo
337 337
     */
338 338
     public static function string2bool($string) : bool
339 339
     {
340
-        if($string === '' || $string === null || !is_scalar($string)) 
340
+        if ($string === '' || $string === null || !is_scalar($string)) 
341 341
         {
342 342
             return false;
343 343
         }
344 344
         
345
-        if(is_bool($string)) 
345
+        if (is_bool($string)) 
346 346
         {
347 347
             return $string;
348 348
         }
349 349
 
350
-        if(array_key_exists($string, self::$booleanStrings)) 
350
+        if (array_key_exists($string, self::$booleanStrings)) 
351 351
         {
352 352
             return self::$booleanStrings[$string];
353 353
         }
@@ -402,10 +402,10 @@  discard block
 block discarded – undo
402 402
     public static function date2listLabel(\DateTime $date, $includeTime = false, $shortMonth = false)
403 403
     {
404 404
         $today = new \DateTime();
405
-        if($date->format('d.m.Y') == $today->format('d.m.Y')) {
405
+        if ($date->format('d.m.Y') == $today->format('d.m.Y')) {
406 406
             $label = t('Today');
407 407
         } else {
408
-            $label = $date->format('d') . '. ' . self::month2string((int)$date->format('m'), $shortMonth) . ' ';
408
+            $label = $date->format('d').'. '.self::month2string((int)$date->format('m'), $shortMonth).' ';
409 409
             if ($date->format('Y') != date('Y')) {
410 410
                 $label .= $date->format('Y');
411 411
             }
@@ -565,12 +565,12 @@  discard block
 block discarded – undo
565 565
         $output = '';
566 566
         $split = str_split($unicodeChar);
567 567
         
568
-        foreach($split as $octet) 
568
+        foreach ($split as $octet) 
569 569
         {
570 570
             $ordInt = ord($octet);
571 571
             // Convert from int (base 10) to hex (base 16), for PHP \x syntax
572 572
             $ordHex = base_convert((string)$ordInt, 10, 16);
573
-            $output .= '\x' . $ordHex;
573
+            $output .= '\x'.$ordHex;
574 574
         }
575 575
         
576 576
         return $output;
@@ -603,19 +603,19 @@  discard block
 block discarded – undo
603 603
     
604 604
     protected static function convertScalarForComparison($scalar)
605 605
     {
606
-        if($scalar === '' || is_null($scalar)) {
606
+        if ($scalar === '' || is_null($scalar)) {
607 607
             return null;
608 608
         }
609 609
         
610
-        if(is_bool($scalar)) {
610
+        if (is_bool($scalar)) {
611 611
             return self::bool2string($scalar);
612 612
         }
613 613
         
614
-        if(is_array($scalar)) {
614
+        if (is_array($scalar)) {
615 615
             $scalar = md5(serialize($scalar));
616 616
         }
617 617
         
618
-        if($scalar !== null && !is_scalar($scalar)) {
618
+        if ($scalar !== null && !is_scalar($scalar)) {
619 619
             throw new ConvertHelper_Exception(
620 620
                 'Not a scalar value in comparison',
621 621
                 null,
@@ -664,7 +664,7 @@  discard block
 block discarded – undo
664 664
     public static function bool2string($boolean, bool $yesno = false) : string
665 665
     {
666 666
         // allow 'yes', 'true', 'no', 'false' string notations as well
667
-        if(!is_bool($boolean)) {
667
+        if (!is_bool($boolean)) {
668 668
             $boolean = self::string2bool($boolean);
669 669
         }
670 670
         
@@ -705,15 +705,15 @@  discard block
 block discarded – undo
705 705
     public static function array2attributeString($array)
706 706
     {
707 707
         $tokens = array();
708
-        foreach($array as $attr => $value) {
709
-            if($value == '' || $value == null) {
708
+        foreach ($array as $attr => $value) {
709
+            if ($value == '' || $value == null) {
710 710
                 continue;
711 711
             }
712 712
             
713 713
             $tokens[] = $attr.'="'.$value.'"';
714 714
         }
715 715
         
716
-        if(empty($tokens)) {
716
+        if (empty($tokens)) {
717 717
             return '';
718 718
         }
719 719
         
@@ -728,10 +728,10 @@  discard block
 block discarded – undo
728 728
     * @param string $string
729 729
     * @return string
730 730
     */
731
-    public static function string2attributeJS($string, $quoted=true)
731
+    public static function string2attributeJS($string, $quoted = true)
732 732
     {
733 733
         $converted = addslashes(htmlspecialchars(strip_tags($string), ENT_QUOTES, 'UTF-8'));
734
-        if($quoted) {
734
+        if ($quoted) {
735 735
             $converted = "'".$converted."'";
736 736
         } 
737 737
         
@@ -749,11 +749,11 @@  discard block
 block discarded – undo
749 749
     */
750 750
     public static function isBoolean($value) : bool
751 751
     {
752
-        if(is_bool($value)) {
752
+        if (is_bool($value)) {
753 753
             return true;
754 754
         }
755 755
         
756
-        if(!is_scalar($value)) {
756
+        if (!is_scalar($value)) {
757 757
             return false;
758 758
         }
759 759
         
@@ -769,7 +769,7 @@  discard block
 block discarded – undo
769 769
     public static function array2styleString(array $subject) : string
770 770
     {
771 771
         $tokens = array();
772
-        foreach($subject as $name => $value) {
772
+        foreach ($subject as $name => $value) {
773 773
             $tokens[] = $name.':'.$value;
774 774
         }
775 775
         
@@ -827,7 +827,7 @@  discard block
 block discarded – undo
827 827
     * 
828 828
     * @see JSHelper::buildRegexStatement()
829 829
     */
830
-    public static function regex2js(string $regex, string $statementType=JSHelper::JS_REGEX_OBJECT)
830
+    public static function regex2js(string $regex, string $statementType = JSHelper::JS_REGEX_OBJECT)
831 831
     {
832 832
         return JSHelper::buildRegexStatement($regex, $statementType);
833 833
     }
@@ -844,11 +844,11 @@  discard block
 block discarded – undo
844 844
     * @throws ConvertHelper_Exception
845 845
     * @return string
846 846
     */
847
-    public static function var2json($variable, int $options=0, int $depth=512) : string
847
+    public static function var2json($variable, int $options = 0, int $depth = 512) : string
848 848
     {
849 849
         $result = json_encode($variable, $options, $depth);
850 850
         
851
-        if($result !== false) {
851
+        if ($result !== false) {
852 852
             return $result;
853 853
         }
854 854
         
@@ -873,10 +873,10 @@  discard block
 block discarded – undo
873 873
     public static function stripUTFBom($string)
874 874
     {
875 875
         $boms = FileHelper::getUTFBOMs();
876
-        foreach($boms as $bomChars) {
876
+        foreach ($boms as $bomChars) {
877 877
             $length = mb_strlen($bomChars);
878 878
             $text = mb_substr($string, 0, $length);
879
-            if($text==$bomChars) {
879
+            if ($text == $bomChars) {
880 880
                 return mb_substr($string, $length);
881 881
             }
882 882
         }
@@ -893,7 +893,7 @@  discard block
 block discarded – undo
893 893
     */
894 894
     public static function string2utf8($string)
895 895
     {
896
-        if(!self::isStringASCII($string)) {
896
+        if (!self::isStringASCII($string)) {
897 897
             return \ForceUTF8\Encoding::toUTF8($string);
898 898
         }
899 899
         
@@ -911,11 +911,11 @@  discard block
 block discarded – undo
911 911
     */
912 912
     public static function isStringASCII($string) : bool
913 913
     {
914
-        if($string === '' || $string === NULL) {
914
+        if ($string === '' || $string === NULL) {
915 915
             return true;
916 916
         }
917 917
         
918
-        if(!is_string($string)) {
918
+        if (!is_string($string)) {
919 919
             return false;
920 920
         }
921 921
         
@@ -955,7 +955,7 @@  discard block
 block discarded – undo
955 955
     * @param array $options
956 956
     * @return float
957 957
     */
958
-    public static function matchString($source, $target, $options=array())
958
+    public static function matchString($source, $target, $options = array())
959 959
     {
960 960
         $defaults = array(
961 961
             'maxLevenshtein' => 10,
@@ -965,12 +965,12 @@  discard block
 block discarded – undo
965 965
         $options = array_merge($defaults, $options);
966 966
         
967 967
         // avoid doing this via levenshtein
968
-        if($source == $target) {
968
+        if ($source == $target) {
969 969
             return 100;
970 970
         }
971 971
         
972 972
         $diff = levenshtein($source, $target);
973
-        if($diff > $options['maxLevenshtein']) {
973
+        if ($diff > $options['maxLevenshtein']) {
974 974
             return 0;
975 975
         }
976 976
         
@@ -1054,24 +1054,24 @@  discard block
 block discarded – undo
1054 1054
     * @see ConvertHelper::INTERVAL_HOURS
1055 1055
     * @see ConvertHelper::INTERVAL_DAYS
1056 1056
     */
1057
-    public static function interval2total(\DateInterval $interval, $unit=self::INTERVAL_SECONDS) : int
1057
+    public static function interval2total(\DateInterval $interval, $unit = self::INTERVAL_SECONDS) : int
1058 1058
     {
1059 1059
         $total = (int)$interval->format('%a');
1060 1060
         if ($unit == self::INTERVAL_DAYS) {
1061 1061
             return $total;
1062 1062
         }
1063 1063
         
1064
-        $total = ($total * 24) + ((int)$interval->h );
1064
+        $total = ($total * 24) + ((int)$interval->h);
1065 1065
         if ($unit == self::INTERVAL_HOURS) {
1066 1066
             return $total;
1067 1067
         }
1068 1068
     
1069
-        $total = ($total * 60) + ((int)$interval->i );
1069
+        $total = ($total * 60) + ((int)$interval->i);
1070 1070
         if ($unit == self::INTERVAL_MINUTES) {
1071 1071
             return $total;
1072 1072
         }
1073 1073
 
1074
-        $total = ($total * 60) + ((int)$interval->s );
1074
+        $total = ($total * 60) + ((int)$interval->s);
1075 1075
         if ($unit == self::INTERVAL_SECONDS) {
1076 1076
             return $total;
1077 1077
         }
@@ -1100,13 +1100,13 @@  discard block
 block discarded – undo
1100 1100
     * @param bool $short
1101 1101
     * @return string|NULL
1102 1102
     */
1103
-    public static function date2dayName(\DateTime $date, bool $short=false)
1103
+    public static function date2dayName(\DateTime $date, bool $short = false)
1104 1104
     {
1105 1105
         $day = $date->format('l');
1106 1106
         $invariant = self::getDayNamesInvariant();
1107 1107
         
1108 1108
         $idx = array_search($day, $invariant);
1109
-        if($idx !== false) {
1109
+        if ($idx !== false) {
1110 1110
             $localized = self::getDayNames($short);
1111 1111
             return $localized[$idx];
1112 1112
         }
@@ -1129,10 +1129,10 @@  discard block
 block discarded – undo
1129 1129
     * @param bool $short
1130 1130
     * @return array
1131 1131
     */
1132
-    public static function getDayNames(bool $short=false) : array
1132
+    public static function getDayNames(bool $short = false) : array
1133 1133
     {
1134
-        if($short) {
1135
-            if(!isset(self::$daysShort)) {
1134
+        if ($short) {
1135
+            if (!isset(self::$daysShort)) {
1136 1136
                 self::$daysShort = array(
1137 1137
                     t('Mon'),
1138 1138
                     t('Tue'),
@@ -1147,7 +1147,7 @@  discard block
 block discarded – undo
1147 1147
             return self::$daysShort;
1148 1148
         }
1149 1149
         
1150
-        if(!isset(self::$days)) {
1150
+        if (!isset(self::$days)) {
1151 1151
             self::$days = array(
1152 1152
                 t('Monday'),
1153 1153
                 t('Tuesday'),
@@ -1172,17 +1172,17 @@  discard block
 block discarded – undo
1172 1172
      */
1173 1173
     public static function implodeWithAnd(array $list, $sep = ', ', $conjunction = null)
1174 1174
     {
1175
-        if(empty($list)) {
1175
+        if (empty($list)) {
1176 1176
             return '';
1177 1177
         }
1178 1178
         
1179
-        if(empty($conjunction)) {
1179
+        if (empty($conjunction)) {
1180 1180
             $conjunction = t('and');
1181 1181
         }
1182 1182
         
1183 1183
         $last = array_pop($list);
1184
-        if($list) {
1185
-            return implode($sep, $list) . $conjunction . ' ' . $last;
1184
+        if ($list) {
1185
+            return implode($sep, $list).$conjunction.' '.$last;
1186 1186
         }
1187 1187
         
1188 1188
         return $last;
@@ -1201,7 +1201,7 @@  discard block
 block discarded – undo
1201 1201
     public static function string2array(string $string) : array
1202 1202
     {
1203 1203
         $result = preg_split('//u', $string, null, PREG_SPLIT_NO_EMPTY);
1204
-        if($result !== false) {
1204
+        if ($result !== false) {
1205 1205
             return $result;
1206 1206
         }
1207 1207
         
@@ -1216,12 +1216,12 @@  discard block
 block discarded – undo
1216 1216
     */
1217 1217
     public static function isStringHTML(string $string) : bool
1218 1218
     {
1219
-        if(preg_match('%<[a-z/][\s\S]*>%siU', $string)) {
1219
+        if (preg_match('%<[a-z/][\s\S]*>%siU', $string)) {
1220 1220
             return true;
1221 1221
         }
1222 1222
         
1223 1223
         $decoded = html_entity_decode($string);
1224
-        if($decoded !== $string) {
1224
+        if ($decoded !== $string) {
1225 1225
             return true;
1226 1226
         }
1227 1227
         
@@ -1330,14 +1330,14 @@  discard block
 block discarded – undo
1330 1330
     * @param bool $caseInsensitive
1331 1331
     * @return ConvertHelper_StringMatch[]
1332 1332
     */
1333
-    public static function findString(string $needle, string $haystack, bool $caseInsensitive=false)
1333
+    public static function findString(string $needle, string $haystack, bool $caseInsensitive = false)
1334 1334
     {
1335
-        if($needle === '') {
1335
+        if ($needle === '') {
1336 1336
             return array();
1337 1337
         }
1338 1338
         
1339 1339
         $function = 'mb_strpos';
1340
-        if($caseInsensitive) {
1340
+        if ($caseInsensitive) {
1341 1341
             $function = 'mb_stripos';
1342 1342
         }
1343 1343
         
@@ -1345,7 +1345,7 @@  discard block
 block discarded – undo
1345 1345
         $positions = array();
1346 1346
         $length = mb_strlen($needle);
1347 1347
         
1348
-        while( ($pos = $function($haystack, $needle, $pos)) !== false) 
1348
+        while (($pos = $function($haystack, $needle, $pos)) !== false) 
1349 1349
         {
1350 1350
             $match = mb_substr($haystack, $pos, $length);
1351 1351
             $positions[] = new ConvertHelper_StringMatch($pos, $match);
@@ -1365,7 +1365,7 @@  discard block
 block discarded – undo
1365 1365
     */
1366 1366
     public static function explodeTrim(string $delimiter, string $string) : array
1367 1367
     {
1368
-        if(empty($string) || empty($delimiter)) {
1368
+        if (empty($string) || empty($delimiter)) {
1369 1369
             return array();
1370 1370
         }
1371 1371
         
@@ -1373,8 +1373,8 @@  discard block
 block discarded – undo
1373 1373
         $tokens = array_map('trim', $tokens);
1374 1374
         
1375 1375
         $keep = array();
1376
-        foreach($tokens as $token) {
1377
-            if($token !== '') {
1376
+        foreach ($tokens as $token) {
1377
+            if ($token !== '') {
1378 1378
                 $keep[] = $token;
1379 1379
             }
1380 1380
         }
@@ -1392,11 +1392,11 @@  discard block
 block discarded – undo
1392 1392
     */
1393 1393
     public static function detectEOLCharacter(string $subjectString) : ?ConvertHelper_EOL
1394 1394
     {
1395
-        if(empty($subjectString)) {
1395
+        if (empty($subjectString)) {
1396 1396
             return null;
1397 1397
         }
1398 1398
         
1399
-        if(!isset(self::$eolChars))
1399
+        if (!isset(self::$eolChars))
1400 1400
         {
1401 1401
             $cr = chr((int)hexdec('0d'));
1402 1402
             $lf = chr((int)hexdec('0a'));
@@ -1427,18 +1427,18 @@  discard block
 block discarded – undo
1427 1427
         
1428 1428
         $max = 0;
1429 1429
         $results = array();
1430
-        foreach(self::$eolChars as $def) 
1430
+        foreach (self::$eolChars as $def) 
1431 1431
         {
1432 1432
             $amount = substr_count($subjectString, $def['char']);
1433 1433
             
1434
-            if($amount > $max)
1434
+            if ($amount > $max)
1435 1435
             {
1436 1436
                 $max = $amount;
1437 1437
                 $results[] = $def;
1438 1438
             }
1439 1439
         }
1440 1440
         
1441
-        if(empty($results)) {
1441
+        if (empty($results)) {
1442 1442
             return null;
1443 1443
         }
1444 1444
         
@@ -1458,9 +1458,9 @@  discard block
 block discarded – undo
1458 1458
     */
1459 1459
     public static function arrayRemoveKeys(array &$array, array $keys) : void
1460 1460
     {
1461
-        foreach($keys as $key) 
1461
+        foreach ($keys as $key) 
1462 1462
         {
1463
-            if(array_key_exists($key, $array)) {
1463
+            if (array_key_exists($key, $array)) {
1464 1464
                 unset($array[$key]); 
1465 1465
             }
1466 1466
         }
@@ -1475,17 +1475,17 @@  discard block
 block discarded – undo
1475 1475
     */
1476 1476
     public static function isInteger($value) : bool
1477 1477
     {
1478
-        if(is_int($value)) {
1478
+        if (is_int($value)) {
1479 1479
             return true;
1480 1480
         }
1481 1481
         
1482 1482
         // booleans get converted to numbers, so they would
1483 1483
         // actually match the regex.
1484
-        if(is_bool($value)) {
1484
+        if (is_bool($value)) {
1485 1485
             return false;
1486 1486
         }
1487 1487
         
1488
-        if(is_string($value) && $value !== '') {
1488
+        if (is_string($value) && $value !== '') {
1489 1489
             return preg_match('/\A-?\d+\z/', $value) === 1;
1490 1490
         }
1491 1491
         
Please login to merge, or discard this patch.