Test Failed
Push — master ( 9a4759...0f3564 )
by Sebastian
04:15 queued 59s
created
src/FileHelper.php 2 patches
Indentation   +233 added lines, -233 removed lines patch added patch discarded remove patch
@@ -73,18 +73,18 @@  discard block
 block discarded – undo
73 73
     public const ERROR_PATH_NOT_WRITABLE = 340039;
74 74
     public const ERROR_PATH_INVALID = 340040;
75 75
 
76
-   /**
77
-    * Opens a serialized file and returns the unserialized data.
78
-    *
79
-    * @param string $file
80
-    * @throws FileHelper_Exception
81
-    * @return array<int|string,mixed>
82
-    * @see SerializedFile::parse()
83
-    * 
84
-    * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST
85
-    * @see FileHelper::ERROR_SERIALIZED_FILE_CANNOT_BE_READ
86
-    * @see FileHelper::ERROR_SERIALIZED_FILE_UNSERIALZE_FAILED
87
-    */
76
+    /**
77
+     * Opens a serialized file and returns the unserialized data.
78
+     *
79
+     * @param string $file
80
+     * @throws FileHelper_Exception
81
+     * @return array<int|string,mixed>
82
+     * @see SerializedFile::parse()
83
+     * 
84
+     * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST
85
+     * @see FileHelper::ERROR_SERIALIZED_FILE_CANNOT_BE_READ
86
+     * @see FileHelper::ERROR_SERIALIZED_FILE_UNSERIALZE_FAILED
87
+     */
88 88
     public static function parseSerializedFile(string $file) : array
89 89
     {
90 90
         return SerializedFile::factory(self::getFileInfo($file))
@@ -104,13 +104,13 @@  discard block
 block discarded – undo
104 104
         return FolderTree::delete($rootFolder);
105 105
     }
106 106
     
107
-   /**
108
-    * Create a folder, if it does not exist yet.
109
-    *  
110
-    * @param string|PathInfoInterface $path
111
-    * @throws FileHelper_Exception
112
-    * @see FileHelper::ERROR_CANNOT_CREATE_FOLDER
113
-    */
107
+    /**
108
+     * Create a folder, if it does not exist yet.
109
+     *  
110
+     * @param string|PathInfoInterface $path
111
+     * @throws FileHelper_Exception
112
+     * @see FileHelper::ERROR_CANNOT_CREATE_FOLDER
113
+     */
114 114
     public static function createFolder($path) : FolderInfo
115 115
     {
116 116
         return self::getFolderInfo($path)->create();
@@ -138,36 +138,36 @@  discard block
 block discarded – undo
138 138
         FolderTree::copy($source, $target);
139 139
     }
140 140
     
141
-   /**
142
-    * Copies a file to the target location. Includes checks
143
-    * for most error sources, like the source file not being
144
-    * readable. Automatically creates the target folder if it
145
-    * does not exist yet.
146
-    * 
147
-    * @param string $sourcePath
148
-    * @param string $targetPath
149
-    * @throws FileHelper_Exception
150
-    * 
151
-    * @see FileHelper::ERROR_CANNOT_CREATE_FOLDER
152
-    * @see FileHelper::ERROR_SOURCE_FILE_NOT_FOUND
153
-    * @see FileHelper::ERROR_SOURCE_FILE_NOT_READABLE
154
-    * @see FileHelper::ERROR_TARGET_COPY_FOLDER_NOT_WRITABLE
155
-    * @see FileHelper::ERROR_CANNOT_COPY_FILE
156
-    */
141
+    /**
142
+     * Copies a file to the target location. Includes checks
143
+     * for most error sources, like the source file not being
144
+     * readable. Automatically creates the target folder if it
145
+     * does not exist yet.
146
+     * 
147
+     * @param string $sourcePath
148
+     * @param string $targetPath
149
+     * @throws FileHelper_Exception
150
+     * 
151
+     * @see FileHelper::ERROR_CANNOT_CREATE_FOLDER
152
+     * @see FileHelper::ERROR_SOURCE_FILE_NOT_FOUND
153
+     * @see FileHelper::ERROR_SOURCE_FILE_NOT_READABLE
154
+     * @see FileHelper::ERROR_TARGET_COPY_FOLDER_NOT_WRITABLE
155
+     * @see FileHelper::ERROR_CANNOT_COPY_FILE
156
+     */
157 157
     public static function copyFile(string $sourcePath, string $targetPath) : void
158 158
     {
159 159
         self::getFileInfo($sourcePath)->copyTo($targetPath);
160 160
     }
161 161
     
162
-   /**
163
-    * Deletes the target file. Ignored if it cannot be found,
164
-    * and throws an exception if it fails.
165
-    * 
166
-    * @param string $filePath
167
-    * @throws FileHelper_Exception
168
-    * 
169
-    * @see FileHelper::ERROR_CANNOT_DELETE_FILE
170
-    */
162
+    /**
163
+     * Deletes the target file. Ignored if it cannot be found,
164
+     * and throws an exception if it fails.
165
+     * 
166
+     * @param string $filePath
167
+     * @throws FileHelper_Exception
168
+     * 
169
+     * @see FileHelper::ERROR_CANNOT_DELETE_FILE
170
+     */
171 171
     public static function deleteFile(string $filePath) : void
172 172
     {
173 173
         self::getFileInfo($filePath)->delete();
@@ -272,46 +272,46 @@  discard block
 block discarded – undo
272 272
             ->download();
273 273
     }
274 274
     
275
-   /**
276
-    * Verifies whether the target file is a PHP file. The path
277
-    * to the file can be a path to a file as a string, or a 
278
-    * DirectoryIterator object instance.
279
-    * 
280
-    * @param string|DirectoryIterator $pathOrDirIterator
281
-    * @return boolean
282
-    */
275
+    /**
276
+     * Verifies whether the target file is a PHP file. The path
277
+     * to the file can be a path to a file as a string, or a 
278
+     * DirectoryIterator object instance.
279
+     * 
280
+     * @param string|DirectoryIterator $pathOrDirIterator
281
+     * @return boolean
282
+     */
283 283
     public static function isPHPFile($pathOrDirIterator) : bool
284 284
     {
285
-    	return self::getExtension($pathOrDirIterator) === 'php';
285
+        return self::getExtension($pathOrDirIterator) === 'php';
286 286
     }
287 287
     
288
-   /**
289
-    * Retrieves the extension of the specified file. Can be a path
290
-    * to a file as a string, or a DirectoryIterator object instance.
291
-    *
292
-    * NOTE: A folder will return an empty string.
293
-    * 
294
-    * @param string|DirectoryIterator $pathOrDirIterator
295
-    * @param bool $lowercase
296
-    * @return string
297
-    */
288
+    /**
289
+     * Retrieves the extension of the specified file. Can be a path
290
+     * to a file as a string, or a DirectoryIterator object instance.
291
+     *
292
+     * NOTE: A folder will return an empty string.
293
+     * 
294
+     * @param string|DirectoryIterator $pathOrDirIterator
295
+     * @param bool $lowercase
296
+     * @return string
297
+     */
298 298
     public static function getExtension($pathOrDirIterator, bool $lowercase = true) : string
299 299
     {
300 300
         return self::getPathInfo($pathOrDirIterator)->getExtension();
301 301
     }
302 302
     
303
-   /**
304
-    * Retrieves the file name from a path, with or without extension.
305
-    * The path to the file can be a string, or a DirectoryIterator object
306
-    * instance.
307
-    * 
308
-    * In case of folders, behaves like the "pathinfo" function: returns
309
-    * the name of the folder.
310
-    * 
311
-    * @param string|DirectoryIterator $pathOrDirIterator
312
-    * @param bool $extension
313
-    * @return string
314
-    */
303
+    /**
304
+     * Retrieves the file name from a path, with or without extension.
305
+     * The path to the file can be a string, or a DirectoryIterator object
306
+     * instance.
307
+     * 
308
+     * In case of folders, behaves like the "pathinfo" function: returns
309
+     * the name of the folder.
310
+     * 
311
+     * @param string|DirectoryIterator $pathOrDirIterator
312
+     * @param bool $extension
313
+     * @return string
314
+     */
315 315
     public static function getFilename($pathOrDirIterator, bool $extension = true) : string
316 316
     {
317 317
         $info = self::getPathInfo($pathOrDirIterator);
@@ -345,16 +345,16 @@  discard block
 block discarded – undo
345 345
             ->parse();
346 346
     }
347 347
     
348
-   /**
349
-    * Corrects common formatting mistakes when users enter
350
-    * file names, like too many spaces, dots and the like.
351
-    * 
352
-    * NOTE: if the file name contains a path, the path is
353
-    * stripped, leaving only the file name.
354
-    * 
355
-    * @param string $name
356
-    * @return string
357
-    */
348
+    /**
349
+     * Corrects common formatting mistakes when users enter
350
+     * file names, like too many spaces, dots and the like.
351
+     * 
352
+     * NOTE: if the file name contains a path, the path is
353
+     * stripped, leaving only the file name.
354
+     * 
355
+     * @param string $name
356
+     * @return string
357
+     */
358 358
     public static function fixFileName(string $name) : string
359 359
     {
360 360
         return NameFixer::fixName($name);
@@ -414,23 +414,23 @@  discard block
 block discarded – undo
414 414
         return self::findFiles($targetFolder, array('php'), $options);
415 415
     }
416 416
     
417
-   /**
418
-    * Finds files according to the specified options.
419
-    * 
420
-    * NOTE: This method only exists for backwards compatibility.
421
-    * Use the {@see FileHelper::createFileFinder()} method instead,
422
-    * which offers an object-oriented interface that is much easier
423
-    * to use.
424
-    *  
425
-    * @param string|PathInfoInterface|DirectoryIterator $targetFolder
426
-    * @param string[] $extensions
427
-    * @param array<string,mixed> $options
428
-    * @throws FileHelper_Exception
429
-    * @return string[]
430
-    *
431
-    * @see FileHelper::createFileFinder()
432
-    * @deprecated Use the file finder instead.
433
-    */
417
+    /**
418
+     * Finds files according to the specified options.
419
+     * 
420
+     * NOTE: This method only exists for backwards compatibility.
421
+     * Use the {@see FileHelper::createFileFinder()} method instead,
422
+     * which offers an object-oriented interface that is much easier
423
+     * to use.
424
+     *  
425
+     * @param string|PathInfoInterface|DirectoryIterator $targetFolder
426
+     * @param string[] $extensions
427
+     * @param array<string,mixed> $options
428
+     * @throws FileHelper_Exception
429
+     * @return string[]
430
+     *
431
+     * @see FileHelper::createFileFinder()
432
+     * @deprecated Use the file finder instead.
433
+     */
434 434
     public static function findFiles($targetFolder, array $extensions=array(), array $options=array()) : array
435 435
     {
436 436
         $finder = self::createFileFinder($targetFolder);
@@ -460,14 +460,14 @@  discard block
 block discarded – undo
460 460
         return $finder->getAll();
461 461
     }
462 462
 
463
-   /**
464
-    * Removes the extension from the specified path or file name,
465
-    * if any, and returns the name without the extension.
466
-    * 
467
-    * @param string $filename
468
-    * @param bool $keepPath Whether to keep the path component, if any. Default PHP pathinfo behavior is not to.
469
-    * @return string
470
-    */
463
+    /**
464
+     * Removes the extension from the specified path or file name,
465
+     * if any, and returns the name without the extension.
466
+     * 
467
+     * @param string $filename
468
+     * @param bool $keepPath Whether to keep the path component, if any. Default PHP pathinfo behavior is not to.
469
+     * @return string
470
+     */
471 471
     public static function removeExtension(string $filename, bool $keepPath=false) : string
472 472
     {
473 473
         return self::getFileInfo($filename)->removeExtension($keepPath);
@@ -488,49 +488,49 @@  discard block
 block discarded – undo
488 488
         return self::$unicodeHandling;
489 489
     }
490 490
     
491
-   /**
492
-    * Normalizes the slash style in a file or folder path,
493
-    * by replacing any anti-slashes with forward slashes.
494
-    * 
495
-    * @param string $path
496
-    * @return string
497
-    */
491
+    /**
492
+     * Normalizes the slash style in a file or folder path,
493
+     * by replacing any anti-slashes with forward slashes.
494
+     * 
495
+     * @param string $path
496
+     * @return string
497
+     */
498 498
     public static function normalizePath(string $path) : string
499 499
     {
500 500
         return str_replace(array('\\', '//'), array('/', '/'), $path);
501 501
     }
502 502
     
503
-   /**
504
-    * Saves the specified data to a file, JSON encoded.
505
-    * 
506
-    * @param mixed $data
507
-    * @param string $file
508
-    * @param bool $pretty
509
-    * @throws FileHelper_Exception
510
-    * 
511
-    * @see FileHelper::ERROR_JSON_ENCODE_ERROR
512
-    * @see FileHelper::ERROR_SAVE_FOLDER_NOT_WRITABLE
513
-    * @see FileHelper::ERROR_SAVE_FILE_NOT_WRITABLE
514
-    * @see FileHelper::ERROR_SAVE_FILE_WRITE_FAILED
515
-    */
503
+    /**
504
+     * Saves the specified data to a file, JSON encoded.
505
+     * 
506
+     * @param mixed $data
507
+     * @param string $file
508
+     * @param bool $pretty
509
+     * @throws FileHelper_Exception
510
+     * 
511
+     * @see FileHelper::ERROR_JSON_ENCODE_ERROR
512
+     * @see FileHelper::ERROR_SAVE_FOLDER_NOT_WRITABLE
513
+     * @see FileHelper::ERROR_SAVE_FILE_NOT_WRITABLE
514
+     * @see FileHelper::ERROR_SAVE_FILE_WRITE_FAILED
515
+     */
516 516
     public static function saveAsJSON($data, string $file, bool $pretty=false) : void
517 517
     {
518 518
         JSONFile::factory(self::getFileInfo($file))
519 519
             ->putData($data, $pretty);
520 520
     }
521 521
    
522
-   /**
523
-    * Saves the specified content to the target file, creating
524
-    * the file and the folder as necessary.
525
-    * 
526
-    * @param string $filePath
527
-    * @param string $content
528
-    * @throws FileHelper_Exception
529
-    * 
530
-    * @see FileHelper::ERROR_SAVE_FOLDER_NOT_WRITABLE
531
-    * @see FileHelper::ERROR_SAVE_FILE_NOT_WRITABLE
532
-    * @see FileHelper::ERROR_SAVE_FILE_WRITE_FAILED
533
-    */
522
+    /**
523
+     * Saves the specified content to the target file, creating
524
+     * the file and the folder as necessary.
525
+     * 
526
+     * @param string $filePath
527
+     * @param string $content
528
+     * @throws FileHelper_Exception
529
+     * 
530
+     * @see FileHelper::ERROR_SAVE_FOLDER_NOT_WRITABLE
531
+     * @see FileHelper::ERROR_SAVE_FILE_NOT_WRITABLE
532
+     * @see FileHelper::ERROR_SAVE_FILE_WRITE_FAILED
533
+     */
534 534
     public static function saveFile(string $filePath, string $content='') : void
535 535
     {
536 536
         self::getFileInfo($filePath)->putContents($content);
@@ -595,14 +595,14 @@  discard block
 block discarded – undo
595 595
         return $output;
596 596
     }
597 597
     
598
-   /**
599
-    * Retrieves the last modified date for the specified file or folder.
600
-    * 
601
-    * Note: If the target does not exist, returns null. 
602
-    * 
603
-    * @param string $path
604
-    * @return DateTime|NULL
605
-    */
598
+    /**
599
+     * Retrieves the last modified date for the specified file or folder.
600
+     * 
601
+     * Note: If the target does not exist, returns null. 
602
+     * 
603
+     * @param string $path
604
+     * @return DateTime|NULL
605
+     */
606 606
     public static function getModifiedDate(string $path) : ?DateTime
607 607
     {
608 608
         $time = filemtime($path);
@@ -642,70 +642,70 @@  discard block
 block discarded – undo
642 642
             ->getPaths();
643 643
     }
644 644
 
645
-   /**
646
-    * Retrieves the maximum allowed upload file size, in bytes.
647
-    * Takes into account the PHP ini settings <code>post_max_size</code>
648
-    * and <code>upload_max_filesize</code>. Since these cannot
649
-    * be modified at runtime, they are the hard limits for uploads.
650
-    * 
651
-    * NOTE: Based on binary values, where 1KB = 1024 Bytes.
652
-    * 
653
-    * @return int Will return <code>-1</code> if no limit.
654
-    */
645
+    /**
646
+     * Retrieves the maximum allowed upload file size, in bytes.
647
+     * Takes into account the PHP ini settings <code>post_max_size</code>
648
+     * and <code>upload_max_filesize</code>. Since these cannot
649
+     * be modified at runtime, they are the hard limits for uploads.
650
+     * 
651
+     * NOTE: Based on binary values, where 1KB = 1024 Bytes.
652
+     * 
653
+     * @return int Will return <code>-1</code> if no limit.
654
+     */
655 655
     public static function getMaxUploadFilesize() : int
656 656
     {
657 657
         return UploadFileSizeInfo::getFileSize();
658 658
     }
659 659
    
660
-   /**
661
-    * Makes a path relative using a folder depth: will reduce the
662
-    * length of the path so that only the amount of folders defined
663
-    * in the <code>$depth</code> attribute are shown below the actual
664
-    * folder or file in the path.
665
-    *  
666
-    * @param string  $path The absolute or relative path
667
-    * @param int $depth The folder depth to reduce the path to
668
-    * @return string
669
-    */
660
+    /**
661
+     * Makes a path relative using a folder depth: will reduce the
662
+     * length of the path so that only the amount of folders defined
663
+     * in the <code>$depth</code> attribute are shown below the actual
664
+     * folder or file in the path.
665
+     *  
666
+     * @param string  $path The absolute or relative path
667
+     * @param int $depth The folder depth to reduce the path to
668
+     * @return string
669
+     */
670 670
     public static function relativizePathByDepth(string $path, int $depth=2) : string
671 671
     {
672 672
         return PathRelativizer::relativizeByDepth($path, $depth);
673 673
     }
674 674
     
675
-   /**
676
-    * Makes the specified path relative to another path,
677
-    * by removing one from the other if found. Also 
678
-    * normalizes the path to use forward slashes. 
679
-    * 
680
-    * Example:
681
-    * 
682
-    * <pre>
683
-    * relativizePath('c:\some\folder\to\file.txt', 'c:\some\folder');
684
-    * </pre>
685
-    * 
686
-    * Result: <code>to/file.txt</code>
687
-    * 
688
-    * @param string $path
689
-    * @param string $relativeTo
690
-    * @return string
691
-    */
675
+    /**
676
+     * Makes the specified path relative to another path,
677
+     * by removing one from the other if found. Also 
678
+     * normalizes the path to use forward slashes. 
679
+     * 
680
+     * Example:
681
+     * 
682
+     * <pre>
683
+     * relativizePath('c:\some\folder\to\file.txt', 'c:\some\folder');
684
+     * </pre>
685
+     * 
686
+     * Result: <code>to/file.txt</code>
687
+     * 
688
+     * @param string $path
689
+     * @param string $relativeTo
690
+     * @return string
691
+     */
692 692
     public static function relativizePath(string $path, string $relativeTo) : string
693 693
     {
694 694
         return PathRelativizer::relativize($path, $relativeTo);
695 695
     }
696 696
     
697
-   /**
698
-    * Checks that the target file exists, and throws an exception
699
-    * if it does not. 
700
-    * 
701
-    * @param string|DirectoryIterator $path
702
-    * @param int|NULL $errorCode Optional custom error code
703
-    * @throws FileHelper_Exception
704
-    * @return string The real path to the file
705
-    * 
706
-    * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST
707
-    * @see FileHelper::ERROR_REAL_PATH_NOT_FOUND
708
-    */
697
+    /**
698
+     * Checks that the target file exists, and throws an exception
699
+     * if it does not. 
700
+     * 
701
+     * @param string|DirectoryIterator $path
702
+     * @param int|NULL $errorCode Optional custom error code
703
+     * @throws FileHelper_Exception
704
+     * @return string The real path to the file
705
+     * 
706
+     * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST
707
+     * @see FileHelper::ERROR_REAL_PATH_NOT_FOUND
708
+     */
709 709
     public static function requireFileExists($path, ?int $errorCode=null) : string
710 710
     {
711 711
         return self::getPathInfo($path)
@@ -728,18 +728,18 @@  discard block
 block discarded – undo
728 728
             ->getPath();
729 729
     }
730 730
     
731
-   /**
732
-    * Reads a specific line number from the target file and returns its
733
-    * contents, if the file has such a line. Does so with little memory
734
-    * usage, as the file is not read entirely into memory.
735
-    * 
736
-    * @param string $path
737
-    * @param int $lineNumber Note: 1-based; the first line is number 1.
738
-    * @return string|NULL Will return null if the requested line does not exist.
739
-    * @throws FileHelper_Exception
740
-    * 
741
-    * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST
742
-    */
731
+    /**
732
+     * Reads a specific line number from the target file and returns its
733
+     * contents, if the file has such a line. Does so with little memory
734
+     * usage, as the file is not read entirely into memory.
735
+     * 
736
+     * @param string $path
737
+     * @param int $lineNumber Note: 1-based; the first line is number 1.
738
+     * @return string|NULL Will return null if the requested line does not exist.
739
+     * @throws FileHelper_Exception
740
+     * 
741
+     * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST
742
+     */
743 743
     public static function getLineFromFile(string $path, int $lineNumber) : ?string
744 744
     {
745 745
         return self::getFileInfo($path)
@@ -816,33 +816,33 @@  discard block
 block discarded – undo
816 816
             ->getLines($amount);
817 817
     }
818 818
     
819
-   /**
820
-    * Reads all content from a file.
821
-    * 
822
-    * @param string $filePath
823
-    * @throws FileHelper_Exception
824
-    * @return string
825
-    * 
826
-    * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST
827
-    * @see FileHelper::ERROR_CANNOT_READ_FILE_CONTENTS
828
-    */
819
+    /**
820
+     * Reads all content from a file.
821
+     * 
822
+     * @param string $filePath
823
+     * @throws FileHelper_Exception
824
+     * @return string
825
+     * 
826
+     * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST
827
+     * @see FileHelper::ERROR_CANNOT_READ_FILE_CONTENTS
828
+     */
829 829
     public static function readContents(string $filePath) : string
830 830
     {
831 831
         return self::getFileInfo($filePath)->getContents();
832 832
     }
833 833
 
834
-   /**
835
-    * Ensures that the target path exists on disk, and is a folder.
836
-    * 
837
-    * @param string $path
838
-    * @return string The real path, with normalized slashes.
839
-    * @throws FileHelper_Exception
840
-    * 
841
-    * @see FileHelper::normalizePath()
842
-    * 
843
-    * @see FileHelper::ERROR_FOLDER_DOES_NOT_EXIST
844
-    * @see FileHelper::ERROR_PATH_IS_NOT_A_FOLDER
845
-    */
834
+    /**
835
+     * Ensures that the target path exists on disk, and is a folder.
836
+     * 
837
+     * @param string $path
838
+     * @return string The real path, with normalized slashes.
839
+     * @throws FileHelper_Exception
840
+     * 
841
+     * @see FileHelper::normalizePath()
842
+     * 
843
+     * @see FileHelper::ERROR_FOLDER_DOES_NOT_EXIST
844
+     * @see FileHelper::ERROR_PATH_IS_NOT_A_FOLDER
845
+     */
846 846
     public static function requireFolderExists(string $path) : string
847 847
     {
848 848
         return self::getFolderInfo($path)
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
     public static function detectMimeType(string $fileName) : ?string
208 208
     {
209 209
         $ext = self::getExtension($fileName);
210
-        if(empty($ext)) {
210
+        if (empty($ext)) {
211 211
             return null;
212 212
         }
213 213
 
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
      * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST
248 248
      * @see FileHelper::ERROR_UNKNOWN_FILE_MIME_TYPE
249 249
      */
250
-    public static function sendFile(string $filePath, ?string $fileName = null, bool $asAttachment=true) : void
250
+    public static function sendFile(string $filePath, ?string $fileName = null, bool $asAttachment = true) : void
251 251
     {
252 252
         self::getFileInfo($filePath)->getDownloader()->send($fileName, $asAttachment);
253 253
     }
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
      * @throws FileHelper_Exception
265 265
      * @see FileHelper::ERROR_CANNOT_OPEN_URL
266 266
      */
267
-    public static function downloadFile(string $url, int $timeout=0, bool $SSLEnabled=false) : string
267
+    public static function downloadFile(string $url, int $timeout = 0, bool $SSLEnabled = false) : string
268 268
     {
269 269
         return FileDownloader::factory($url)
270 270
             ->setTimeout($timeout)
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
     {
317 317
         $info = self::getPathInfo($pathOrDirIterator);
318 318
 
319
-        if($extension === true || $info instanceof FolderInfo)
319
+        if ($extension === true || $info instanceof FolderInfo)
320 320
         {
321 321
             return $info->getName();
322 322
         }
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
      * @see FileHelper::ERROR_CANNOT_FIND_JSON_FILE
338 338
      * @see FileHelper::ERROR_CANNOT_DECODE_JSON_FILE
339 339
      */
340
-    public static function parseJSONFile(string $file, string $targetEncoding='', $sourceEncoding=null) : array
340
+    public static function parseJSONFile(string $file, string $targetEncoding = '', $sourceEncoding = null) : array
341 341
     {
342 342
         return JSONFile::factory(self::getFileInfo($file))
343 343
             ->setTargetEncoding($targetEncoding)
@@ -390,7 +390,7 @@  discard block
 block discarded – undo
390 390
      * @throws FileHelper_Exception
391 391
      * @see FileHelper::createFileFinder()
392 392
      */
393
-    public static function findHTMLFiles(string $targetFolder, array $options=array()) : array
393
+    public static function findHTMLFiles(string $targetFolder, array $options = array()) : array
394 394
     {
395 395
         return self::findFiles($targetFolder, array('html'), $options);
396 396
     }
@@ -409,7 +409,7 @@  discard block
 block discarded – undo
409 409
      * @throws FileHelper_Exception
410 410
      * @see FileHelper::createFileFinder()
411 411
      */
412
-    public static function findPHPFiles(string $targetFolder, array $options=array()) : array
412
+    public static function findPHPFiles(string $targetFolder, array $options = array()) : array
413 413
     {
414 414
         return self::findFiles($targetFolder, array('php'), $options);
415 415
     }
@@ -431,7 +431,7 @@  discard block
 block discarded – undo
431 431
     * @see FileHelper::createFileFinder()
432 432
     * @deprecated Use the file finder instead.
433 433
     */
434
-    public static function findFiles($targetFolder, array $extensions=array(), array $options=array()) : array
434
+    public static function findFiles($targetFolder, array $extensions = array(), array $options = array()) : array
435 435
     {
436 436
         $finder = self::createFileFinder($targetFolder);
437 437
 
@@ -441,16 +441,16 @@  discard block
 block discarded – undo
441 441
 
442 442
         $finder->setPathmodeStrip();
443 443
         
444
-        if(isset($options['relative-path']) && $options['relative-path'] === true) 
444
+        if (isset($options['relative-path']) && $options['relative-path'] === true) 
445 445
         {
446 446
             $finder->setPathmodeRelative();
447 447
         } 
448
-        else if(isset($options['absolute-path']) && $options['absolute-path'] === true)
448
+        else if (isset($options['absolute-path']) && $options['absolute-path'] === true)
449 449
         {
450 450
             $finder->setPathmodeAbsolute();
451 451
         }
452 452
         
453
-        if(isset($options['strip-extension'])) 
453
+        if (isset($options['strip-extension'])) 
454 454
         {
455 455
             $finder->stripExtensions();
456 456
         }
@@ -468,7 +468,7 @@  discard block
 block discarded – undo
468 468
     * @param bool $keepPath Whether to keep the path component, if any. Default PHP pathinfo behavior is not to.
469 469
     * @return string
470 470
     */
471
-    public static function removeExtension(string $filename, bool $keepPath=false) : string
471
+    public static function removeExtension(string $filename, bool $keepPath = false) : string
472 472
     {
473 473
         return self::getFileInfo($filename)->removeExtension($keepPath);
474 474
     }
@@ -480,7 +480,7 @@  discard block
 block discarded – undo
480 480
 
481 481
     public static function createUnicodeHandling() : UnicodeHandling
482 482
     {
483
-        if(!isset(self::$unicodeHandling))
483
+        if (!isset(self::$unicodeHandling))
484 484
         {
485 485
             self::$unicodeHandling = new UnicodeHandling();
486 486
         }
@@ -513,7 +513,7 @@  discard block
 block discarded – undo
513 513
     * @see FileHelper::ERROR_SAVE_FILE_NOT_WRITABLE
514 514
     * @see FileHelper::ERROR_SAVE_FILE_WRITE_FAILED
515 515
     */
516
-    public static function saveAsJSON($data, string $file, bool $pretty=false) : void
516
+    public static function saveAsJSON($data, string $file, bool $pretty = false) : void
517 517
     {
518 518
         JSONFile::factory(self::getFileInfo($file))
519 519
             ->putData($data, $pretty);
@@ -531,7 +531,7 @@  discard block
 block discarded – undo
531 531
     * @see FileHelper::ERROR_SAVE_FILE_NOT_WRITABLE
532 532
     * @see FileHelper::ERROR_SAVE_FILE_WRITE_FAILED
533 533
     */
534
-    public static function saveFile(string $filePath, string $content='') : void
534
+    public static function saveFile(string $filePath, string $content = '') : void
535 535
     {
536 536
         self::getFileInfo($filePath)->putContents($content);
537 537
     }
@@ -574,7 +574,7 @@  discard block
 block discarded – undo
574 574
      */
575 575
     public static function checkPHPFileSyntax(string $path)
576 576
     {
577
-        if(!self::canMakePHPCalls()) {
577
+        if (!self::canMakePHPCalls()) {
578 578
             return true;
579 579
         }
580 580
         
@@ -585,7 +585,7 @@  discard block
 block discarded – undo
585 585
         // when the validation is successful, the first entry
586 586
         // in the array contains the success message. When it
587 587
         // is invalid, the first entry is always empty.
588
-        if(!empty($output[0])) {
588
+        if (!empty($output[0])) {
589 589
             return true;
590 590
         }
591 591
         
@@ -606,7 +606,7 @@  discard block
 block discarded – undo
606 606
     public static function getModifiedDate(string $path) : ?DateTime
607 607
     {
608 608
         $time = filemtime($path);
609
-        if($time === false) {
609
+        if ($time === false) {
610 610
             return null;
611 611
         }
612 612
 
@@ -667,7 +667,7 @@  discard block
 block discarded – undo
667 667
     * @param int $depth The folder depth to reduce the path to
668 668
     * @return string
669 669
     */
670
-    public static function relativizePathByDepth(string $path, int $depth=2) : string
670
+    public static function relativizePathByDepth(string $path, int $depth = 2) : string
671 671
     {
672 672
         return PathRelativizer::relativizeByDepth($path, $depth);
673 673
     }
@@ -706,7 +706,7 @@  discard block
 block discarded – undo
706 706
     * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST
707 707
     * @see FileHelper::ERROR_REAL_PATH_NOT_FOUND
708 708
     */
709
-    public static function requireFileExists($path, ?int $errorCode=null) : string
709
+    public static function requireFileExists($path, ?int $errorCode = null) : string
710 710
     {
711 711
         return self::getPathInfo($path)
712 712
             ->requireIsFile()
@@ -720,7 +720,7 @@  discard block
 block discarded – undo
720 720
      * @return string
721 721
      * @throws FileHelper_Exception
722 722
      */
723
-    public static function requireFileReadable(string $path, ?int $errorCode=null) : string
723
+    public static function requireFileReadable(string $path, ?int $errorCode = null) : string
724 724
     {
725 725
         return self::getPathInfo($path)
726 726
             ->requireIsFile()
@@ -809,7 +809,7 @@  discard block
 block discarded – undo
809 809
      * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST
810 810
      * @see FileHelper::ERROR_CANNOT_OPEN_FILE_TO_READ_LINES
811 811
      */
812
-    public static function readLines(string $filePath, int $amount=0) : array
812
+    public static function readLines(string $filePath, int $amount = 0) : array
813 813
     {
814 814
         return self::getFileInfo($filePath)
815 815
             ->getLineReader()
@@ -859,7 +859,7 @@  discard block
 block discarded – undo
859 859
      *
860 860
      * @throws FileHelper_Exception
861 861
      */
862
-    public static function createPathsReducer(array $paths=array()) : PathsReducer
862
+    public static function createPathsReducer(array $paths = array()) : PathsReducer
863 863
     {
864 864
         return new PathsReducer($paths);
865 865
     }
Please login to merge, or discard this patch.
src/AttributeCollection.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
      */
68 68
     public function setAttributes(array $attributes) : AttributeCollection
69 69
     {
70
-        foreach($attributes as $name => $value)
70
+        foreach ($attributes as $name => $value)
71 71
         {
72 72
             $this->attr($name, $value);
73 73
         }
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
         return $this;
76 76
     }
77 77
 
78
-    public function getAttribute(string $name, string $default='') : string
78
+    public function getAttribute(string $name, string $default = '') : string
79 79
     {
80 80
         return $this->attributes[$name] ?? $default;
81 81
     }
@@ -84,14 +84,14 @@  discard block
 block discarded – undo
84 84
      * @param array<string,string|number|bool|NULL|Interface_Stringable|StringBuilder_Interface> $attributes
85 85
      * @return AttributeCollection
86 86
      */
87
-    public static function create(array $attributes=array()) : AttributeCollection
87
+    public static function create(array $attributes = array()) : AttributeCollection
88 88
     {
89 89
         return new AttributeCollection($attributes);
90 90
     }
91 91
 
92
-    public function prop(string $name, bool $enabled=true) : AttributeCollection
92
+    public function prop(string $name, bool $enabled = true) : AttributeCollection
93 93
     {
94
-        if($enabled)
94
+        if ($enabled)
95 95
         {
96 96
             return $this->attr($name, $name);
97 97
         }
@@ -108,18 +108,18 @@  discard block
 block discarded – undo
108 108
     {
109 109
         $string = Filtering::value2string($value);
110 110
 
111
-        if($name === 'class')
111
+        if ($name === 'class')
112 112
         {
113 113
             return $this->addClasses(ConvertHelper::explodeTrim(' ', $string));
114 114
         }
115 115
 
116
-        if($name === 'style')
116
+        if ($name === 'style')
117 117
         {
118 118
             $this->styles->parseStylesString($string);
119 119
             return $this;
120 120
         }
121 121
 
122
-        if($string !== '')
122
+        if ($string !== '')
123 123
         {
124 124
             $this->attributes[$name] = $string;
125 125
         }
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
     {
139 139
         $this->attr($name, $value);
140 140
 
141
-        if(isset($this->attributes[$name]))
141
+        if (isset($this->attributes[$name]))
142 142
         {
143 143
             $this->attributes[$name] = Filtering::quotes($this->attributes[$name]);
144 144
         }
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 
154 154
     public function remove(string $name) : AttributeCollection
155 155
     {
156
-        if(isset($this->attributes[$name]))
156
+        if (isset($this->attributes[$name]))
157 157
         {
158 158
             unset($this->attributes[$name]);
159 159
         }
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
 
176 176
     private function getRenderer() : AttributesRenderer
177 177
     {
178
-        if(isset($this->renderer))
178
+        if (isset($this->renderer))
179 179
         {
180 180
             return $this->renderer;
181 181
         }
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
 
239 239
     public const TARGET_BLANK = '_blank';
240 240
 
241
-    public function target(string $value=self::TARGET_BLANK) : AttributeCollection
241
+    public function target(string $value = self::TARGET_BLANK) : AttributeCollection
242 242
     {
243 243
         return $this->attr('target', $value);
244 244
     }
Please login to merge, or discard this patch.
src/FileHelper/PathInfoInterface.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@
 block discarded – undo
24 24
 interface PathInfoInterface
25 25
 {
26 26
     public function getName() : string;
27
-    public function getExtension(bool $lowercase=true) : string;
27
+    public function getExtension(bool $lowercase = true) : string;
28 28
     public function getPath() : string;
29 29
     public function exists() : bool;
30 30
     public function isFolder() : bool;
Please login to merge, or discard this patch.
src/FileHelper/FolderTree.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
     {
23 23
         $info = FileHelper::getFolderInfo($rootFolder);
24 24
 
25
-        if(!$info->exists())
25
+        if (!$info->exists())
26 26
         {
27 27
             return true;
28 28
         }
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 
32 32
         foreach ($d as $item)
33 33
         {
34
-            if(self::processDeleteItem($item) === false)
34
+            if (self::processDeleteItem($item) === false)
35 35
             {
36 36
                 return false;
37 37
             }
@@ -100,11 +100,11 @@  discard block
 block discarded – undo
100 100
     {
101 101
         $target = FileHelper::createFolder($target);
102 102
 
103
-        $d =  FileHelper::getPathInfo($source)->requireIsFolder()->getIterator();
103
+        $d = FileHelper::getPathInfo($source)->requireIsFolder()->getIterator();
104 104
 
105 105
         foreach ($d as $item)
106 106
         {
107
-            if($item->isDot())
107
+            if ($item->isDot())
108 108
             {
109 109
                 continue;
110 110
             }
@@ -125,9 +125,9 @@  discard block
 block discarded – undo
125 125
 
126 126
         if ($item->isFolder())
127 127
         {
128
-            self::copy($item, $target . '/' . $item->getName());
128
+            self::copy($item, $target.'/'.$item->getName());
129 129
         }
130
-        else if($item->isFile())
130
+        else if ($item->isFile())
131 131
         {
132 132
             $item
133 133
                 ->requireIsFile()
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -41,8 +41,7 @@  discard block
 block discarded – undo
41 41
         {
42 42
             $info->delete();
43 43
             return true;
44
-        }
45
-        catch (FileHelper_Exception $e)
44
+        } catch (FileHelper_Exception $e)
46 45
         {
47 46
 
48 47
         }
@@ -79,8 +78,7 @@  discard block
 block discarded – undo
79 78
             try
80 79
             {
81 80
                 FileHelper::deleteFile($itemPath);
82
-            }
83
-            catch (FileHelper_Exception $e)
81
+            } catch (FileHelper_Exception $e)
84 82
             {
85 83
                 return false;
86 84
             }
@@ -126,8 +124,7 @@  discard block
 block discarded – undo
126 124
         if ($item->isFolder())
127 125
         {
128 126
             self::copy($item, $target . '/' . $item->getName());
129
-        }
130
-        else if($item->isFile())
127
+        } else if($item->isFile())
131 128
         {
132 129
             $item
133 130
                 ->requireIsFile()
Please login to merge, or discard this patch.