Passed
Push — master ( e76473...8d6fb4 )
by Sebastian
09:39
created
src/FileHelper/FolderInfo.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
      */
26 26
     public static function factory(string $path) : FolderInfo
27 27
     {
28
-        if(!isset(self::$infoCache[$path]))
28
+        if (!isset(self::$infoCache[$path]))
29 29
         {
30 30
             self::$infoCache[$path] = new FolderInfo($path);
31 31
         }
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
     {
55 55
         parent::__construct($path);
56 56
 
57
-        if(!self::is_dir($this->path))
57
+        if (!self::is_dir($this->path))
58 58
         {
59 59
             throw new FileHelper_Exception(
60 60
                 'Not a folder',
@@ -76,12 +76,12 @@  discard block
 block discarded – undo
76 76
     {
77 77
         $path = trim($path);
78 78
 
79
-        if($path === '' || $path === '.' || $path === '..')
79
+        if ($path === '' || $path === '.' || $path === '..')
80 80
         {
81 81
             return false;
82 82
         }
83 83
 
84
-        if(is_dir($path))
84
+        if (is_dir($path))
85 85
         {
86 86
             return true;
87 87
         }
@@ -99,12 +99,12 @@  discard block
 block discarded – undo
99 99
      */
100 100
     public function delete() : FolderInfo
101 101
     {
102
-        if(!$this->exists())
102
+        if (!$this->exists())
103 103
         {
104 104
             return $this;
105 105
         }
106 106
 
107
-        if(rmdir($this->path))
107
+        if (rmdir($this->path))
108 108
         {
109 109
             return $this;
110 110
         }
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
      */
131 131
     public function create() : FolderInfo
132 132
     {
133
-        if(is_dir($this->path) || mkdir($this->path, 0777, true) || is_dir($this->path))
133
+        if (is_dir($this->path) || mkdir($this->path, 0777, true) || is_dir($this->path))
134 134
         {
135 135
             return $this;
136 136
         }
Please login to merge, or discard this patch.
src/FileHelper/FolderTree.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
      */
20 20
     public static function delete(string $rootFolder) : bool
21 21
     {
22
-        if(!file_exists($rootFolder))
22
+        if (!file_exists($rootFolder))
23 23
         {
24 24
             return true;
25 25
         }
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 
29 29
         foreach ($d as $item)
30 30
         {
31
-            if(self::processDeleteItem($item) === false)
31
+            if (self::processDeleteItem($item) === false)
32 32
             {
33 33
                 return false;
34 34
             }
@@ -111,11 +111,11 @@  discard block
 block discarded – undo
111 111
 
112 112
         if ($item->isDir())
113 113
         {
114
-            self::copy($itemPath, $target . '/' . $baseName);
114
+            self::copy($itemPath, $target.'/'.$baseName);
115 115
         }
116
-        else if($item->isFile())
116
+        else if ($item->isFile())
117 117
         {
118
-            FileHelper::copyFile($itemPath, $target . '/' . $baseName);
118
+            FileHelper::copyFile($itemPath, $target.'/'.$baseName);
119 119
         }
120 120
     }
121 121
 }
Please login to merge, or discard this patch.
src/FileHelper/FolderFinder.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
      */
29 29
     public function __construct($path)
30 30
     {
31
-        if($path instanceof FolderInfo)
31
+        if ($path instanceof FolderInfo)
32 32
         {
33 33
             $this->folder = $path;
34 34
         }
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
         );
47 47
     }
48 48
 
49
-    public function makeRecursive(bool $recursive=true) : self
49
+    public function makeRecursive(bool $recursive = true) : self
50 50
     {
51 51
         return $this->setOption(self::OPTION_RECURSIVE, $recursive);
52 52
     }
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 
77 77
         $result = array();
78 78
 
79
-        foreach($this->folders as $folder)
79
+        foreach ($this->folders as $folder)
80 80
         {
81 81
             $result[] = $this->resolvePath($folder);
82 82
         }
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 
97 97
     private function resolvePath(FolderInfo $folder) : string
98 98
     {
99
-        if(!$this->isPathModeAbsolute())
99
+        if (!$this->isPathModeAbsolute())
100 100
         {
101 101
             return $folder->getRelativeTo($this->folder);
102 102
         }
@@ -117,9 +117,9 @@  discard block
 block discarded – undo
117 117
     {
118 118
         $d = new DirectoryIterator($folder->getPath());
119 119
 
120
-        foreach($d as $item)
120
+        foreach ($d as $item)
121 121
         {
122
-            if($item->isDir() && !$item->isDot())
122
+            if ($item->isDir() && !$item->isDot())
123 123
             {
124 124
                 $this->processFolder(FileHelper::getFolderInfo($item->getPathname()));
125 125
             }
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
     {
141 141
         $this->folders[] = $folder;
142 142
 
143
-        if($this->isRecursive())
143
+        if ($this->isRecursive())
144 144
         {
145 145
             $this->scanFolder($folder);
146 146
         }
Please login to merge, or discard this patch.
src/FileHelper/FileFinder.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  * @see \AppUtils\FileHelper\FileFinder
8 8
  */
9 9
 
10
-declare(strict_types = 1);
10
+declare(strict_types=1);
11 11
 
12 12
 namespace AppUtils\FileHelper;
13 13
 
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
     {
64 64
         $real = realpath($path);
65 65
         
66
-        if($real === false) 
66
+        if ($real === false) 
67 67
         {
68 68
             throw new FileHelper_Exception(
69 69
                 'Target path does not exist',
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
      * @param bool $enabled
107 107
      * @return FileFinder
108 108
      */
109
-    public function makeRecursive(bool $enabled=true) : FileFinder
109
+    public function makeRecursive(bool $enabled = true) : FileFinder
110 110
     {
111 111
         return $this->setOption('recursive', $enabled);
112 112
     }
@@ -311,22 +311,22 @@  discard block
 block discarded – undo
311 311
         return $this->getAll();
312 312
     }
313 313
     
314
-    protected function find(string $path, bool $isRoot=false) : void
314
+    protected function find(string $path, bool $isRoot = false) : void
315 315
     {
316
-        if($isRoot) {
316
+        if ($isRoot) {
317 317
             $this->found = array();
318 318
         }
319 319
         
320 320
         $recursive = $this->getBoolOption('recursive');
321 321
         
322 322
         $d = new DirectoryIterator($path);
323
-        foreach($d as $item)
323
+        foreach ($d as $item)
324 324
         {
325 325
             $pathname = $item->getPathname();
326 326
             
327
-            if($item->isDir())
327
+            if ($item->isDir())
328 328
             {
329
-                if($recursive && !$item->isDot()) {
329
+                if ($recursive && !$item->isDot()) {
330 330
                     $this->find($pathname);
331 331
                 }
332 332
                 
@@ -335,7 +335,7 @@  discard block
 block discarded – undo
335 335
             
336 336
             $file = $this->filterFile($pathname);
337 337
             
338
-            if($file !== null) 
338
+            if ($file !== null) 
339 339
             {
340 340
                 $this->found[] = $file;
341 341
             }
@@ -348,23 +348,23 @@  discard block
 block discarded – undo
348 348
         
349 349
         $extension = FileHelper::getExtension($path);
350 350
         
351
-        if(!$this->filterExclusion($extension)) {
351
+        if (!$this->filterExclusion($extension)) {
352 352
             return null;
353 353
         }
354 354
         
355 355
         $path = $this->filterPath($path);
356 356
         
357
-        if($this->getOption('strip-extensions') === true)
357
+        if ($this->getOption('strip-extensions') === true)
358 358
         {
359 359
             $path = str_replace('.'.$extension, '', $path);
360 360
         }
361 361
         
362
-        if($path === '') {
362
+        if ($path === '') {
363 363
             return null;
364 364
         }
365 365
         
366 366
         $replace = $this->getOption('slash-replacement');
367
-        if(!empty($replace)) {
367
+        if (!empty($replace)) {
368 368
             $path = str_replace('/', $replace, $path);
369 369
         }
370 370
         
@@ -383,15 +383,15 @@  discard block
 block discarded – undo
383 383
         $include = $this->getOption(self::OPTION_INCLUDE_EXTENSIONS);
384 384
         $exclude = $this->getOption(self::OPTION_EXCLUDE_EXTENSIONS);
385 385
         
386
-        if(!empty($include))
386
+        if (!empty($include))
387 387
         {
388
-            if(!in_array($extension, $include, true)) {
388
+            if (!in_array($extension, $include, true)) {
389 389
                 return false;
390 390
             }
391 391
         }
392
-        else if(!empty($exclude))
392
+        else if (!empty($exclude))
393 393
         {
394
-            if(in_array($extension, $exclude, true)) {
394
+            if (in_array($extension, $exclude, true)) {
395 395
                 return false;
396 396
             }
397 397
         }
@@ -407,7 +407,7 @@  discard block
 block discarded – undo
407 407
     */
408 408
     protected function filterPath(string $path) : string
409 409
     {
410
-        switch($this->getStringOption(self::OPTION_PATHMODE))
410
+        switch ($this->getStringOption(self::OPTION_PATHMODE))
411 411
         {
412 412
             case self::PATH_MODE_STRIP:
413 413
                 return basename($path);
Please login to merge, or discard this patch.
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/CLICommandChecker.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
     {
60 60
         $os = $this->getOS();
61 61
 
62
-        if(isset(self::$osCommands[$os]))
62
+        if (isset(self::$osCommands[$os]))
63 63
         {
64 64
             return self::$osCommands[$os];
65 65
         }
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
      */
84 84
     public function exists(string $command) : bool
85 85
     {
86
-        if(isset(self::$checked[$command]))
86
+        if (isset(self::$checked[$command]))
87 87
         {
88 88
             return self::$checked[$command];
89 89
         }
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
             $pipes
115 115
         );
116 116
 
117
-        if($process === false)
117
+        if ($process === false)
118 118
         {
119 119
             return '';
120 120
         }
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 
127 127
         proc_close($process);
128 128
 
129
-        if($stdout === false)
129
+        if ($stdout === false)
130 130
         {
131 131
             return '';
132 132
         }
Please login to merge, or discard this patch.
src/FileHelper/FileInfo.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
      */
40 40
     public static function factory(string $path) : FileInfo
41 41
     {
42
-        if(!isset(self::$infoCache[$path]))
42
+        if (!isset(self::$infoCache[$path]))
43 43
         {
44 44
             self::$infoCache[$path] = new FileInfo($path);
45 45
         }
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
     {
70 70
         parent::__construct($path);
71 71
 
72
-        if(!self::is_file($this->path))
72
+        if (!self::is_file($this->path))
73 73
         {
74 74
             throw new FileHelper_Exception(
75 75
                 'Not a file path',
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
     {
84 84
         $path = trim($path);
85 85
 
86
-        if(empty($path))
86
+        if (empty($path))
87 87
         {
88 88
             return false;
89 89
         }
@@ -91,9 +91,9 @@  discard block
 block discarded – undo
91 91
         return is_file($path) || pathinfo($path, PATHINFO_EXTENSION) !== '';
92 92
     }
93 93
 
94
-    public function removeExtension(bool $keepPath=false) : string
94
+    public function removeExtension(bool $keepPath = false) : string
95 95
     {
96
-        if(!$keepPath)
96
+        if (!$keepPath)
97 97
         {
98 98
             return pathinfo($this->getName(), PATHINFO_FILENAME);
99 99
         }
@@ -107,11 +107,11 @@  discard block
 block discarded – undo
107 107
         return implode('/', $parts);
108 108
     }
109 109
 
110
-    public function getExtension(bool $lowercase=true) : string
110
+    public function getExtension(bool $lowercase = true) : string
111 111
     {
112 112
         $ext = pathinfo($this->path, PATHINFO_EXTENSION);
113 113
 
114
-        if($lowercase)
114
+        if ($lowercase)
115 115
         {
116 116
             $ext = mb_strtolower($ext);
117 117
         }
@@ -127,12 +127,12 @@  discard block
 block discarded – undo
127 127
      */
128 128
     public function delete() : FileInfo
129 129
     {
130
-        if(!$this->exists())
130
+        if (!$this->exists())
131 131
         {
132 132
             return $this;
133 133
         }
134 134
 
135
-        if(unlink($this->path))
135
+        if (unlink($this->path))
136 136
         {
137 137
             return $this;
138 138
         }
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
     {
160 160
         $this->checkCopyPrerequisites($targetPath);
161 161
 
162
-        if(copy($this->path, $targetPath))
162
+        if (copy($this->path, $targetPath))
163 163
         {
164 164
             return self::factory($targetPath);
165 165
         }
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
      */
212 212
     public function getLineReader() : LineReader
213 213
     {
214
-        if(!isset($this->lineReader))
214
+        if (!isset($this->lineReader))
215 215
         {
216 216
             $this->lineReader = new LineReader($this);
217 217
         }
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
 
231 231
         $result = file_get_contents($this->getPath());
232 232
 
233
-        if($result !== false) {
233
+        if ($result !== false) {
234 234
             return $result;
235 235
         }
236 236
 
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
      */
253 253
     public function putContents(string $content) : FileInfo
254 254
     {
255
-        if($this->exists())
255
+        if ($this->exists())
256 256
         {
257 257
             $this->requireWritable();
258 258
         }
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
                 ->requireWritable();
264 264
         }
265 265
 
266
-        if(file_put_contents($this->path, $content) !== false)
266
+        if (file_put_contents($this->path, $content) !== false)
267 267
         {
268 268
             return $this;
269 269
         }
Please login to merge, or discard this patch.
src/FileHelper/AbstractPathInfo.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 
93 93
         $path = realpath($this->path);
94 94
 
95
-        if($path !== false)
95
+        if ($path !== false)
96 96
         {
97 97
             return FileHelper::normalizePath($path);
98 98
         }
@@ -111,14 +111,14 @@  discard block
 block discarded – undo
111 111
      * @return $this
112 112
      * @throws FileHelper_Exception
113 113
      */
114
-    private function requireTrue(bool $condition, string $conditionLabel, ?int $errorCode=null) : self
114
+    private function requireTrue(bool $condition, string $conditionLabel, ?int $errorCode = null) : self
115 115
     {
116
-        if($condition === true)
116
+        if ($condition === true)
117 117
         {
118 118
             return $this;
119 119
         }
120 120
 
121
-        if($errorCode === null)
121
+        if ($errorCode === null)
122 122
         {
123 123
             $errorCode = FileHelper::ERROR_FILE_DOES_NOT_EXIST;
124 124
         }
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
      * @return $this
136 136
      * @throws FileHelper_Exception
137 137
      */
138
-    public function requireExists(?int $errorCode=null) : self
138
+    public function requireExists(?int $errorCode = null) : self
139 139
     {
140 140
         return $this->requireTrue(
141 141
             !empty($this->path) && realpath($this->path) !== false,
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
      * @return $this
150 150
      * @throws FileHelper_Exception
151 151
      */
152
-    public function requireReadable(?int $errorCode=null) : self
152
+    public function requireReadable(?int $errorCode = null) : self
153 153
     {
154 154
         $this->requireExists($errorCode);
155 155
 
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
      * @return $this
166 166
      * @throws FileHelper_Exception
167 167
      */
168
-    public function requireWritable(?int $errorCode=null) : self
168
+    public function requireWritable(?int $errorCode = null) : self
169 169
     {
170 170
         return $this->requireTrue(
171 171
             $this->isWritable(),
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
      */
183 183
     public function requireIsFile() : FileInfo
184 184
     {
185
-        if($this instanceof FileInfo)
185
+        if ($this instanceof FileInfo)
186 186
         {
187 187
             return $this;
188 188
         }
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
      */
206 206
     public function requireIsFolder() : FolderInfo
207 207
     {
208
-        if($this instanceof FolderInfo)
208
+        if ($this instanceof FolderInfo)
209 209
         {
210 210
             return $this;
211 211
         }
@@ -229,17 +229,17 @@  discard block
 block discarded – undo
229 229
      */
230 230
     public static function resolveType($path) : PathInfoInterface
231 231
     {
232
-        if($path instanceof DirectoryIterator)
232
+        if ($path instanceof DirectoryIterator)
233 233
         {
234 234
             $path = $path->getPathname();
235 235
         }
236 236
 
237
-        if(FolderInfo::is_dir($path))
237
+        if (FolderInfo::is_dir($path))
238 238
         {
239 239
             return FolderInfo::factory($path);
240 240
         }
241 241
 
242
-        if(FileInfo::is_file($path))
242
+        if (FileInfo::is_file($path))
243 243
         {
244 244
             return FileInfo::factory($path);
245 245
         }
Please login to merge, or discard this patch.
src/FileHelper/UnicodeHandling.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -27,12 +27,12 @@  discard block
 block discarded – undo
27 27
     /**
28 28
      * @var array<string,string>|NULL
29 29
      */
30
-    protected static ?array $utfBoms = null;
30
+    protected static ? array $utfBoms = null;
31 31
 
32 32
     /**
33 33
      * @var string[]|NULL
34 34
      */
35
-    protected static ?array $encodings = null;
35
+    protected static ? array $encodings = null;
36 36
 
37 37
     public function __construct()
38 38
     {
@@ -70,9 +70,9 @@  discard block
 block discarded – undo
70 70
 
71 71
         fclose($fp);
72 72
 
73
-        foreach(self::$utfBoms as $bom => $value)
73
+        foreach (self::$utfBoms as $bom => $value)
74 74
         {
75
-            if(mb_strpos($text, $value) === 0)
75
+            if (mb_strpos($text, $value) === 0)
76 76
             {
77 77
                 return $bom;
78 78
             }
@@ -83,23 +83,23 @@  discard block
 block discarded – undo
83 83
 
84 84
     private function initBOMs() : void
85 85
     {
86
-        if(isset(self::$utfBoms))
86
+        if (isset(self::$utfBoms))
87 87
         {
88 88
             return;
89 89
         }
90 90
 
91 91
         self::$utfBoms = array(
92
-            'UTF32-BE' => chr(0x00) . chr(0x00) . chr(0xFE) . chr(0xFF),
93
-            'UTF32-LE' => chr(0xFF) . chr(0xFE) . chr(0x00) . chr(0x00),
94
-            'UTF16-BE' => chr(0xFE) . chr(0xFF),
95
-            'UTF16-LE' => chr(0xFF) . chr(0xFE),
96
-            'UTF8' => chr(0xEF) . chr(0xBB) . chr(0xBF)
92
+            'UTF32-BE' => chr(0x00).chr(0x00).chr(0xFE).chr(0xFF),
93
+            'UTF32-LE' => chr(0xFF).chr(0xFE).chr(0x00).chr(0x00),
94
+            'UTF16-BE' => chr(0xFE).chr(0xFF),
95
+            'UTF16-LE' => chr(0xFF).chr(0xFE),
96
+            'UTF8' => chr(0xEF).chr(0xBB).chr(0xBF)
97 97
         );
98 98
     }
99 99
 
100 100
     private function initEncodings() : void
101 101
     {
102
-        if(isset(self::$encodings))
102
+        if (isset(self::$encodings))
103 103
         {
104 104
             return;
105 105
         }
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 
109 109
         self::$encodings = array();
110 110
 
111
-        foreach($encodings as $string)
111
+        foreach ($encodings as $string)
112 112
         {
113 113
             $withHyphen = str_replace('UTF', 'UTF-', $string);
114 114
 
Please login to merge, or discard this patch.