Passed
Push — master ( 0b916c...6ef6f5 )
by Sebastian
03:00
created
src/FileHelper/SerializedFile.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@
 block discarded – undo
50 50
             )
51 51
         );
52 52
 
53
-        if($result !== false) {
53
+        if ($result !== false) {
54 54
             return $result;
55 55
         }
56 56
 
Please login to merge, or discard this patch.
src/FileHelper.php 1 patch
Indentation   +162 added lines, -162 removed lines patch added patch discarded remove patch
@@ -73,18 +73,18 @@  discard block
 block discarded – undo
73 73
     public const ERROR_PATH_INVALID = 340040;
74 74
     public const ERROR_CANNOT_COPY_FILE_TO_FOLDER = 340041;
75 75
 
76
-   /**
77
-    * Opens a serialized file and returns the unserialized data.
78
-    *
79
-    * @param string|PathInfoInterface|SplFileInfo $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|PathInfoInterface|SplFileInfo $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($file) : array
89 89
     {
90 90
         return SerializedFile::factory($file)->parse();
@@ -103,13 +103,13 @@  discard block
 block discarded – undo
103 103
         return FolderTree::delete($rootFolder);
104 104
     }
105 105
     
106
-   /**
107
-    * Create a folder, if it does not exist yet.
108
-    *  
109
-    * @param string|PathInfoInterface $path
110
-    * @throws FileHelper_Exception
111
-    * @see FileHelper::ERROR_CANNOT_CREATE_FOLDER
112
-    */
106
+    /**
107
+     * Create a folder, if it does not exist yet.
108
+     *  
109
+     * @param string|PathInfoInterface $path
110
+     * @throws FileHelper_Exception
111
+     * @see FileHelper::ERROR_CANNOT_CREATE_FOLDER
112
+     */
113 113
     public static function createFolder($path) : FolderInfo
114 114
     {
115 115
         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|PathInfoInterface|SplFileInfo $sourcePath
148
-    * @param string|PathInfoInterface|SplFileInfo $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|PathInfoInterface|SplFileInfo $sourcePath
148
+     * @param string|PathInfoInterface|SplFileInfo $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($sourcePath, $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|PathInfoInterface|SplFileInfo $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|PathInfoInterface|SplFileInfo $filePath
167
+     * @throws FileHelper_Exception
168
+     * 
169
+     * @see FileHelper::ERROR_CANNOT_DELETE_FILE
170
+     */
171 171
     public static function deleteFile($filePath) : void
172 172
     {
173 173
         self::getFileInfo($filePath)->delete();
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
      */
289 289
     public static function isPHPFile($filePath) : bool
290 290
     {
291
-    	return self::getExtension($filePath) === 'php';
291
+        return self::getExtension($filePath) === 'php';
292 292
     }
293 293
 
294 294
     /**
@@ -354,16 +354,16 @@  discard block
 block discarded – undo
354 354
             ->parse();
355 355
     }
356 356
     
357
-   /**
358
-    * Corrects common formatting mistakes when users enter
359
-    * file names, like too many spaces, dots and the like.
360
-    * 
361
-    * NOTE: if the file name contains a path, the path is
362
-    * stripped, leaving only the file name.
363
-    * 
364
-    * @param string $name
365
-    * @return string
366
-    */
357
+    /**
358
+     * Corrects common formatting mistakes when users enter
359
+     * file names, like too many spaces, dots and the like.
360
+     * 
361
+     * NOTE: if the file name contains a path, the path is
362
+     * stripped, leaving only the file name.
363
+     * 
364
+     * @param string $name
365
+     * @return string
366
+     */
367 367
     public static function fixFileName(string $name) : string
368 368
     {
369 369
         return NameFixer::fixName($name);
@@ -423,23 +423,23 @@  discard block
 block discarded – undo
423 423
         return self::findFiles($targetFolder, array('php'), $options);
424 424
     }
425 425
     
426
-   /**
427
-    * Finds files according to the specified options.
428
-    * 
429
-    * NOTE: This method only exists for backwards compatibility.
430
-    * Use the {@see FileHelper::createFileFinder()} method instead,
431
-    * which offers an object-oriented interface that is much easier
432
-    * to use.
433
-    *  
434
-    * @param string|PathInfoInterface|SplFileInfo $targetFolder
435
-    * @param string[] $extensions
436
-    * @param array<string,mixed> $options
437
-    * @throws FileHelper_Exception
438
-    * @return string[]
439
-    *
440
-    * @see FileHelper::createFileFinder()
441
-    * @deprecated Use the file finder instead.
442
-    */
426
+    /**
427
+     * Finds files according to the specified options.
428
+     * 
429
+     * NOTE: This method only exists for backwards compatibility.
430
+     * Use the {@see FileHelper::createFileFinder()} method instead,
431
+     * which offers an object-oriented interface that is much easier
432
+     * to use.
433
+     *  
434
+     * @param string|PathInfoInterface|SplFileInfo $targetFolder
435
+     * @param string[] $extensions
436
+     * @param array<string,mixed> $options
437
+     * @throws FileHelper_Exception
438
+     * @return string[]
439
+     *
440
+     * @see FileHelper::createFileFinder()
441
+     * @deprecated Use the file finder instead.
442
+     */
443 443
     public static function findFiles($targetFolder, array $extensions=array(), array $options=array()) : array
444 444
     {
445 445
         $finder = self::createFileFinder($targetFolder);
@@ -510,13 +510,13 @@  discard block
 block discarded – undo
510 510
         return self::$unicodeHandling;
511 511
     }
512 512
     
513
-   /**
514
-    * Normalizes the slash style in a file or folder path,
515
-    * by replacing any anti-slashes with forward slashes.
516
-    * 
517
-    * @param string $path
518
-    * @return string
519
-    */
513
+    /**
514
+     * Normalizes the slash style in a file or folder path,
515
+     * by replacing any anti-slashes with forward slashes.
516
+     * 
517
+     * @param string $path
518
+     * @return string
519
+     */
520 520
     public static function normalizePath(string $path) : string
521 521
     {
522 522
         return str_replace(array('\\', '//'), array('/', '/'), $path);
@@ -641,70 +641,70 @@  discard block
 block discarded – undo
641 641
             ->getPaths();
642 642
     }
643 643
 
644
-   /**
645
-    * Retrieves the maximum allowed upload file size, in bytes.
646
-    * Takes into account the PHP ini settings <code>post_max_size</code>
647
-    * and <code>upload_max_filesize</code>. Since these cannot
648
-    * be modified at runtime, they are the hard limits for uploads.
649
-    * 
650
-    * NOTE: Based on binary values, where 1KB = 1024 Bytes.
651
-    * 
652
-    * @return int Will return <code>-1</code> if no limit.
653
-    */
644
+    /**
645
+     * Retrieves the maximum allowed upload file size, in bytes.
646
+     * Takes into account the PHP ini settings <code>post_max_size</code>
647
+     * and <code>upload_max_filesize</code>. Since these cannot
648
+     * be modified at runtime, they are the hard limits for uploads.
649
+     * 
650
+     * NOTE: Based on binary values, where 1KB = 1024 Bytes.
651
+     * 
652
+     * @return int Will return <code>-1</code> if no limit.
653
+     */
654 654
     public static function getMaxUploadFilesize() : int
655 655
     {
656 656
         return UploadFileSizeInfo::getFileSize();
657 657
     }
658 658
    
659
-   /**
660
-    * Makes a path relative using a folder depth: will reduce the
661
-    * length of the path so that only the amount of folders defined
662
-    * in the <code>$depth</code> attribute are shown below the actual
663
-    * folder or file in the path.
664
-    *  
665
-    * @param string  $path The absolute or relative path
666
-    * @param int $depth The folder depth to reduce the path to
667
-    * @return string
668
-    */
659
+    /**
660
+     * Makes a path relative using a folder depth: will reduce the
661
+     * length of the path so that only the amount of folders defined
662
+     * in the <code>$depth</code> attribute are shown below the actual
663
+     * folder or file in the path.
664
+     *  
665
+     * @param string  $path The absolute or relative path
666
+     * @param int $depth The folder depth to reduce the path to
667
+     * @return string
668
+     */
669 669
     public static function relativizePathByDepth(string $path, int $depth=2) : string
670 670
     {
671 671
         return PathRelativizer::relativizeByDepth($path, $depth);
672 672
     }
673 673
     
674
-   /**
675
-    * Makes the specified path relative to another path,
676
-    * by removing one from the other if found. Also 
677
-    * normalizes the path to use forward slashes. 
678
-    * 
679
-    * Example:
680
-    * 
681
-    * <pre>
682
-    * relativizePath('c:\some\folder\to\file.txt', 'c:\some\folder');
683
-    * </pre>
684
-    * 
685
-    * Result: <code>to/file.txt</code>
686
-    * 
687
-    * @param string $path
688
-    * @param string $relativeTo
689
-    * @return string
690
-    */
674
+    /**
675
+     * Makes the specified path relative to another path,
676
+     * by removing one from the other if found. Also 
677
+     * normalizes the path to use forward slashes. 
678
+     * 
679
+     * Example:
680
+     * 
681
+     * <pre>
682
+     * relativizePath('c:\some\folder\to\file.txt', 'c:\some\folder');
683
+     * </pre>
684
+     * 
685
+     * Result: <code>to/file.txt</code>
686
+     * 
687
+     * @param string $path
688
+     * @param string $relativeTo
689
+     * @return string
690
+     */
691 691
     public static function relativizePath(string $path, string $relativeTo) : string
692 692
     {
693 693
         return PathRelativizer::relativize($path, $relativeTo);
694 694
     }
695 695
     
696
-   /**
697
-    * Checks that the target file exists, and throws an exception
698
-    * if it does not. 
699
-    * 
700
-    * @param string|SplFileInfo $path
701
-    * @param int|NULL $errorCode Optional custom error code
702
-    * @throws FileHelper_Exception
703
-    * @return string The real path to the file
704
-    * 
705
-    * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST
706
-    * @see FileHelper::ERROR_REAL_PATH_NOT_FOUND
707
-    */
696
+    /**
697
+     * Checks that the target file exists, and throws an exception
698
+     * if it does not. 
699
+     * 
700
+     * @param string|SplFileInfo $path
701
+     * @param int|NULL $errorCode Optional custom error code
702
+     * @throws FileHelper_Exception
703
+     * @return string The real path to the file
704
+     * 
705
+     * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST
706
+     * @see FileHelper::ERROR_REAL_PATH_NOT_FOUND
707
+     */
708 708
     public static function requireFileExists($path, ?int $errorCode=null) : string
709 709
     {
710 710
         return self::getPathInfo($path)
@@ -727,18 +727,18 @@  discard block
 block discarded – undo
727 727
             ->getPath();
728 728
     }
729 729
     
730
-   /**
731
-    * Reads a specific line number from the target file and returns its
732
-    * contents, if the file has such a line. Does so with little memory
733
-    * usage, as the file is not read entirely into memory.
734
-    * 
735
-    * @param string|PathInfoInterface|SplFileInfo $path
736
-    * @param int $lineNumber Note: 1-based; the first line is number 1.
737
-    * @return string|NULL Will return null if the requested line does not exist.
738
-    * @throws FileHelper_Exception
739
-    * 
740
-    * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST
741
-    */
730
+    /**
731
+     * Reads a specific line number from the target file and returns its
732
+     * contents, if the file has such a line. Does so with little memory
733
+     * usage, as the file is not read entirely into memory.
734
+     * 
735
+     * @param string|PathInfoInterface|SplFileInfo $path
736
+     * @param int $lineNumber Note: 1-based; the first line is number 1.
737
+     * @return string|NULL Will return null if the requested line does not exist.
738
+     * @throws FileHelper_Exception
739
+     * 
740
+     * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST
741
+     */
742 742
     public static function getLineFromFile($path, int $lineNumber) : ?string
743 743
     {
744 744
         return self::getFileInfo($path)->getLine($lineNumber);
@@ -804,33 +804,33 @@  discard block
 block discarded – undo
804 804
             ->getLines($amount);
805 805
     }
806 806
     
807
-   /**
808
-    * Reads all content from a file.
809
-    * 
810
-    * @param string|PathInfoInterface|SplFileInfo $filePath
811
-    * @throws FileHelper_Exception
812
-    * @return string
813
-    * 
814
-    * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST
815
-    * @see FileHelper::ERROR_CANNOT_READ_FILE_CONTENTS
816
-    */
807
+    /**
808
+     * Reads all content from a file.
809
+     * 
810
+     * @param string|PathInfoInterface|SplFileInfo $filePath
811
+     * @throws FileHelper_Exception
812
+     * @return string
813
+     * 
814
+     * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST
815
+     * @see FileHelper::ERROR_CANNOT_READ_FILE_CONTENTS
816
+     */
817 817
     public static function readContents($filePath) : string
818 818
     {
819 819
         return self::getFileInfo($filePath)->getContents();
820 820
     }
821 821
 
822
-   /**
823
-    * Ensures that the target path exists on disk, and is a folder.
824
-    * 
825
-    * @param string|PathInfoInterface|SplFileInfo $path
826
-    * @return string The real path, with normalized slashes.
827
-    * @throws FileHelper_Exception
828
-    * 
829
-    * @see FileHelper::normalizePath()
830
-    * 
831
-    * @see FileHelper::ERROR_FOLDER_DOES_NOT_EXIST
832
-    * @see FileHelper::ERROR_PATH_IS_NOT_A_FOLDER
833
-    */
822
+    /**
823
+     * Ensures that the target path exists on disk, and is a folder.
824
+     * 
825
+     * @param string|PathInfoInterface|SplFileInfo $path
826
+     * @return string The real path, with normalized slashes.
827
+     * @throws FileHelper_Exception
828
+     * 
829
+     * @see FileHelper::normalizePath()
830
+     * 
831
+     * @see FileHelper::ERROR_FOLDER_DOES_NOT_EXIST
832
+     * @see FileHelper::ERROR_PATH_IS_NOT_A_FOLDER
833
+     */
834 834
     public static function requireFolderExists($path) : string
835 835
     {
836 836
         return self::getFolderInfo($path)
Please login to merge, or discard this patch.
src/FileHelper/JSONFile.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 
121 121
     private function convertEncoding(string $contents) : string
122 122
     {
123
-        if(!empty($this->targetEncoding))
123
+        if (!empty($this->targetEncoding))
124 124
         {
125 125
             return (string)mb_convert_encoding(
126 126
                 $contents,
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
     {
143 143
         $options = null;
144 144
 
145
-        if($pretty)
145
+        if ($pretty)
146 146
         {
147 147
             $options = JSON_PRETTY_PRINT;
148 148
         }
Please login to merge, or discard this patch.
src/FileHelper/AbstractPathInfo.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 
108 108
         $path = realpath($this->path);
109 109
 
110
-        if($path !== false)
110
+        if ($path !== false)
111 111
         {
112 112
             return FileHelper::normalizePath($path);
113 113
         }
@@ -126,14 +126,14 @@  discard block
 block discarded – undo
126 126
      * @return $this
127 127
      * @throws FileHelper_Exception
128 128
      */
129
-    private function requireTrue(bool $condition, string $conditionLabel, ?int $errorCode=null) : self
129
+    private function requireTrue(bool $condition, string $conditionLabel, ?int $errorCode = null) : self
130 130
     {
131
-        if($condition === true)
131
+        if ($condition === true)
132 132
         {
133 133
             return $this;
134 134
         }
135 135
 
136
-        if($errorCode === null)
136
+        if ($errorCode === null)
137 137
         {
138 138
             $errorCode = FileHelper::ERROR_FILE_DOES_NOT_EXIST;
139 139
         }
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
      * @return $this
151 151
      * @throws FileHelper_Exception
152 152
      */
153
-    public function requireExists(?int $errorCode=null) : self
153
+    public function requireExists(?int $errorCode = null) : self
154 154
     {
155 155
         return $this->requireTrue(
156 156
             !empty($this->path) && realpath($this->path) !== false,
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
      * @return $this
165 165
      * @throws FileHelper_Exception
166 166
      */
167
-    public function requireReadable(?int $errorCode=null) : self
167
+    public function requireReadable(?int $errorCode = null) : self
168 168
     {
169 169
         $this->requireExists($errorCode);
170 170
 
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
      * @return $this
181 181
      * @throws FileHelper_Exception
182 182
      */
183
-    public function requireWritable(?int $errorCode=null) : self
183
+    public function requireWritable(?int $errorCode = null) : self
184 184
     {
185 185
         return $this->requireTrue(
186 186
             $this->isWritable(),
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
      */
198 198
     public function requireIsFile() : FileInfo
199 199
     {
200
-        if($this instanceof FileInfo)
200
+        if ($this instanceof FileInfo)
201 201
         {
202 202
             return $this;
203 203
         }
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
      */
221 221
     public function requireIsFolder() : FolderInfo
222 222
     {
223
-        if($this instanceof FolderInfo)
223
+        if ($this instanceof FolderInfo)
224 224
         {
225 225
             return $this;
226 226
         }
@@ -241,12 +241,12 @@  discard block
 block discarded – undo
241 241
      */
242 242
     public static function type2string($path) : string
243 243
     {
244
-        if($path instanceof PathInfoInterface)
244
+        if ($path instanceof PathInfoInterface)
245 245
         {
246 246
             return $path->getPath();
247 247
         }
248 248
 
249
-        if($path instanceof SplFileInfo)
249
+        if ($path instanceof SplFileInfo)
250 250
         {
251 251
             return $path->getPathname();
252 252
         }
@@ -268,24 +268,24 @@  discard block
 block discarded – undo
268 268
      */
269 269
     public static function resolveType($path) : PathInfoInterface
270 270
     {
271
-        if($path instanceof PathInfoInterface)
271
+        if ($path instanceof PathInfoInterface)
272 272
         {
273 273
             return $path;
274 274
         }
275 275
 
276 276
         $path = self::type2string($path);
277 277
 
278
-        if(FolderInfo::is_dir($path))
278
+        if (FolderInfo::is_dir($path))
279 279
         {
280 280
             return FolderInfo::factory($path);
281 281
         }
282 282
 
283
-        if(FileInfo::is_file($path))
283
+        if (FileInfo::is_file($path))
284 284
         {
285 285
             return FileInfo::factory($path);
286 286
         }
287 287
 
288
-        if(!empty($path) && $path !== '.' && $path !== '..')
288
+        if (!empty($path) && $path !== '.' && $path !== '..')
289 289
         {
290 290
             return new IndeterminatePath($path);
291 291
         }
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
     public function getModifiedDate() : ?DateTime
341 341
     {
342 342
         $time = filemtime($this->getPath());
343
-        if($time === false) {
343
+        if ($time === false) {
344 344
             return null;
345 345
         }
346 346
 
Please login to merge, or discard this patch.
src/FileHelper/FileInfo.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
         $pathString = AbstractPathInfo::type2string($path);
67 67
         $endingChar = $pathString[strlen($pathString) - 1];
68 68
 
69
-        if(empty($path)) {
69
+        if (empty($path)) {
70 70
             throw new FileHelper_Exception(
71 71
                 'Invalid',
72 72
                 '',
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
             );
75 75
         }
76 76
 
77
-        if($path instanceof FolderInfo || $endingChar === '/' || $endingChar === '\\')
77
+        if ($path instanceof FolderInfo || $endingChar === '/' || $endingChar === '\\')
78 78
         {
79 79
             throw new FileHelper_Exception(
80 80
                 'Cannot use a folder as a file',
@@ -88,12 +88,12 @@  discard block
 block discarded – undo
88 88
 
89 89
         $key = $pathString.';'.static::class;
90 90
 
91
-        if(!isset(self::$infoCache[$key]))
91
+        if (!isset(self::$infoCache[$key]))
92 92
         {
93 93
             $class = static::class;
94 94
             $instance = new $class($pathString);
95 95
 
96
-            if(!$instance instanceof self) {
96
+            if (!$instance instanceof self) {
97 97
                 throw new FileHelper_Exception(
98 98
                     'Invalid class created',
99 99
                     sprintf(
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
     {
129 129
         $path = trim($path);
130 130
 
131
-        if(empty($path))
131
+        if (empty($path))
132 132
         {
133 133
             return false;
134 134
         }
@@ -136,9 +136,9 @@  discard block
 block discarded – undo
136 136
         return pathinfo($path, PATHINFO_EXTENSION) !== '' || is_file($path);
137 137
     }
138 138
 
139
-    public function removeExtension(bool $keepPath=false) : string
139
+    public function removeExtension(bool $keepPath = false) : string
140 140
     {
141
-        if(!$keepPath)
141
+        if (!$keepPath)
142 142
         {
143 143
             return (string)pathinfo($this->getName(), PATHINFO_FILENAME);
144 144
         }
@@ -163,11 +163,11 @@  discard block
 block discarded – undo
163 163
         return $this->removeExtension();
164 164
     }
165 165
 
166
-    public function getExtension(bool $lowercase=true) : string
166
+    public function getExtension(bool $lowercase = true) : string
167 167
     {
168 168
         $ext = (string)pathinfo($this->path, PATHINFO_EXTENSION);
169 169
 
170
-        if($lowercase)
170
+        if ($lowercase)
171 171
         {
172 172
             $ext = mb_strtolower($ext);
173 173
         }
@@ -188,12 +188,12 @@  discard block
 block discarded – undo
188 188
      */
189 189
     public function delete() : FileInfo
190 190
     {
191
-        if(!$this->exists())
191
+        if (!$this->exists())
192 192
         {
193 193
             return $this;
194 194
         }
195 195
 
196
-        if(unlink($this->path))
196
+        if (unlink($this->path))
197 197
         {
198 198
             return $this;
199 199
         }
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
     {
221 221
         $target = $this->checkCopyPrerequisites($targetPath);
222 222
 
223
-        if(copy($this->path, (string)$target))
223
+        if (copy($this->path, (string)$target))
224 224
         {
225 225
             return $target;
226 226
         }
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
         $target = FileHelper::getPathInfo($targetPath);
258 258
 
259 259
         // It's a file? Then we can use it as-is.
260
-        if($target instanceof self) {
260
+        if ($target instanceof self) {
261 261
             return $target
262 262
                 ->requireIsFile()
263 263
                 ->createFolder();
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
         // but is not a folder: very likely a file without extension.
268 268
         // In this case we create an empty file to be able to return
269 269
         // a FileInfo instance.
270
-        if($target instanceof IndeterminatePath)
270
+        if ($target instanceof IndeterminatePath)
271 271
         {
272 272
             return $target->convertToFile();
273 273
         }
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
      */
297 297
     public function getLineReader() : LineReader
298 298
     {
299
-        if($this->lineReader === null)
299
+        if ($this->lineReader === null)
300 300
         {
301 301
             $this->lineReader = new LineReader($this);
302 302
         }
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
 
316 316
         $result = file_get_contents($this->getPath());
317 317
 
318
-        if($result !== false) {
318
+        if ($result !== false) {
319 319
             return $result;
320 320
         }
321 321
 
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
      */
338 338
     public function putContents(string $content) : FileInfo
339 339
     {
340
-        if($this->exists())
340
+        if ($this->exists())
341 341
         {
342 342
             $this->requireWritable();
343 343
         }
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
                 ->requireWritable();
349 349
         }
350 350
 
351
-        if(file_put_contents($this->path, $content) !== false)
351
+        if (file_put_contents($this->path, $content) !== false)
352 352
         {
353 353
             return $this;
354 354
         }
@@ -378,7 +378,7 @@  discard block
 block discarded – undo
378 378
      */
379 379
     private function createFolder() : FileInfo
380 380
     {
381
-        if(!$this->exists())
381
+        if (!$this->exists())
382 382
         {
383 383
             FolderInfo::factory($this->getFolderPath())
384 384
                 ->create()
Please login to merge, or discard this patch.
src/FileHelper/IndeterminatePath.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
     {
42 42
         // Doing this manually, as FileHelper::saveFile()
43 43
         // checks if the target is a file, which will fail.
44
-        if(file_put_contents($this->getPath(), '') === false) {
44
+        if (file_put_contents($this->getPath(), '') === false) {
45 45
             throw new FileHelper_Exception(
46 46
                 'Cannot create file',
47 47
                 '',
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 
59 59
         // Doing this manually, as FileHelper::createFolder()
60 60
         // checks if the target is a folder, which will fail.
61
-        if(!mkdir($path, 0777, true) && !is_dir($path))
61
+        if (!mkdir($path, 0777, true) && !is_dir($path))
62 62
         {
63 63
             throw new FileHelper_Exception(
64 64
                 'Cannot create folder',
@@ -72,11 +72,11 @@  discard block
 block discarded – undo
72 72
 
73 73
     public function convertTo(string $type) : PathInfoInterface
74 74
     {
75
-        if($type === self::CONVERT_TYPE_FILE) {
75
+        if ($type === self::CONVERT_TYPE_FILE) {
76 76
             return $this->convertToFile();
77 77
         }
78 78
 
79
-        if($type === self::CONVERT_TYPE_FOLDER) {
79
+        if ($type === self::CONVERT_TYPE_FOLDER) {
80 80
             return $this->convertToFolder();
81 81
         }
82 82
 
Please login to merge, or discard this patch.
src/FileHelper/PHPFile.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
      */
57 57
     public function checkSyntax()
58 58
     {
59
-        if(!FileHelper::canMakePHPCalls())
59
+        if (!FileHelper::canMakePHPCalls())
60 60
         {
61 61
             return true;
62 62
         }
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
         // when the validation is successful, the first entry
69 69
         // in the array contains the success message. When it
70 70
         // is invalid, the first entry is always empty.
71
-        if(!empty($output[0])) {
71
+        if (!empty($output[0])) {
72 72
             return true;
73 73
         }
74 74
 
Please login to merge, or discard this patch.
src/FileHelper/FolderInfo.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
     {
31 31
         $pathString = AbstractPathInfo::type2string($path);
32 32
 
33
-        if(empty($path)) {
33
+        if (empty($path)) {
34 34
             throw new FileHelper_Exception(
35 35
                 'Invalid',
36 36
                 '',
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
             );
39 39
         }
40 40
 
41
-        if($path instanceof FileInfo || FileInfo::is_file($pathString))
41
+        if ($path instanceof FileInfo || FileInfo::is_file($pathString))
42 42
         {
43 43
             throw new FileHelper_Exception(
44 44
                 'Cannot use a file',
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
             );
51 51
         }
52 52
 
53
-        if(!isset(self::$infoCache[$pathString]))
53
+        if (!isset(self::$infoCache[$pathString]))
54 54
         {
55 55
             self::$infoCache[$pathString] = new FolderInfo($pathString);
56 56
         }
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
         $path = trim($path);
88 88
         $test = trim($path, '/\\');
89 89
 
90
-        if($path === '' || $test === '.' || $test === '..')
90
+        if ($path === '' || $test === '.' || $test === '..')
91 91
         {
92 92
             return false;
93 93
         }
@@ -105,12 +105,12 @@  discard block
 block discarded – undo
105 105
      */
106 106
     public function delete() : FolderInfo
107 107
     {
108
-        if(!$this->exists())
108
+        if (!$this->exists())
109 109
         {
110 110
             return $this;
111 111
         }
112 112
 
113
-        if(rmdir($this->path))
113
+        if (rmdir($this->path))
114 114
         {
115 115
             return $this;
116 116
         }
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
      */
137 137
     public function create() : FolderInfo
138 138
     {
139
-        if(is_dir($this->path) || mkdir($this->path, 0777, true) || is_dir($this->path))
139
+        if (is_dir($this->path) || mkdir($this->path, 0777, true) || is_dir($this->path))
140 140
         {
141 141
             return $this;
142 142
         }
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
         return FileHelper::createFolder($this->getPath().'/'.$name);
187 187
     }
188 188
 
189
-    public function saveFile(string $fileName, string $content='') : FileInfo
189
+    public function saveFile(string $fileName, string $content = '') : FileInfo
190 190
     {
191 191
         return FileHelper::saveFile($this.'/'.$fileName, $content);
192 192
     }
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
      * @return JSONFile
199 199
      * @throws FileHelper_Exception
200 200
      */
201
-    public function saveJSONFile(array $data, string $fileName, bool $pretty=false) : JSONFile
201
+    public function saveJSONFile(array $data, string $fileName, bool $pretty = false) : JSONFile
202 202
     {
203 203
         return FileHelper::saveAsJSON($data, $this.'/'.$fileName, $pretty);
204 204
     }
Please login to merge, or discard this patch.