Passed
Push — master ( 1dce7e...428f46 )
by Sebastian
03:05
created
src/FileHelper/MimeTypes.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -221,7 +221,7 @@
 block discarded – undo
221 221
      */
222 222
     public static function getMime($extension)
223 223
     {
224
-        if(isset(self::$mimeTypes[$extension])) {
224
+        if (isset(self::$mimeTypes[$extension])) {
225 225
             return self::$mimeTypes[$extension];
226 226
         }
227 227
 
Please login to merge, or discard this patch.
src/FileHelper/PHPClassInfo/Class.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
     {
106 106
         $name = $this->getName();
107 107
         
108
-        if($this->info->hasNamespace()) {
108
+        if ($this->info->hasNamespace()) {
109 109
             $name = $this->info->getNamespace().'\\'.$this->name;
110 110
         }
111 111
         
@@ -160,12 +160,12 @@  discard block
 block discarded – undo
160 160
         $parts[] = 'class';
161 161
         $parts[] = $this->getName();
162 162
         
163
-        if(!empty($this->extends)) {
163
+        if (!empty($this->extends)) {
164 164
             $parts[] = 'extends';
165 165
             $parts[] = $this->extends;
166 166
         }
167 167
         
168
-        if(!empty($this->implements)) {
168
+        if (!empty($this->implements)) {
169 169
             $parts[] = 'implements';
170 170
             $parts[] = implode(', ', $this->implements);
171 171
         }
@@ -184,9 +184,9 @@  discard block
 block discarded – undo
184 184
     
185 185
     protected function analyzeCode()
186 186
     {
187
-        if($this->keyword == 'abstract') {
187
+        if ($this->keyword == 'abstract') {
188 188
             $this->abstract = true;
189
-        } else if($this->keyword == 'final') {
189
+        } else if ($this->keyword == 'final') {
190 190
             $this->final = true;
191 191
         }
192 192
         
@@ -203,16 +203,16 @@  discard block
 block discarded – undo
203 203
         
204 204
         $tokenName = 'none';
205 205
         
206
-        foreach($parts as $part)
206
+        foreach ($parts as $part)
207 207
         {
208 208
             $part = str_replace(',', '', $part);
209 209
             $part = trim($part);
210
-            if(empty($part)) {
210
+            if (empty($part)) {
211 211
                 continue;
212 212
             }
213 213
             
214 214
             $name = strtolower($part);
215
-            if($name == 'extends' || $name == 'implements') {
215
+            if ($name == 'extends' || $name == 'implements') {
216 216
                 $tokenName = $name;
217 217
                 continue;
218 218
             }
@@ -222,13 +222,13 @@  discard block
 block discarded – undo
222 222
         
223 223
         $this->implements = $tokens['implements'];
224 224
         
225
-        if(!empty($this->implements)) {
225
+        if (!empty($this->implements)) {
226 226
             usort($this->implements, function(string $a, string $b) {
227 227
                 return strnatcasecmp($a, $b);
228 228
             });
229 229
         }
230 230
         
231
-        if(!empty($tokens['extends'])) {
231
+        if (!empty($tokens['extends'])) {
232 232
             $this->extends = $tokens['extends'][0];
233 233
         }
234 234
     }
Please login to merge, or discard this patch.
src/ImageHelper/Size.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -18,23 +18,23 @@  discard block
 block discarded – undo
18 18
     
19 19
     public function __construct(array $size)
20 20
     {
21
-        if(!isset($size['width'])) {
21
+        if (!isset($size['width'])) {
22 22
             $size['width'] = $size[0];
23 23
         }
24 24
         
25
-        if(!isset($size['height'])) {
25
+        if (!isset($size['height'])) {
26 26
             $size['height'] = $size[1];
27 27
         }
28 28
         
29
-        if(!isset($size[0])) {
29
+        if (!isset($size[0])) {
30 30
             $size[0] = $size['width'];
31 31
         }
32 32
         
33
-        if(!isset($size[1])) {
33
+        if (!isset($size[1])) {
34 34
             $size[1] = $size['height'];
35 35
         }
36 36
         
37
-        if(!isset($size['channels'])) {
37
+        if (!isset($size['channels'])) {
38 38
             $size['channels'] = 1;
39 39
         }
40 40
         
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
     
69 69
     public function offsetGet($offset)
70 70
     {
71
-        if(isset($this->size[$offset])) {
71
+        if (isset($this->size[$offset])) {
72 72
             return $this->size[$offset];
73 73
         }
74 74
         
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
     
78 78
     public function offsetSet($offset, $value)
79 79
     {
80
-        if(is_null($offset)) {
80
+        if (is_null($offset)) {
81 81
             $this->size[] = $value;
82 82
         } else {
83 83
             $this->size[$offset] = $value;
Please login to merge, or discard this patch.
src/FileHelper.php 1 patch
Spacing   +107 added lines, -107 removed lines patch added patch discarded remove patch
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
         
91 91
         $contents = file_get_contents($file);
92 92
         
93
-        if($contents === false) 
93
+        if ($contents === false) 
94 94
         {
95 95
             throw new FileHelper_Exception(
96 96
                 'Cannot load serialized content from file.',
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
         
105 105
         $result = @unserialize($contents);
106 106
         
107
-        if($result !== false) {
107
+        if ($result !== false) {
108 108
             return $result;
109 109
         }
110 110
         
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
     
121 121
     public static function deleteTree($rootFolder)
122 122
     {
123
-        if(!file_exists($rootFolder)) {
123
+        if (!file_exists($rootFolder)) {
124 124
             return true;
125 125
         }
126 126
         
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
     */
162 162
     public static function createFolder($path)
163 163
     {
164
-        if(is_dir($path) || mkdir($path, 0777, true)) {
164
+        if (is_dir($path) || mkdir($path, 0777, true)) {
165 165
             return;
166 166
         }
167 167
         
@@ -196,11 +196,11 @@  discard block
 block discarded – undo
196 196
 
197 197
             if ($item->isDir()) 
198 198
             {
199
-                FileHelper::copyTree(str_replace('\\', '/', $itemPath), $target . '/' . $baseName);
199
+                FileHelper::copyTree(str_replace('\\', '/', $itemPath), $target.'/'.$baseName);
200 200
             } 
201
-            else if($item->isFile()) 
201
+            else if ($item->isFile()) 
202 202
             {
203
-                self::copyFile($itemPath, $target . '/' . $baseName);
203
+                self::copyFile($itemPath, $target.'/'.$baseName);
204 204
             }
205 205
         }
206 206
     }
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
     {
226 226
         self::requireFileExists($sourcePath, self::ERROR_SOURCE_FILE_NOT_FOUND);
227 227
         
228
-        if(!is_readable($sourcePath))
228
+        if (!is_readable($sourcePath))
229 229
         {
230 230
             throw new FileHelper_Exception(
231 231
                 sprintf('Source file [%s] to copy is not readable.', basename($sourcePath)),
@@ -239,11 +239,11 @@  discard block
 block discarded – undo
239 239
         
240 240
         $targetFolder = dirname($targetPath);
241 241
         
242
-        if(!file_exists($targetFolder))
242
+        if (!file_exists($targetFolder))
243 243
         {
244 244
             self::createFolder($targetFolder);
245 245
         }
246
-        else if(!is_writable($targetFolder)) 
246
+        else if (!is_writable($targetFolder)) 
247 247
         {
248 248
             throw new FileHelper_Exception(
249 249
                 sprintf('Target folder [%s] is not writable.', basename($targetFolder)),
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
             );
256 256
         }
257 257
         
258
-        if(copy($sourcePath, $targetPath)) {
258
+        if (copy($sourcePath, $targetPath)) {
259 259
             return;
260 260
         }
261 261
         
@@ -282,11 +282,11 @@  discard block
 block discarded – undo
282 282
     */
283 283
     public static function deleteFile(string $filePath) : void
284 284
     {
285
-        if(!file_exists($filePath)) {
285
+        if (!file_exists($filePath)) {
286 286
             return;
287 287
         }
288 288
         
289
-        if(unlink($filePath)) {
289
+        if (unlink($filePath)) {
290 290
             return;
291 291
         }
292 292
         
@@ -308,11 +308,11 @@  discard block
 block discarded – undo
308 308
     * @param string $heading
309 309
     * @return \parseCSV
310 310
     */
311
-    public static function createCSVParser($delimiter = ';', $enclosure = '"', $escape = '\\', $heading=false)
311
+    public static function createCSVParser($delimiter = ';', $enclosure = '"', $escape = '\\', $heading = false)
312 312
     {
313
-        if($delimiter===null) { $delimiter = ';'; }
314
-        if($enclosure===null) { $enclosure = '"'; }
315
-        if($escape===null) { $escape = '\\'; }
313
+        if ($delimiter === null) { $delimiter = ';'; }
314
+        if ($enclosure === null) { $enclosure = '"'; }
315
+        if ($escape === null) { $escape = '\\'; }
316 316
         
317 317
         $parser = new \parseCSV(null, null, null, array());
318 318
 
@@ -334,7 +334,7 @@  discard block
 block discarded – undo
334 334
      * @return array
335 335
      * @see parseCSVFile()
336 336
      */
337
-    public static function parseCSVString($csv, $delimiter = ';', $enclosure = '"', $escape = '\\', $heading=false)
337
+    public static function parseCSVString($csv, $delimiter = ';', $enclosure = '"', $escape = '\\', $heading = false)
338 338
     {
339 339
         $parser = self::createCSVParser($delimiter, $enclosure, $escape, $heading);
340 340
         return $parser->parse_string($csv);
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
      * @return array
352 352
      * @see parseCSVString()
353 353
      */
354
-    public static function parseCSVFile($filePath, $delimiter = ';', $enclosure = '"', $escape = '\\', $heading=false)
354
+    public static function parseCSVFile($filePath, $delimiter = ';', $enclosure = '"', $escape = '\\', $heading = false)
355 355
     {
356 356
         $content = file_get_contents($filePath);
357 357
         if (!$content) {
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
     public static function detectMimeType($fileName)
372 372
     {
373 373
         $ext = self::getExtension($fileName);
374
-        if(empty($ext)) {
374
+        if (empty($ext)) {
375 375
             return null;
376 376
         }
377 377
 
@@ -392,7 +392,7 @@  discard block
 block discarded – undo
392 392
      * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST
393 393
      * @see FileHelper::ERROR_UNKNOWN_FILE_MIME_TYPE
394 394
      */
395
-    public static function sendFile($filePath, $fileName = null, $asAttachment=true)
395
+    public static function sendFile($filePath, $fileName = null, $asAttachment = true)
396 396
     {
397 397
         self::requireFileExists($filePath);
398 398
         
@@ -414,10 +414,10 @@  discard block
 block discarded – undo
414 414
         
415 415
         header("Cache-Control: public", true);
416 416
         header("Content-Description: File Transfer", true);
417
-        header("Content-Type: " . $mime, true);
417
+        header("Content-Type: ".$mime, true);
418 418
 
419 419
         $disposition = 'inline';
420
-        if($asAttachment) {
420
+        if ($asAttachment) {
421 421
             $disposition = 'attachment';
422 422
         }
423 423
         
@@ -491,7 +491,7 @@  discard block
 block discarded – undo
491 491
     */
492 492
     public static function isPHPFile($pathOrDirIterator)
493 493
     {
494
-    	if(self::getExtension($pathOrDirIterator) == 'php') {
494
+    	if (self::getExtension($pathOrDirIterator) == 'php') {
495 495
     		return true;
496 496
     	}
497 497
     	
@@ -508,14 +508,14 @@  discard block
 block discarded – undo
508 508
     */
509 509
     public static function getExtension($pathOrDirIterator, bool $lowercase = true) : string
510 510
     {
511
-        if($pathOrDirIterator instanceof \DirectoryIterator) {
511
+        if ($pathOrDirIterator instanceof \DirectoryIterator) {
512 512
             $filename = $pathOrDirIterator->getFilename();
513 513
         } else {
514 514
             $filename = basename($pathOrDirIterator);
515 515
         }
516 516
          
517 517
         $ext = pathinfo($filename, PATHINFO_EXTENSION);
518
-        if($lowercase) {
518
+        if ($lowercase) {
519 519
         	$ext = mb_strtolower($ext);
520 520
         }
521 521
         
@@ -537,13 +537,13 @@  discard block
 block discarded – undo
537 537
     public static function getFilename($pathOrDirIterator, $extension = true)
538 538
     {
539 539
         $path = $pathOrDirIterator;
540
-    	if($pathOrDirIterator instanceof \DirectoryIterator) {
540
+    	if ($pathOrDirIterator instanceof \DirectoryIterator) {
541 541
     		$path = $pathOrDirIterator->getFilename();
542 542
     	}
543 543
     	
544 544
     	$path = self::normalizePath($path);
545 545
     	
546
-    	if(!$extension) {
546
+    	if (!$extension) {
547 547
     	    return pathinfo($path, PATHINFO_FILENAME);
548 548
     	}
549 549
     	
@@ -561,12 +561,12 @@  discard block
 block discarded – undo
561 561
     * @see FileHelper::ERROR_CANNOT_FIND_JSON_FILE
562 562
     * @see FileHelper::ERROR_CANNOT_DECODE_JSON_FILE
563 563
     */ 
564
-    public static function parseJSONFile(string $file, $targetEncoding=null, $sourceEncoding=null)
564
+    public static function parseJSONFile(string $file, $targetEncoding = null, $sourceEncoding = null)
565 565
     {
566 566
         self::requireFileExists($file, self::ERROR_CANNOT_FIND_JSON_FILE);
567 567
         
568 568
         $content = file_get_contents($file);
569
-        if(!$content) {
569
+        if (!$content) {
570 570
             throw new FileHelper_Exception(
571 571
                 'Cannot get file contents',
572 572
                 sprintf(
@@ -577,12 +577,12 @@  discard block
 block discarded – undo
577 577
             );
578 578
         }
579 579
         
580
-        if(isset($targetEncoding)) {
580
+        if (isset($targetEncoding)) {
581 581
             $content = mb_convert_encoding($content, $targetEncoding, $sourceEncoding);
582 582
         }
583 583
         
584 584
         $json = json_decode($content, true);
585
-        if($json === false || $json === NULL) {
585
+        if ($json === false || $json === NULL) {
586 586
             throw new FileHelper_Exception(
587 587
                 'Cannot decode json data',
588 588
                 sprintf(
@@ -622,13 +622,13 @@  discard block
 block discarded – undo
622 622
         
623 623
         $name = str_replace(array_keys($replaces), array_values($replaces), $name);
624 624
         
625
-        while(strstr($name, '  ')) {
625
+        while (strstr($name, '  ')) {
626 626
             $name = str_replace('  ', ' ', $name);
627 627
         }
628 628
 
629 629
         $name = str_replace(array_keys($replaces), array_values($replaces), $name);
630 630
         
631
-        while(strstr($name, '..')) {
631
+        while (strstr($name, '..')) {
632 632
             $name = str_replace('..', '.', $name);
633 633
         }
634 634
         
@@ -656,7 +656,7 @@  discard block
 block discarded – undo
656 656
     * @return string[]
657 657
     * @see FileHelper::createFileFinder()
658 658
     */
659
-    public static function findHTMLFiles($targetFolder, $options=array())
659
+    public static function findHTMLFiles($targetFolder, $options = array())
660 660
     {
661 661
         return self::findFiles($targetFolder, array('html'), $options);
662 662
     }
@@ -669,44 +669,44 @@  discard block
 block discarded – undo
669 669
     * @return string[]
670 670
     * @see FileHelper::createFileFinder()
671 671
     */
672
-    public static function findPHPFiles($targetFolder, $options=array())
672
+    public static function findPHPFiles($targetFolder, $options = array())
673 673
     {
674 674
         return self::findFiles($targetFolder, array('php'), $options);
675 675
     }
676 676
     
677
-    public static function findFiles($targetFolder, $extensions=array(), $options=array(), $files=array())
677
+    public static function findFiles($targetFolder, $extensions = array(), $options = array(), $files = array())
678 678
     {
679
-        if(!isset($options['strip-extension'])) {
679
+        if (!isset($options['strip-extension'])) {
680 680
             $options['strip-extension'] = false;
681 681
         }
682 682
         
683
-        if(!isset($options['absolute-path'])) {
683
+        if (!isset($options['absolute-path'])) {
684 684
             $options['absolute-path'] = false;
685 685
         } 
686 686
         
687
-        if(!isset($options['relative-path'])) {
687
+        if (!isset($options['relative-path'])) {
688 688
             $options['relative-path'] = false;
689 689
         }
690 690
         
691
-        if(!isset($options['recursive'])) {
691
+        if (!isset($options['recursive'])) {
692 692
             $options['recursive'] = false;
693 693
         }
694 694
         
695
-        if($options['relative-path']) {
695
+        if ($options['relative-path']) {
696 696
             $options['absolute-path'] = true;
697 697
         }
698 698
         
699
-        if(!isset($options['__root'])) {
699
+        if (!isset($options['__root'])) {
700 700
             $options['__root'] = self::normalizePath($targetFolder);
701 701
         }
702 702
         
703 703
         $checkExtensions = false;
704
-        if(!empty($extensions)) {
704
+        if (!empty($extensions)) {
705 705
             $checkExtensions = true;
706 706
             $extensions = array_map('strtolower', $extensions);
707 707
         }
708 708
         
709
-        if(!is_dir($targetFolder)) 
709
+        if (!is_dir($targetFolder)) 
710 710
         {
711 711
             throw new FileHelper_Exception(
712 712
                 'Target folder does not exist',
@@ -719,32 +719,32 @@  discard block
 block discarded – undo
719 719
         }
720 720
         
721 721
         $d = new \DirectoryIterator($targetFolder);
722
-        foreach($d as $item) {
723
-            if($item->isDot()) {
722
+        foreach ($d as $item) {
723
+            if ($item->isDot()) {
724 724
                 continue;
725 725
             }
726 726
             
727
-            if($item->isDir()) {
728
-                if($options['recursive']) {
727
+            if ($item->isDir()) {
728
+                if ($options['recursive']) {
729 729
                     $files = self::findFiles($item->getPathname(), $extensions, $options, $files);
730 730
                 }
731 731
                 continue;
732 732
             }
733 733
             
734
-            if($checkExtensions && !in_array(self::getExtension($item, true), $extensions)) {
734
+            if ($checkExtensions && !in_array(self::getExtension($item, true), $extensions)) {
735 735
                 continue;
736 736
             }
737 737
             
738 738
             $filename = $item->getFilename();
739
-            if($options['strip-extension']) {
739
+            if ($options['strip-extension']) {
740 740
                 $filename = self::removeExtension($filename);
741 741
             }
742 742
             
743
-            if($options['absolute-path']) {
743
+            if ($options['absolute-path']) {
744 744
                 $filename = self::normalizePath($targetFolder.'/'.$filename);
745 745
             }
746 746
             
747
-            if($options['relative-path']) {
747
+            if ($options['relative-path']) {
748 748
                 $filename = ltrim(str_replace($options['__root'], '', $filename), '/');
749 749
             }
750 750
             
@@ -792,9 +792,9 @@  discard block
 block discarded – undo
792 792
         fclose($fp);
793 793
 
794 794
         $boms = self::getUTFBOMs();
795
-        foreach($boms as $bom => $value) {
795
+        foreach ($boms as $bom => $value) {
796 796
             $length = mb_strlen($value);
797
-            if(mb_substr($text, 0, $length) == $value) {
797
+            if (mb_substr($text, 0, $length) == $value) {
798 798
                 return $bom;
799 799
             }
800 800
         }
@@ -813,13 +813,13 @@  discard block
 block discarded – undo
813 813
     */
814 814
     public static function getUTFBOMs()
815 815
     {
816
-        if(!isset(self::$utfBoms)) {
816
+        if (!isset(self::$utfBoms)) {
817 817
             self::$utfBoms = array(
818
-                'UTF32-BE' => chr(0x00) . chr(0x00) . chr(0xFE) . chr(0xFF),
819
-                'UTF32-LE' => chr(0xFF) . chr(0xFE) . chr(0x00) . chr(0x00),
820
-                'UTF16-BE' => chr(0xFE) . chr(0xFF),
821
-                'UTF16-LE' => chr(0xFF) . chr(0xFE),
822
-                'UTF8' => chr(0xEF) . chr(0xBB) . chr(0xBF)
818
+                'UTF32-BE' => chr(0x00).chr(0x00).chr(0xFE).chr(0xFF),
819
+                'UTF32-LE' => chr(0xFF).chr(0xFE).chr(0x00).chr(0x00),
820
+                'UTF16-BE' => chr(0xFE).chr(0xFF),
821
+                'UTF16-LE' => chr(0xFF).chr(0xFE),
822
+                'UTF8' => chr(0xEF).chr(0xBB).chr(0xBF)
823 823
             );
824 824
         }
825 825
         
@@ -840,7 +840,7 @@  discard block
 block discarded – undo
840 840
         $encodings = self::getKnownUnicodeEncodings();
841 841
 
842 842
         $keep = array();
843
-        foreach($encodings as $string) 
843
+        foreach ($encodings as $string) 
844 844
         {
845 845
             $withHyphen = str_replace('UTF', 'UTF-', $string);
846 846
             
@@ -871,22 +871,22 @@  discard block
 block discarded – undo
871 871
     */
872 872
     public static function normalizePath($path)
873 873
     {
874
-        if(is_string($path)) {
874
+        if (is_string($path)) {
875 875
             $path = str_replace(array('\\', '//'), array('/', '/'), $path);
876 876
         }
877 877
         
878 878
         return $path;
879 879
     }
880 880
     
881
-    public static function saveAsJSON($data, $file, $pretty=false)
881
+    public static function saveAsJSON($data, $file, $pretty = false)
882 882
     {
883 883
         $options = null;
884
-        if($pretty) {
884
+        if ($pretty) {
885 885
             $options = JSON_PRETTY_PRINT;
886 886
         }
887 887
         
888 888
         $json = json_encode($data, $options);
889
-        if($json===false) 
889
+        if ($json === false) 
890 890
         {
891 891
             $errorCode = json_last_error();
892 892
             throw new FileHelper_Exception(
@@ -896,7 +896,7 @@  discard block
 block discarded – undo
896 896
             ); 
897 897
         }
898 898
         
899
-        if(!file_put_contents($file, $json)) {
899
+        if (!file_put_contents($file, $json)) {
900 900
             throw new FileHelper_Exception(
901 901
                 sprintf('Could not write the JSON file [%s] to disk.', basename($file)),
902 902
                 sprintf('Full path: [%s].', $file),
@@ -917,12 +917,12 @@  discard block
 block discarded – undo
917 917
     * @see FileHelper::ERROR_SAVE_FILE_NOT_WRITABLE
918 918
     * @see FileHelper::ERROR_SAVE_FILE_WRITE_FAILED
919 919
     */
920
-    public static function saveFile(string $filePath, string $content='') : void
920
+    public static function saveFile(string $filePath, string $content = '') : void
921 921
     {
922 922
         // target file already exists
923
-        if(file_exists($filePath))
923
+        if (file_exists($filePath))
924 924
         {
925
-            if(!is_writable($filePath))
925
+            if (!is_writable($filePath))
926 926
             {
927 927
                 throw new FileHelper_Exception(
928 928
                     sprintf('Cannot save file: target file [%s] exists, but is not writable.', basename($filePath)),
@@ -942,7 +942,7 @@  discard block
 block discarded – undo
942 942
             // create the folder as needed
943 943
             self::createFolder($targetFolder);
944 944
             
945
-            if(!is_writable($targetFolder)) 
945
+            if (!is_writable($targetFolder)) 
946 946
             {
947 947
                 throw new FileHelper_Exception(
948 948
                     sprintf('Cannot save file: target folder [%s] is not writable.', basename($targetFolder)),
@@ -955,7 +955,7 @@  discard block
 block discarded – undo
955 955
             }
956 956
         }
957 957
         
958
-        if(file_put_contents($filePath, $content) !== false) {
958
+        if (file_put_contents($filePath, $content) !== false) {
959 959
             return;
960 960
         }
961 961
         
@@ -991,7 +991,7 @@  discard block
 block discarded – undo
991 991
     {
992 992
         static $checked = array();
993 993
         
994
-        if(isset($checked[$command])) {
994
+        if (isset($checked[$command])) {
995 995
             return $checked[$command];
996 996
         }
997 997
         
@@ -1004,7 +1004,7 @@  discard block
 block discarded – undo
1004 1004
         
1005 1005
         $os = strtolower(PHP_OS_FAMILY);
1006 1006
         
1007
-        if(!isset($osCommands[$os])) 
1007
+        if (!isset($osCommands[$os])) 
1008 1008
         {
1009 1009
             throw new FileHelper_Exception(
1010 1010
                 'Unsupported OS for CLI commands',
@@ -1030,7 +1030,7 @@  discard block
 block discarded – undo
1030 1030
             $pipes
1031 1031
         );
1032 1032
         
1033
-        if($process === false) {
1033
+        if ($process === false) {
1034 1034
             $checked[$command] = false;
1035 1035
             return false;
1036 1036
         }
@@ -1061,7 +1061,7 @@  discard block
 block discarded – undo
1061 1061
     */
1062 1062
     public static function checkPHPFileSyntax($path)
1063 1063
     {
1064
-        if(!self::canMakePHPCalls()) {
1064
+        if (!self::canMakePHPCalls()) {
1065 1065
             return true;
1066 1066
         }
1067 1067
         
@@ -1072,7 +1072,7 @@  discard block
 block discarded – undo
1072 1072
         // when the validation is successful, the first entry
1073 1073
         // in the array contains the success message. When it
1074 1074
         // is invalid, the first entry is always empty.
1075
-        if(!empty($output[0])) {
1075
+        if (!empty($output[0])) {
1076 1076
             return true;
1077 1077
         }
1078 1078
         
@@ -1093,7 +1093,7 @@  discard block
 block discarded – undo
1093 1093
     public static function getModifiedDate($path)
1094 1094
     {
1095 1095
         $time = filemtime($path);
1096
-        if($time !== false) {
1096
+        if ($time !== false) {
1097 1097
             $date = new \DateTime();
1098 1098
             $date->setTimestamp($time);
1099 1099
             return $date;
@@ -1120,7 +1120,7 @@  discard block
 block discarded – undo
1120 1120
     */
1121 1121
     public static function getSubfolders($targetFolder, $options = array())
1122 1122
     {
1123
-        if(!is_dir($targetFolder)) 
1123
+        if (!is_dir($targetFolder)) 
1124 1124
         {
1125 1125
             throw new FileHelper_Exception(
1126 1126
                 'Target folder does not exist',
@@ -1144,29 +1144,29 @@  discard block
 block discarded – undo
1144 1144
         
1145 1145
         $d = new \DirectoryIterator($targetFolder);
1146 1146
         
1147
-        foreach($d as $item) 
1147
+        foreach ($d as $item) 
1148 1148
         {
1149
-            if($item->isDir() && !$item->isDot()) 
1149
+            if ($item->isDir() && !$item->isDot()) 
1150 1150
             {
1151 1151
                 $name = $item->getFilename();
1152 1152
                 
1153
-                if(!$options['absolute-path']) {
1153
+                if (!$options['absolute-path']) {
1154 1154
                     $result[] = $name;
1155 1155
                 } else {
1156 1156
                     $result[] = $targetFolder.'/'.$name;
1157 1157
                 }
1158 1158
                 
1159
-                if(!$options['recursive']) 
1159
+                if (!$options['recursive']) 
1160 1160
                 {
1161 1161
                     continue;
1162 1162
                 }
1163 1163
                 
1164 1164
                 $subs = self::getSubfolders($targetFolder.'/'.$name, $options);
1165
-                foreach($subs as $sub) 
1165
+                foreach ($subs as $sub) 
1166 1166
                 {
1167 1167
                     $relative = $name.'/'.$sub;
1168 1168
                     
1169
-                    if(!$options['absolute-path']) {
1169
+                    if (!$options['absolute-path']) {
1170 1170
                         $result[] = $relative;
1171 1171
                     } else {
1172 1172
                         $result[] = $targetFolder.'/'.$relative;
@@ -1234,7 +1234,7 @@  discard block
 block discarded – undo
1234 1234
     * @param int $depth The folder depth to reduce the path to
1235 1235
     * @return string
1236 1236
     */
1237
-    public static function relativizePathByDepth(string $path, int $depth=2) : string
1237
+    public static function relativizePathByDepth(string $path, int $depth = 2) : string
1238 1238
     {
1239 1239
         $path = self::normalizePath($path);
1240 1240
         
@@ -1242,17 +1242,17 @@  discard block
 block discarded – undo
1242 1242
         $tokens = array_filter($tokens); // remove empty entries (trailing slash for example)
1243 1243
         $tokens = array_values($tokens); // re-index keys
1244 1244
         
1245
-        if(empty($tokens)) {
1245
+        if (empty($tokens)) {
1246 1246
             return '';
1247 1247
         }
1248 1248
         
1249 1249
         // remove the drive if present
1250
-        if(strstr($tokens[0], ':')) {
1250
+        if (strstr($tokens[0], ':')) {
1251 1251
             array_shift($tokens);
1252 1252
         }
1253 1253
         
1254 1254
         // path was only the drive
1255
-        if(count($tokens) == 0) {
1255
+        if (count($tokens) == 0) {
1256 1256
             return '';
1257 1257
         }
1258 1258
 
@@ -1261,8 +1261,8 @@  discard block
 block discarded – undo
1261 1261
         
1262 1262
         // reduce the path to the specified depth
1263 1263
         $length = count($tokens);
1264
-        if($length > $depth) {
1265
-            $tokens = array_slice($tokens, $length-$depth);
1264
+        if ($length > $depth) {
1265
+            $tokens = array_slice($tokens, $length - $depth);
1266 1266
         }
1267 1267
 
1268 1268
         // append the last element again
@@ -1310,14 +1310,14 @@  discard block
 block discarded – undo
1310 1310
     * 
1311 1311
     * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST
1312 1312
     */
1313
-    public static function requireFileExists(string $path, $errorCode=null) : string
1313
+    public static function requireFileExists(string $path, $errorCode = null) : string
1314 1314
     {
1315 1315
         $result = realpath($path);
1316
-        if($result !== false) {
1316
+        if ($result !== false) {
1317 1317
             return $result;
1318 1318
         }
1319 1319
         
1320
-        if($errorCode === null) {
1320
+        if ($errorCode === null) {
1321 1321
             $errorCode = self::ERROR_FILE_DOES_NOT_EXIST;
1322 1322
         }
1323 1323
         
@@ -1346,15 +1346,15 @@  discard block
 block discarded – undo
1346 1346
         
1347 1347
         $file = new \SplFileObject($path);
1348 1348
         
1349
-        if($file->eof()) {
1349
+        if ($file->eof()) {
1350 1350
             return '';
1351 1351
         }
1352 1352
         
1353
-        $targetLine = $lineNumber-1;
1353
+        $targetLine = $lineNumber - 1;
1354 1354
         
1355 1355
         $file->seek($targetLine);
1356 1356
         
1357
-        if($file->key() !== $targetLine) {
1357
+        if ($file->key() !== $targetLine) {
1358 1358
              return null;
1359 1359
         }
1360 1360
         
@@ -1380,7 +1380,7 @@  discard block
 block discarded – undo
1380 1380
         $number = $spl->key();
1381 1381
         
1382 1382
         // if seeking to the end the cursor is still at 0, there are no lines. 
1383
-        if($number === 0) 
1383
+        if ($number === 0) 
1384 1384
         {
1385 1385
             // since it's a very small file, to get reliable results,
1386 1386
             // we read its contents and use that to determine what
@@ -1388,13 +1388,13 @@  discard block
 block discarded – undo
1388 1388
             // that this is not pactical to solve with the SplFileObject.
1389 1389
             $content = file_get_contents($path);
1390 1390
             
1391
-            if(empty($content)) {
1391
+            if (empty($content)) {
1392 1392
                 return 0;
1393 1393
             }
1394 1394
         }
1395 1395
         
1396 1396
         // return the line number we were able to reach + 1 (key is zero-based)
1397
-        return $number+1;
1397
+        return $number + 1;
1398 1398
     }
1399 1399
     
1400 1400
    /**
@@ -1441,13 +1441,13 @@  discard block
 block discarded – undo
1441 1441
     * @see FileHelper::ERROR_CANNOT_OPEN_FILE_TO_READ_LINES
1442 1442
     * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST
1443 1443
     */
1444
-    public static function readLines(string $filePath, int $amount=0) : array
1444
+    public static function readLines(string $filePath, int $amount = 0) : array
1445 1445
     {
1446 1446
         self::requireFileExists($filePath);
1447 1447
         
1448 1448
         $fn = fopen($filePath, "r");
1449 1449
         
1450
-        if($fn === false) 
1450
+        if ($fn === false) 
1451 1451
         {
1452 1452
             throw new FileHelper_Exception(
1453 1453
                 'Could not open file for reading.',
@@ -1463,25 +1463,25 @@  discard block
 block discarded – undo
1463 1463
         $counter = 0;
1464 1464
         $first = true;
1465 1465
         
1466
-        while(!feof($fn)) 
1466
+        while (!feof($fn)) 
1467 1467
         {
1468 1468
             $counter++;
1469 1469
             
1470 1470
             $line = fgets($fn);
1471 1471
             
1472 1472
             // can happen with zero length files
1473
-            if($line === false) {
1473
+            if ($line === false) {
1474 1474
                 continue;
1475 1475
             }
1476 1476
             
1477 1477
             // the first line may contain a unicode BOM marker.
1478
-            if($first) {
1478
+            if ($first) {
1479 1479
                 $line = ConvertHelper::stripUTFBom($line);
1480 1480
             }
1481 1481
             
1482 1482
             $result[] = $line;
1483 1483
             
1484
-            if($amount > 0 && $counter == $amount) {
1484
+            if ($amount > 0 && $counter == $amount) {
1485 1485
                 break;
1486 1486
             }
1487 1487
         }
@@ -1507,7 +1507,7 @@  discard block
 block discarded – undo
1507 1507
         
1508 1508
         $result = file_get_contents($filePath);
1509 1509
         
1510
-        if($result !== false) {
1510
+        if ($result !== false) {
1511 1511
             return $result;
1512 1512
         }
1513 1513
         
Please login to merge, or discard this patch.
examples/URLInfo/highlighting.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@
 block discarded – undo
42 42
 		<br>
43 43
         <?php
44 44
         
45
-            foreach($urls as $url)
45
+            foreach ($urls as $url)
46 46
             {
47 47
                 $info = parseURL($url);
48 48
                 
Please login to merge, or discard this patch.
examples/prepend.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@
 block discarded – undo
12 12
     $autoload = realpath($root.'/../vendor/autoload.php');
13 13
     
14 14
     // we need the autoloader to be present
15
-    if($autoload === false) 
15
+    if ($autoload === false) 
16 16
     {
17 17
         die('<b>ERROR:</b> Autoloader not present. Run composer update first.');
18 18
     }
Please login to merge, or discard this patch.
src/ConvertHelper.php 1 patch
Spacing   +113 added lines, -113 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
             $amount = substr_count($line, "\t") - $min;
69 69
             $line = trim($line);
70 70
             if ($amount >= 1) {
71
-                $line = str_repeat("\t", $amount) . $line;
71
+                $line = str_repeat("\t", $amount).$line;
72 72
             }
73 73
 
74 74
             $converted[] = $line;
@@ -140,10 +140,10 @@  discard block
 block discarded – undo
140 140
 
141 141
         // specifically handle zero
142 142
         if ($seconds <= 0) {
143
-            return '0 ' . t('seconds');
143
+            return '0 '.t('seconds');
144 144
         }
145 145
         
146
-        if($seconds < 1) {
146
+        if ($seconds < 1) {
147 147
             return t('less than a second');
148 148
         }
149 149
 
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
         foreach ($units as $def) {
152 152
             $quot = intval($seconds / $def['value']);
153 153
             if ($quot) {
154
-                $item = $quot . ' ';
154
+                $item = $quot.' ';
155 155
                 if (abs($quot) > 1) {
156 156
                     $item .= $def['plural'];
157 157
                 } else {
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
             return $last;
169 169
         }
170 170
 
171
-        return implode(', ', $tokens) . ' ' . t('and') . ' ' . $last;
171
+        return implode(', ', $tokens).' '.t('and').' '.$last;
172 172
     }
173 173
 
174 174
     /**
@@ -185,11 +185,11 @@  discard block
 block discarded – undo
185 185
      */
186 186
     public static function duration2string($datefrom, $dateto = -1)
187 187
     {
188
-        if($datefrom instanceof \DateTime) {
188
+        if ($datefrom instanceof \DateTime) {
189 189
             $datefrom = ConvertHelper::date2timestamp($datefrom);
190 190
         }
191 191
         
192
-        if($dateto instanceof \DateTime) {
192
+        if ($dateto instanceof \DateTime) {
193 193
             $dateto = ConvertHelper::date2timestamp($dateto);
194 194
         }
195 195
         
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
         $interval = "";
211 211
         
212 212
         $future = false;
213
-        if($difference < 0) {
213
+        if ($difference < 0) {
214 214
             $difference = $difference * -1;
215 215
             $future = true;
216 216
         }
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
                 $day = (int)date("j", $dateto);
286 286
                 $year = (int)date("Y", $datefrom);
287 287
                 
288
-                while(mktime($hour, $min, $sec, $month + ($months_difference), $day, $year) < $dateto) 
288
+                while (mktime($hour, $min, $sec, $month + ($months_difference), $day, $year) < $dateto) 
289 289
                 {
290 290
                     $months_difference++;
291 291
                 }
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
                     $datediff--;
301 301
                 }
302 302
 
303
-                if($future) {
303
+                if ($future) {
304 304
                     $result = ($datediff == 1) ? t('In one month', $datediff) : t('In %1s months', $datediff);
305 305
                 } else {
306 306
                     $result = ($datediff == 1) ? t('One month ago', $datediff) : t('%1s months ago', $datediff);
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
 
310 310
             case "y":
311 311
                 $datediff = floor($difference / 60 / 60 / 24 / 365);
312
-                if($future) {
312
+                if ($future) {
313 313
                     $result = ($datediff == 1) ? t('In one year', $datediff) : t('In %1s years', $datediff);
314 314
                 } else {
315 315
                     $result = ($datediff == 1) ? t('One year ago', $datediff) : t('%1s years ago', $datediff);
@@ -318,7 +318,7 @@  discard block
 block discarded – undo
318 318
 
319 319
             case "d":
320 320
                 $datediff = floor($difference / 60 / 60 / 24);
321
-                if($future) {
321
+                if ($future) {
322 322
                     $result = ($datediff == 1) ? t('In one day', $datediff) : t('In %1s days', $datediff);
323 323
                 } else {
324 324
                     $result = ($datediff == 1) ? t('One day ago', $datediff) : t('%1s days ago', $datediff);
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
 
328 328
             case "ww":
329 329
                 $datediff = floor($difference / 60 / 60 / 24 / 7);
330
-                if($future) {
330
+                if ($future) {
331 331
                     $result = ($datediff == 1) ? t('In one week', $datediff) : t('In %1s weeks', $datediff);
332 332
                 } else {
333 333
                     $result = ($datediff == 1) ? t('One week ago', $datediff) : t('%1s weeks ago', $datediff);
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
 
337 337
             case "h":
338 338
                 $datediff = floor($difference / 60 / 60);
339
-                if($future) {
339
+                if ($future) {
340 340
                     $result = ($datediff == 1) ? t('In one hour', $datediff) : t('In %1s hours', $datediff);
341 341
                 } else {
342 342
                     $result = ($datediff == 1) ? t('One hour ago', $datediff) : t('%1s hours ago', $datediff);
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
 
346 346
             case "n":
347 347
                 $datediff = floor($difference / 60);
348
-                if($future) {
348
+                if ($future) {
349 349
                     $result = ($datediff == 1) ? t('In one minute', $datediff) : t('In %1s minutes', $datediff);
350 350
                 } else {
351 351
                     $result = ($datediff == 1) ? t('One minute ago', $datediff) : t('%1s minutes ago', $datediff);
@@ -354,7 +354,7 @@  discard block
 block discarded – undo
354 354
 
355 355
             case "s":
356 356
                 $datediff = $difference;
357
-                if($future) {
357
+                if ($future) {
358 358
                     $result = ($datediff == 1) ? t('In one second', $datediff) : t('In %1s seconds', $datediff);
359 359
                 } else {
360 360
                     $result = ($datediff == 1) ? t('One second ago', $datediff) : t('%1s seconds ago', $datediff);
@@ -377,9 +377,9 @@  discard block
 block discarded – undo
377 377
         return $geshi->parse_code();
378 378
     }
379 379
     
380
-    public static function highlight_xml($xml, $formatSource=false)
380
+    public static function highlight_xml($xml, $formatSource = false)
381 381
     {
382
-        if($formatSource) 
382
+        if ($formatSource) 
383 383
         {
384 384
             $dom = new \DOMDocument();
385 385
             $dom->loadXML($xml);
@@ -417,22 +417,22 @@  discard block
 block discarded – undo
417 417
         $terabyte = $gigabyte * 1024;
418 418
 
419 419
         if (($bytes >= 0) && ($bytes < $kilobyte)) {
420
-            return $bytes . ' ' . t('B');
420
+            return $bytes.' '.t('B');
421 421
 
422 422
         } elseif (($bytes >= $kilobyte) && ($bytes < $megabyte)) {
423
-            return round($bytes / $kilobyte, $precision) . ' ' . t('Kb');
423
+            return round($bytes / $kilobyte, $precision).' '.t('Kb');
424 424
 
425 425
         } elseif (($bytes >= $megabyte) && ($bytes < $gigabyte)) {
426
-            return round($bytes / $megabyte, $precision) . ' ' . t('Mb');
426
+            return round($bytes / $megabyte, $precision).' '.t('Mb');
427 427
 
428 428
         } elseif (($bytes >= $gigabyte) && ($bytes < $terabyte)) {
429
-            return round($bytes / $gigabyte, $precision) . ' ' . t('Gb');
429
+            return round($bytes / $gigabyte, $precision).' '.t('Gb');
430 430
 
431 431
         } elseif ($bytes >= $terabyte) {
432
-            return round($bytes / $gigabyte, $precision) . ' ' . t('Tb');
432
+            return round($bytes / $gigabyte, $precision).' '.t('Tb');
433 433
         }
434 434
 
435
-        return $bytes . ' ' . t('B');
435
+        return $bytes.' '.t('B');
436 436
     }
437 437
 
438 438
    /**
@@ -452,34 +452,34 @@  discard block
 block discarded – undo
452 452
             return $text;
453 453
         }
454 454
 
455
-        $text = trim(mb_substr($text, 0, $targetLength)) . $append;
455
+        $text = trim(mb_substr($text, 0, $targetLength)).$append;
456 456
 
457 457
         return $text;
458 458
     }
459 459
 
460
-    public static function var_dump($var, $html=true)
460
+    public static function var_dump($var, $html = true)
461 461
     {
462 462
         $info = parseVariable($var);
463 463
         
464
-        if($html) {
464
+        if ($html) {
465 465
             return $info->toHTML();
466 466
         }
467 467
         
468 468
         return $info->toString();
469 469
     }
470 470
     
471
-    public static function print_r($var, $return=false, $html=true)
471
+    public static function print_r($var, $return = false, $html = true)
472 472
     {
473 473
         $result = self::var_dump($var, $html);
474 474
         
475
-        if($html) {
475
+        if ($html) {
476 476
             $result = 
477 477
             '<pre style="background:#fff;color:#333;padding:16px;border:solid 1px #bbb;border-radius:4px">'.
478 478
                 $result.
479 479
             '</pre>';
480 480
         }
481 481
         
482
-        if($return) {
482
+        if ($return) {
483 483
             return $result;
484 484
         }
485 485
         
@@ -499,7 +499,7 @@  discard block
 block discarded – undo
499 499
 
500 500
     public static function string2bool($string)
501 501
     {
502
-        if($string === '' || $string === null) {
502
+        if ($string === '' || $string === null) {
503 503
             return false;
504 504
         }
505 505
         
@@ -554,10 +554,10 @@  discard block
 block discarded – undo
554 554
     public static function date2listLabel(\DateTime $date, $includeTime = false, $shortMonth = false)
555 555
     {
556 556
         $today = new \DateTime();
557
-        if($date->format('d.m.Y') == $today->format('d.m.Y')) {
557
+        if ($date->format('d.m.Y') == $today->format('d.m.Y')) {
558 558
             $label = t('Today');
559 559
         } else {
560
-            $label = $date->format('d') . '. ' . self::month2string((int)$date->format('m'), $shortMonth) . ' ';
560
+            $label = $date->format('d').'. '.self::month2string((int)$date->format('m'), $shortMonth).' ';
561 561
             if ($date->format('Y') != date('Y')) {
562 562
                 $label .= $date->format('Y');
563 563
             }
@@ -648,28 +648,28 @@  discard block
 block discarded – undo
648 648
         $hexAlphabet = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F');
649 649
         
650 650
         $stack = array();
651
-        foreach(self::$controlChars as $char)
651
+        foreach (self::$controlChars as $char)
652 652
         {
653 653
             $tokens = explode('-', $char);
654 654
             $start = $tokens[0];
655 655
             $end = $tokens[1];
656 656
             $prefix = substr($start, 0, 3);
657 657
             $range = array();
658
-            foreach($hexAlphabet as $number) {
658
+            foreach ($hexAlphabet as $number) {
659 659
                 $range[] = $prefix.$number;
660 660
             }
661 661
             
662 662
             $use = false;
663
-            foreach($range as $number) {
664
-                if($number == $start) {
663
+            foreach ($range as $number) {
664
+                if ($number == $start) {
665 665
                     $use = true;
666 666
                 }
667 667
                 
668
-                if($use) {
668
+                if ($use) {
669 669
                     $stack[] = $number;
670 670
                 }
671 671
                 
672
-                if($number == $end) {
672
+                if ($number == $end) {
673 673
                     break;
674 674
                 }
675 675
             }
@@ -690,7 +690,7 @@  discard block
 block discarded – undo
690 690
         $chars = self::getControlCharactersAsHex();
691 691
         
692 692
         $result = array();
693
-        foreach($chars as $char) {
693
+        foreach ($chars as $char) {
694 694
             $result[] = hex2bin($char);
695 695
         }
696 696
         
@@ -708,14 +708,14 @@  discard block
 block discarded – undo
708 708
         $chars = self::getControlCharactersAsHex();
709 709
         
710 710
         $result = array();
711
-        foreach($chars as $char) {
711
+        foreach ($chars as $char) {
712 712
             $result[] = '\u'.strtolower($char);
713 713
         }
714 714
         
715 715
         return $result;
716 716
     }
717 717
     
718
-    protected static $controlChars =  array(
718
+    protected static $controlChars = array(
719 719
         '0000-0008', // control chars
720 720
         '000E-000F', // control chars
721 721
         '0010-001F', // control chars
@@ -737,19 +737,19 @@  discard block
 block discarded – undo
737 737
      */
738 738
     public static function stripControlCharacters(string $string) : string
739 739
     {
740
-        if(empty($string)) {
740
+        if (empty($string)) {
741 741
             return $string;
742 742
         }
743 743
         
744 744
         // create the regex from the unicode characters list
745
-        if(!isset(self::$controlCharsRegex)) 
745
+        if (!isset(self::$controlCharsRegex)) 
746 746
         {
747 747
             $chars = self::getControlCharactersAsHex();
748 748
 
749 749
             // we use the notation \x{0000} to specify the unicode character key
750 750
             // in the regular expression.
751 751
             $stack = array();
752
-            foreach($chars as $char) {
752
+            foreach ($chars as $char) {
753 753
                 $stack[] = '\x{'.$char.'}';
754 754
             }
755 755
             
@@ -783,7 +783,7 @@  discard block
 block discarded – undo
783 783
             $ordInt = ord($octet);
784 784
             // Convert from int (base 10) to hex (base 16), for PHP \x syntax
785 785
             $ordHex = base_convert($ordInt, 10, 16);
786
-            $output .= '\x' . $ordHex;
786
+            $output .= '\x'.$ordHex;
787 787
         }
788 788
         return $output;
789 789
     }
@@ -815,19 +815,19 @@  discard block
 block discarded – undo
815 815
     
816 816
     protected static function convertScalarForComparison($scalar)
817 817
     {
818
-        if($scalar === '' || is_null($scalar)) {
818
+        if ($scalar === '' || is_null($scalar)) {
819 819
             return null;
820 820
         }
821 821
         
822
-        if(is_bool($scalar)) {
822
+        if (is_bool($scalar)) {
823 823
             return self::bool2string($scalar);
824 824
         }
825 825
         
826
-        if(is_array($scalar)) {
826
+        if (is_array($scalar)) {
827 827
             $scalar = md5(serialize($scalar));
828 828
         }
829 829
         
830
-        if($scalar !== null && !is_scalar($scalar)) {
830
+        if ($scalar !== null && !is_scalar($scalar)) {
831 831
             throw new ConvertHelper_Exception(
832 832
                 'Not a scalar value in comparison',
833 833
                 null,
@@ -876,7 +876,7 @@  discard block
 block discarded – undo
876 876
     public static function bool2string($boolean, bool $yesno = false) : string
877 877
     {
878 878
         // allow 'yes', 'true', 'no', 'false' string notations as well
879
-        if(!is_bool($boolean)) {
879
+        if (!is_bool($boolean)) {
880 880
             $boolean = self::string2bool($boolean);
881 881
         }
882 882
         
@@ -917,15 +917,15 @@  discard block
 block discarded – undo
917 917
     public static function array2attributeString($array)
918 918
     {
919 919
         $tokens = array();
920
-        foreach($array as $attr => $value) {
921
-            if($value == '' || $value == null) {
920
+        foreach ($array as $attr => $value) {
921
+            if ($value == '' || $value == null) {
922 922
                 continue;
923 923
             }
924 924
             
925 925
             $tokens[] = $attr.'="'.$value.'"';
926 926
         }
927 927
         
928
-        if(empty($tokens)) {
928
+        if (empty($tokens)) {
929 929
             return '';
930 930
         }
931 931
         
@@ -940,10 +940,10 @@  discard block
 block discarded – undo
940 940
     * @param string $string
941 941
     * @return string
942 942
     */
943
-    public static function string2attributeJS($string, $quoted=true)
943
+    public static function string2attributeJS($string, $quoted = true)
944 944
     {
945 945
         $converted = addslashes(htmlspecialchars(strip_tags($string), ENT_QUOTES, 'UTF-8'));
946
-        if($quoted) {
946
+        if ($quoted) {
947 947
             $converted = "'".$converted."'";
948 948
         } 
949 949
         
@@ -961,11 +961,11 @@  discard block
 block discarded – undo
961 961
     */
962 962
     public static function isBoolean($value) : bool
963 963
     {
964
-        if(is_bool($value)) {
964
+        if (is_bool($value)) {
965 965
             return true;
966 966
         }
967 967
         
968
-        if(!is_scalar($value)) {
968
+        if (!is_scalar($value)) {
969 969
             return false;
970 970
         }
971 971
         
@@ -981,7 +981,7 @@  discard block
 block discarded – undo
981 981
     public static function array2styleString(array $subject) : string
982 982
     {
983 983
         $tokens = array();
984
-        foreach($subject as $name => $value) {
984
+        foreach ($subject as $name => $value) {
985 985
             $tokens[] = $name.':'.$value;
986 986
         }
987 987
         
@@ -1046,7 +1046,7 @@  discard block
 block discarded – undo
1046 1046
     * @param string $regex
1047 1047
     * @return array
1048 1048
     */
1049
-    public static function regex2js($regex, $return=self::JS_REGEX_OBJECT)
1049
+    public static function regex2js($regex, $return = self::JS_REGEX_OBJECT)
1050 1050
     {
1051 1051
         $regex = trim($regex);
1052 1052
         $separator = substr($regex, 0, 1);
@@ -1054,7 +1054,7 @@  discard block
 block discarded – undo
1054 1054
         array_shift($parts);
1055 1055
         
1056 1056
         $modifiers = array_pop($parts);
1057
-        if($modifiers == $separator) {
1057
+        if ($modifiers == $separator) {
1058 1058
             $modifiers = '';
1059 1059
         }
1060 1060
         
@@ -1070,14 +1070,14 @@  discard block
 block discarded – undo
1070 1070
         // convert the anchors that are not supported in js regexes
1071 1071
         $format = str_replace(array('\\A', '\\Z', '\\z'), array('^', '$', ''), $format);
1072 1072
         
1073
-        if($return==self::JS_REGEX_JSON) {
1073
+        if ($return == self::JS_REGEX_JSON) {
1074 1074
             return json_encode(array(
1075 1075
                 'format' => $format,
1076 1076
                 'modifiers' => $modifiers
1077 1077
             ));
1078 1078
         }
1079 1079
         
1080
-        if(!empty($modifiers)) {
1080
+        if (!empty($modifiers)) {
1081 1081
             return sprintf(
1082 1082
                 'new RegExp(%s, %s)',
1083 1083
                 json_encode($format),
@@ -1100,10 +1100,10 @@  discard block
 block discarded – undo
1100 1100
     public static function stripUTFBom($string)
1101 1101
     {
1102 1102
         $boms = FileHelper::getUTFBOMs();
1103
-        foreach($boms as $bomChars) {
1103
+        foreach ($boms as $bomChars) {
1104 1104
             $length = mb_strlen($bomChars);
1105 1105
             $text = mb_substr($string, 0, $length);
1106
-            if($text==$bomChars) {
1106
+            if ($text == $bomChars) {
1107 1107
                 return mb_substr($string, $length);
1108 1108
             }
1109 1109
         }
@@ -1120,7 +1120,7 @@  discard block
 block discarded – undo
1120 1120
     */
1121 1121
     public static function string2utf8($string)
1122 1122
     {
1123
-        if(!self::isStringASCII($string)) {
1123
+        if (!self::isStringASCII($string)) {
1124 1124
             return \ForceUTF8\Encoding::toUTF8($string);
1125 1125
         }
1126 1126
         
@@ -1138,11 +1138,11 @@  discard block
 block discarded – undo
1138 1138
     */
1139 1139
     public static function isStringASCII($string)
1140 1140
     {
1141
-        if($string === '' || $string === NULL) {
1141
+        if ($string === '' || $string === NULL) {
1142 1142
             return true;
1143 1143
         }
1144 1144
         
1145
-        if(!is_string($string)) {
1145
+        if (!is_string($string)) {
1146 1146
             return false;
1147 1147
         }
1148 1148
         
@@ -1176,7 +1176,7 @@  discard block
 block discarded – undo
1176 1176
     * @param array $options
1177 1177
     * @return float
1178 1178
     */
1179
-    public static function matchString($source, $target, $options=array())
1179
+    public static function matchString($source, $target, $options = array())
1180 1180
     {
1181 1181
         $defaults = array(
1182 1182
             'maxLevenshtein' => 10,
@@ -1186,12 +1186,12 @@  discard block
 block discarded – undo
1186 1186
         $options = array_merge($defaults, $options);
1187 1187
         
1188 1188
         // avoid doing this via levenshtein
1189
-        if($source == $target) {
1189
+        if ($source == $target) {
1190 1190
             return 100;
1191 1191
         }
1192 1192
         
1193 1193
         $diff = levenshtein($source, $target);
1194
-        if($diff > $options['maxLevenshtein']) {
1194
+        if ($diff > $options['maxLevenshtein']) {
1195 1195
             return 0;
1196 1196
         }
1197 1197
         
@@ -1205,8 +1205,8 @@  discard block
 block discarded – undo
1205 1205
         
1206 1206
         $offset = 0;
1207 1207
         $keep = array();
1208
-        foreach($tokens as $token) {
1209
-            if($interval->$token > 0) {
1208
+        foreach ($tokens as $token) {
1209
+            if ($interval->$token > 0) {
1210 1210
                 $keep = array_slice($tokens, $offset);
1211 1211
                 break;
1212 1212
             }
@@ -1215,16 +1215,16 @@  discard block
 block discarded – undo
1215 1215
         }
1216 1216
         
1217 1217
         $parts = array();
1218
-        foreach($keep as $token) 
1218
+        foreach ($keep as $token) 
1219 1219
         {
1220 1220
             $value = $interval->$token;
1221 1221
             $label = '';
1222 1222
             
1223 1223
             $suffix = 'p';
1224
-            if($value == 1) { $suffix = 's'; }
1224
+            if ($value == 1) { $suffix = 's'; }
1225 1225
             $token .= $suffix;
1226 1226
             
1227
-            switch($token) {
1227
+            switch ($token) {
1228 1228
                 case 'ys': $label = t('1 year'); break;
1229 1229
                 case 'yp': $label = t('%1$s years', $value); break;
1230 1230
                 case 'ms': $label = t('1 month'); break;
@@ -1242,7 +1242,7 @@  discard block
 block discarded – undo
1242 1242
             $parts[] = $label;
1243 1243
         }
1244 1244
         
1245
-        if(count($parts) == 1) {
1245
+        if (count($parts) == 1) {
1246 1246
             return $parts[0];
1247 1247
         } 
1248 1248
         
@@ -1267,23 +1267,23 @@  discard block
 block discarded – undo
1267 1267
     * @param string $unit
1268 1268
     * @return integer
1269 1269
     */
1270
-    public static function interval2total(\DateInterval $interval, $unit=self::INTERVAL_SECONDS)
1270
+    public static function interval2total(\DateInterval $interval, $unit = self::INTERVAL_SECONDS)
1271 1271
     {
1272 1272
         $total = $interval->format('%a');
1273 1273
         if ($unit == self::INTERVAL_DAYS) {
1274 1274
             return $total;
1275 1275
         }
1276 1276
 
1277
-        $total = ($total * 24) + ($interval->h );
1277
+        $total = ($total * 24) + ($interval->h);
1278 1278
         if ($unit == self::INTERVAL_HOURS) {
1279 1279
             return $total;
1280 1280
         }
1281 1281
     
1282
-        $total = ($total * 60) + ($interval->i );
1282
+        $total = ($total * 60) + ($interval->i);
1283 1283
         if ($unit == self::INTERVAL_MINUTES)
1284 1284
             return $total;
1285 1285
 
1286
-        $total = ($total * 60) + ($interval->s );
1286
+        $total = ($total * 60) + ($interval->s);
1287 1287
         if ($unit == self::INTERVAL_SECONDS)
1288 1288
             return $total;
1289 1289
         
@@ -1311,13 +1311,13 @@  discard block
 block discarded – undo
1311 1311
     * @param string $short
1312 1312
     * @return string|NULL
1313 1313
     */
1314
-    public static function date2dayName(\DateTime $date, $short=false)
1314
+    public static function date2dayName(\DateTime $date, $short = false)
1315 1315
     {
1316 1316
         $day = $date->format('l');
1317 1317
         $invariant = self::getDayNamesInvariant();
1318 1318
         
1319 1319
         $idx = array_search($day, $invariant);
1320
-        if($idx !== false) {
1320
+        if ($idx !== false) {
1321 1321
             $localized = self::getDayNames($short);
1322 1322
             return $localized[$idx];
1323 1323
         }
@@ -1340,10 +1340,10 @@  discard block
 block discarded – undo
1340 1340
     * @param string $short
1341 1341
     * @return string[]
1342 1342
     */
1343
-    public static function getDayNames($short=false)
1343
+    public static function getDayNames($short = false)
1344 1344
     {
1345
-        if($short) {
1346
-            if(!isset(self::$daysShort)) {
1345
+        if ($short) {
1346
+            if (!isset(self::$daysShort)) {
1347 1347
                 self::$daysShort = array(
1348 1348
                     t('Mon'),
1349 1349
                     t('Tue'),
@@ -1358,7 +1358,7 @@  discard block
 block discarded – undo
1358 1358
             return self::$daysShort;
1359 1359
         }
1360 1360
         
1361
-        if(!isset(self::$days)) {
1361
+        if (!isset(self::$days)) {
1362 1362
             self::$days = array(
1363 1363
                 t('Monday'),
1364 1364
                 t('Tuesday'),
@@ -1383,17 +1383,17 @@  discard block
 block discarded – undo
1383 1383
      */
1384 1384
     public static function implodeWithAnd(array $list, $sep = ', ', $conjunction = null)
1385 1385
     {
1386
-        if(empty($list)) {
1386
+        if (empty($list)) {
1387 1387
             return '';
1388 1388
         }
1389 1389
         
1390
-        if(empty($conjunction)) {
1390
+        if (empty($conjunction)) {
1391 1391
             $conjunction = t('and');
1392 1392
         }
1393 1393
         
1394 1394
         $last = array_pop($list);
1395
-        if($list) {
1396
-            return implode($sep, $list) . $conjunction . ' ' . $last;
1395
+        if ($list) {
1396
+            return implode($sep, $list).$conjunction.' '.$last;
1397 1397
         }
1398 1398
         
1399 1399
         return $last;
@@ -1410,7 +1410,7 @@  discard block
 block discarded – undo
1410 1410
     public static function string2array(string $string) : array
1411 1411
     {
1412 1412
         $result = preg_split('//u', $string, null, PREG_SPLIT_NO_EMPTY);
1413
-        if($result !== false) {
1413
+        if ($result !== false) {
1414 1414
             return $result;
1415 1415
         }
1416 1416
         
@@ -1425,12 +1425,12 @@  discard block
 block discarded – undo
1425 1425
     */
1426 1426
     public static function isStringHTML(string $string) : bool
1427 1427
     {
1428
-        if(preg_match('%<[a-z/][\s\S]*>%siU', $string)) {
1428
+        if (preg_match('%<[a-z/][\s\S]*>%siU', $string)) {
1429 1429
             return true;
1430 1430
         }
1431 1431
         
1432 1432
         $decoded = html_entity_decode($string);
1433
-        if($decoded !== $string) {
1433
+        if ($decoded !== $string) {
1434 1434
             return true;
1435 1435
         }
1436 1436
         
@@ -1567,7 +1567,7 @@  discard block
 block discarded – undo
1567 1567
         // extract parameter names from the query string
1568 1568
         $result = array();
1569 1569
         preg_match_all('/&?([^&]+)=.*/sixU', $queryString, $result, PREG_PATTERN_ORDER);
1570
-        if(isset($result[1])) {
1570
+        if (isset($result[1])) {
1571 1571
             $paramNames = $result[1];
1572 1572
         }
1573 1573
         
@@ -1590,11 +1590,11 @@  discard block
 block discarded – undo
1590 1590
         // possible naming conflicts like having both parameters "foo.bar" 
1591 1591
         // and "foo_bar" in the query string: since "foo.bar" would be converted
1592 1592
         // to "foo_bar", one of the two would be replaced.
1593
-        if($fixRequired) 
1593
+        if ($fixRequired) 
1594 1594
         {
1595 1595
             $counter = 1;
1596 1596
             $placeholders = array();
1597
-            foreach($paramNames as $paramName)
1597
+            foreach ($paramNames as $paramName)
1598 1598
             {
1599 1599
                  // create a unique placeholder name
1600 1600
                  $placeholder = '__PLACEHOLDER'.$counter.'__';
@@ -1624,13 +1624,13 @@  discard block
 block discarded – undo
1624 1624
         parse_str($queryString, $parsed);
1625 1625
         
1626 1626
         // do any of the parameter names need to be fixed?
1627
-        if(!$fixRequired) {
1627
+        if (!$fixRequired) {
1628 1628
             return $parsed;
1629 1629
         }
1630 1630
         
1631 1631
         $keep = array();
1632 1632
         
1633
-        foreach($parsed as $name => $value)
1633
+        foreach ($parsed as $name => $value)
1634 1634
         {
1635 1635
              $keep[$table[$name]] = $value;
1636 1636
         }
@@ -1649,14 +1649,14 @@  discard block
 block discarded – undo
1649 1649
     * @param bool $caseInsensitive
1650 1650
     * @return ConvertHelper_StringMatch[]
1651 1651
     */
1652
-    public static function findString(string $needle, string $haystack, bool $caseInsensitive=false)
1652
+    public static function findString(string $needle, string $haystack, bool $caseInsensitive = false)
1653 1653
     {
1654
-        if($needle === '') {
1654
+        if ($needle === '') {
1655 1655
             return array();
1656 1656
         }
1657 1657
         
1658 1658
         $function = 'mb_strpos';
1659
-        if($caseInsensitive) {
1659
+        if ($caseInsensitive) {
1660 1660
             $function = 'mb_stripos';
1661 1661
         }
1662 1662
         
@@ -1664,7 +1664,7 @@  discard block
 block discarded – undo
1664 1664
         $positions = array();
1665 1665
         $length = mb_strlen($needle);
1666 1666
         
1667
-        while( ($pos = $function($haystack, $needle, $pos)) !== false) 
1667
+        while (($pos = $function($haystack, $needle, $pos)) !== false) 
1668 1668
         {
1669 1669
             $match = mb_substr($haystack, $pos, $length);
1670 1670
             $positions[] = new ConvertHelper_StringMatch($pos, $match);
@@ -1684,7 +1684,7 @@  discard block
 block discarded – undo
1684 1684
     */
1685 1685
     public static function explodeTrim(string $delimiter, string $string) : array
1686 1686
     {
1687
-        if(empty($string) || empty($delimiter)) {
1687
+        if (empty($string) || empty($delimiter)) {
1688 1688
             return array();
1689 1689
         }
1690 1690
         
@@ -1692,8 +1692,8 @@  discard block
 block discarded – undo
1692 1692
         $tokens = array_map('trim', $tokens);
1693 1693
         
1694 1694
         $keep = array();
1695
-        foreach($tokens as $token) {
1696
-            if($token !== '') {
1695
+        foreach ($tokens as $token) {
1696
+            if ($token !== '') {
1697 1697
                 $keep[] = $token;
1698 1698
             }
1699 1699
         }
@@ -1711,11 +1711,11 @@  discard block
 block discarded – undo
1711 1711
     */
1712 1712
     public static function detectEOLCharacter(string $subjectString) : ?ConvertHelper_EOL
1713 1713
     {
1714
-        if(empty($subjectString)) {
1714
+        if (empty($subjectString)) {
1715 1715
             return null;
1716 1716
         }
1717 1717
         
1718
-        if(!isset(self::$eolChars))
1718
+        if (!isset(self::$eolChars))
1719 1719
         {
1720 1720
             $cr = chr((int)hexdec('0d'));
1721 1721
             $lf = chr((int)hexdec('0a'));
@@ -1746,18 +1746,18 @@  discard block
 block discarded – undo
1746 1746
         
1747 1747
         $max = 0;
1748 1748
         $results = array();
1749
-        foreach(self::$eolChars as $def) 
1749
+        foreach (self::$eolChars as $def) 
1750 1750
         {
1751 1751
             $amount = substr_count($subjectString, $def['char']);
1752 1752
             
1753
-            if($amount > $max)
1753
+            if ($amount > $max)
1754 1754
             {
1755 1755
                 $max = $amount;
1756 1756
                 $results[] = $def;
1757 1757
             }
1758 1758
         }
1759 1759
         
1760
-        if(empty($results)) {
1760
+        if (empty($results)) {
1761 1761
             return null;
1762 1762
         }
1763 1763
         
@@ -1777,9 +1777,9 @@  discard block
 block discarded – undo
1777 1777
     */
1778 1778
     public static function arrayRemoveKeys(array &$array, array $keys) : void
1779 1779
     {
1780
-        foreach($keys as $key) 
1780
+        foreach ($keys as $key) 
1781 1781
         {
1782
-            if(array_key_exists($key, $array)) {
1782
+            if (array_key_exists($key, $array)) {
1783 1783
                 unset($array[$key]); 
1784 1784
             }
1785 1785
         }
Please login to merge, or discard this patch.