Passed
Push — master ( bf29cf...6612ae )
by f
15:14
created
src/Commands/FormatsCommand.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -33,19 +33,19 @@  discard block
 block discarded – undo
33 33
 
34 34
         if ($driver !== null) {
35 35
             if (strpos($driver, '\\') === false) {
36
-                if (class_exists('\\wapmorgan\\UnifiedArchive\\Drivers\\' . $driver)) {
37
-                    $driver = '\\wapmorgan\\UnifiedArchive\\Drivers\\' . $driver;
38
-                } else if (class_exists('\\wapmorgan\\UnifiedArchive\\Drivers\\OneFile\\' . $driver)) {
39
-                    $driver = '\\wapmorgan\\UnifiedArchive\\Drivers\\OneFile\\' . $driver;
36
+                if (class_exists('\\wapmorgan\\UnifiedArchive\\Drivers\\'.$driver)) {
37
+                    $driver = '\\wapmorgan\\UnifiedArchive\\Drivers\\'.$driver;
38
+                } else if (class_exists('\\wapmorgan\\UnifiedArchive\\Drivers\\OneFile\\'.$driver)) {
39
+                    $driver = '\\wapmorgan\\UnifiedArchive\\Drivers\\OneFile\\'.$driver;
40 40
                 }
41 41
             }
42 42
             if ($driver[0] !== '\\') {
43 43
                 $driver = '\\'.$driver;
44 44
             }
45 45
             if (!class_exists($driver) || !is_a($driver, BasicDriver::class, true)) {
46
-                throw new \InvalidArgumentException('Class "' . $driver . '" not found or not in BasicDriver children');
46
+                throw new \InvalidArgumentException('Class "'.$driver.'" not found or not in BasicDriver children');
47 47
             }
48
-            $output->writeln('Supported formats by <info>' . $driver . '</info>');
48
+            $output->writeln('Supported formats by <info>'.$driver.'</info>');
49 49
 
50 50
             $table->setHeaders(['format', ...array_keys(self::$abilitiesLabels)]);
51 51
             foreach ($driver::getSupportedFormats() as $i => $format) {
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
             return 0;
63 63
         }
64 64
 
65
-        $headers = array_map(function ($v) { return substr($v, strrpos($v, '\\') + 1);}, Formats::$drivers);
65
+        $headers = array_map(function($v) { return substr($v, strrpos($v, '\\') + 1); }, Formats::$drivers);
66 66
         array_unshift($headers, 'format');
67 67
 
68 68
         $table->setHeaders($headers);
Please login to merge, or discard this patch.
src/Commands/FormatCommand.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@
 block discarded – undo
41 41
             $question = new ChoiceQuestion('Which format', array_keys($formats));
42 42
             $format = $helper->ask($input, $output, $question);
43 43
         }
44
-        $output->writeln('Format <info>' . $format . '</info> drivers support');
44
+        $output->writeln('Format <info>'.$format.'</info> drivers support');
45 45
 
46 46
         $table = new Table($output);
47 47
         $table->setHeaders(['format', ...array_keys(self::$abilitiesLabels)]);
Please login to merge, or discard this patch.
src/Formats.php 1 patch
Braces   +12 added lines, -8 removed lines patch added patch discarded remove patch
@@ -174,8 +174,9 @@  discard block
 block discarded – undo
174 174
         // by file content
175 175
         if ($contentCheck) {
176 176
             $mime_type = mime_content_type($fileName);
177
-            if (isset(static::$mimeTypes[$mime_type]))
178
-                return static::$mimeTypes[$mime_type];
177
+            if (isset(static::$mimeTypes[$mime_type])) {
178
+                            return static::$mimeTypes[$mime_type];
179
+            }
179 180
         }
180 181
 
181 182
         return false;
@@ -299,15 +300,18 @@  discard block
 block discarded – undo
299 300
     {
300 301
         static::getAllPossibleFormatsAndDrivers();
301 302
 
302
-        if (!static::canOpen($format))
303
-            throw new UnsupportedArchiveException('Unsupported archive type: '.$format.' of archive ');
303
+        if (!static::canOpen($format)) {
304
+                    throw new UnsupportedArchiveException('Unsupported archive type: '.$format.' of archive ');
305
+        }
304 306
 
305
-        if (!$createAbility)
306
-            return static::$supportedDriversFormats[$format][0];
307
+        if (!$createAbility) {
308
+                    return static::$supportedDriversFormats[$format][0];
309
+        }
307 310
 
308 311
         foreach (static::$supportedDriversFormats[$format] as $driver) {
309
-            if ($driver::canCreateArchive($format))
310
-                return $driver;
312
+            if ($driver::canCreateArchive($format)) {
313
+                            return $driver;
314
+            }
311 315
         }
312 316
 
313 317
         return false;
Please login to merge, or discard this patch.
src/Drivers/SevenZip.php 1 patch
Braces   +24 added lines, -16 removed lines patch added patch discarded remove patch
@@ -120,12 +120,14 @@  discard block
 block discarded – undo
120 120
      */
121 121
     public static function getInstallationInstruction()
122 122
     {
123
-        if (!class_exists('\Archive7z\Archive7z'))
124
-            return 'install library [gemorroj/archive7z]: `composer require gemorroj/archive7z`' . "\n"
123
+        if (!class_exists('\Archive7z\Archive7z')) {
124
+                    return 'install library [gemorroj/archive7z]: `composer require gemorroj/archive7z`' . "\n"
125 125
                 . ' and console program p7zip [7za]: `apt install p7zip-full` - depends on OS';
126
+        }
126 127
 
127
-        if (Archive7z::getBinaryVersion() === false)
128
-            return 'install console program p7zip [7za]: `apt install p7zip-full` - depends on OS';
128
+        if (Archive7z::getBinaryVersion() === false) {
129
+                    return 'install console program p7zip [7za]: `apt install p7zip-full` - depends on OS';
130
+        }
129 131
 
130 132
         return null;
131 133
     }
@@ -138,8 +140,9 @@  discard block
 block discarded – undo
138 140
         try {
139 141
             $this->format = $format;
140 142
             $this->sevenZip = new Archive7z($archiveFileName, null, null);
141
-            if ($password !== null)
142
-                $this->sevenZip->setPassword($password);
143
+            if ($password !== null) {
144
+                            $this->sevenZip->setPassword($password);
145
+            }
143 146
         } catch (\Archive7z\Exception $e) {
144 147
             throw new Exception('Could not open 7Zip archive: '.$e->getMessage(), $e->getCode(), $e);
145 148
         }
@@ -157,8 +160,9 @@  discard block
 block discarded – undo
157 160
                 continue;
158 161
             }
159 162
 
160
-            if (!isset($can_get_unix_path))
161
-                $can_get_unix_path = method_exists($entry, 'getUnixPath');
163
+            if (!isset($can_get_unix_path)) {
164
+                            $can_get_unix_path = method_exists($entry, 'getUnixPath');
165
+            }
162 166
 
163 167
             $information->files[] = $can_get_unix_path
164 168
                 ? $entry->getUnixPath()
@@ -176,8 +180,9 @@  discard block
 block discarded – undo
176 180
     {
177 181
         $files = [];
178 182
         foreach ($this->sevenZip->getEntries() as $entry) {
179
-            if ($entry->isDirectory())
180
-                continue;
183
+            if ($entry->isDirectory()) {
184
+                            continue;
185
+            }
181 186
             $files[] = $entry->getPath();
182 187
         }
183 188
         return $files;
@@ -329,8 +334,9 @@  discard block
 block discarded – undo
329 334
     public function addFileFromString($inArchiveName, $content)
330 335
     {
331 336
         $tmp_file = tempnam(sys_get_temp_dir(), 'ua');
332
-        if (!$tmp_file)
333
-            throw new ArchiveModificationException('Could not create temporarily file');
337
+        if (!$tmp_file) {
338
+                    throw new ArchiveModificationException('Could not create temporarily file');
339
+        }
334 340
 
335 341
         file_put_contents($tmp_file, $content);
336 342
         $this->sevenZip->addEntry($tmp_file, true);
@@ -380,8 +386,9 @@  discard block
 block discarded – undo
380 386
             $total_files = count($files);
381 387
 
382 388
             $seven_zip = new Archive7z($archiveFileName);
383
-            if ($password !== null)
384
-                $seven_zip->setPassword($password);
389
+            if ($password !== null) {
390
+                            $seven_zip->setPassword($password);
391
+            }
385 392
             $seven_zip->setCompressionLevel($compressionLevelMap[$compressionLevel]);
386 393
             foreach ($files as $localName => $filename) {
387 394
                 if ($filename !== null) {
@@ -413,8 +420,9 @@  discard block
 block discarded – undo
413 420
             Formats::TAR,
414 421
             Formats::LZMA,
415 422
             Formats::ZIP]
416
-        ))
417
-            return self::canRenameFiles();
423
+        )) {
424
+                    return self::canRenameFiles();
425
+        }
418 426
 
419 427
         return false;
420 428
     }
Please login to merge, or discard this patch.
src/Drivers/TarByPear.php 1 patch
Braces   +26 added lines, -18 removed lines patch added patch discarded remove patch
@@ -165,10 +165,11 @@  discard block
 block discarded – undo
165 165
                 break;
166 166
         }
167 167
 
168
-        if (isset($tar_aname))
169
-            $tar = new Archive_Tar($tar_aname, $compression);
170
-        else
171
-            $tar = new Archive_Tar($archiveFileName, $compression);
168
+        if (isset($tar_aname)) {
169
+                    $tar = new Archive_Tar($tar_aname, $compression);
170
+        } else {
171
+                    $tar = new Archive_Tar($archiveFileName, $compression);
172
+        }
172 173
 
173 174
         $current_file = 0;
174 175
         $total_files = count($files);
@@ -177,11 +178,13 @@  discard block
 block discarded – undo
177 178
             $add_dir = dirname($localName);
178 179
 
179 180
             if (is_null($filename)) {
180
-                if ($tar->addString($localName, '') === false)
181
-                    throw new ArchiveCreationException('Error when adding directory '.$localName.' to archive');
181
+                if ($tar->addString($localName, '') === false) {
182
+                                    throw new ArchiveCreationException('Error when adding directory '.$localName.' to archive');
183
+                }
182 184
             } else {
183
-                if ($tar->addModify($filename, $add_dir, $remove_dir) === false)
184
-                    throw new ArchiveCreationException('Error when adding file '.$filename.' to archive');
185
+                if ($tar->addModify($filename, $add_dir, $remove_dir) === false) {
186
+                                    throw new ArchiveCreationException('Error when adding file '.$filename.' to archive');
187
+                }
185 188
             }
186 189
             if ($fileProgressCallable !== null) {
187 190
                 call_user_func_array($fileProgressCallable, [$current_file++, $total_files, $filename, $localName]);
@@ -242,8 +245,9 @@  discard block
 block discarded – undo
242 245
                 continue;
243 246
             }
244 247
             // skip directories
245
-            if ($file['typeflag'] == '5' || substr($file['filename'], -1) === '/')
246
-                continue;
248
+            if ($file['typeflag'] == '5' || substr($file['filename'], -1) === '/') {
249
+                            continue;
250
+            }
247 251
             $information->files[] = $file['filename'];
248 252
             $information->uncompressedFilesSize += $file['size'];
249 253
             $this->pearFilesIndex[$file['filename']] = $i;
@@ -289,14 +293,16 @@  discard block
 block discarded – undo
289 293
      */
290 294
     public function getFileData($fileName)
291 295
     {
292
-        if (!isset($this->pearFilesIndex[$fileName]))
293
-            throw new NonExistentArchiveFileException('File '.$fileName.' is not found in archive files list');
296
+        if (!isset($this->pearFilesIndex[$fileName])) {
297
+                    throw new NonExistentArchiveFileException('File '.$fileName.' is not found in archive files list');
298
+        }
294 299
 
295 300
         $index = $this->pearFilesIndex[$fileName];
296 301
 
297 302
         $files_list = $this->tar->listContent();
298
-        if (!isset($files_list[$index]))
299
-            throw new NonExistentArchiveFileException('File '.$fileName.' is not found in Tar archive');
303
+        if (!isset($files_list[$index])) {
304
+                    throw new NonExistentArchiveFileException('File '.$fileName.' is not found in Tar archive');
305
+        }
300 306
 
301 307
         $data = $files_list[$index];
302 308
         unset($files_list);
@@ -311,8 +317,9 @@  discard block
 block discarded – undo
311 317
      */
312 318
     public function getFileContent($fileName)
313 319
     {
314
-        if (!isset($this->pearFilesIndex[$fileName]))
315
-            throw new NonExistentArchiveFileException('File '.$fileName.' is not found in archive files list');
320
+        if (!isset($this->pearFilesIndex[$fileName])) {
321
+                    throw new NonExistentArchiveFileException('File '.$fileName.' is not found in archive files list');
322
+        }
316 323
 
317 324
         return $this->tar->extractInString($fileName);
318 325
     }
@@ -322,8 +329,9 @@  discard block
 block discarded – undo
322 329
      */
323 330
     public function getFileStream($fileName)
324 331
     {
325
-        if (!isset($this->pearFilesIndex[$fileName]))
326
-            throw new NonExistentArchiveFileException('File '.$fileName.' is not found in archive files list');
332
+        if (!isset($this->pearFilesIndex[$fileName])) {
333
+                    throw new NonExistentArchiveFileException('File '.$fileName.' is not found in archive files list');
334
+        }
327 335
 
328 336
         return self::wrapStringInStream($this->tar->extractInString($fileName));
329 337
     }
Please login to merge, or discard this patch.
src/Drivers/AlchemyZippy.php 1 patch
Braces   +11 added lines, -8 removed lines patch added patch discarded remove patch
@@ -61,10 +61,11 @@  discard block
 block discarded – undo
61 61
 
62 62
     protected static function init()
63 63
     {
64
-        if (!class_exists('\Alchemy\Zippy\Zippy'))
65
-            static::$zippy = false;
66
-        else if (static::$zippy === null)
67
-            static::$zippy = Zippy::load();
64
+        if (!class_exists('\Alchemy\Zippy\Zippy')) {
65
+                    static::$zippy = false;
66
+        } else if (static::$zippy === null) {
67
+                    static::$zippy = Zippy::load();
68
+        }
68 69
     }
69 70
 
70 71
     /**
@@ -75,8 +76,9 @@  discard block
 block discarded – undo
75 76
     {
76 77
         static::init();
77 78
 
78
-        if (static::$zippy === false)
79
-            return [];
79
+        if (static::$zippy === false) {
80
+                    return [];
81
+        }
80 82
 
81 83
         switch ($format) {
82 84
             case Formats::TAR_BZIP:
@@ -212,8 +214,9 @@  discard block
 block discarded – undo
212 214
         $information = new ArchiveInformation();
213 215
 
214 216
         foreach ($this->archive->getMembers() as $member) {
215
-            if ($member->isDir())
216
-                continue;
217
+            if ($member->isDir()) {
218
+                            continue;
219
+            }
217 220
 
218 221
             $this->files[] = $information->files[] = str_replace('\\', '/', $member->getLocation());
219 222
             $this->members[str_replace('\\', '/', $member->getLocation())] = $member;
Please login to merge, or discard this patch.
src/Drivers/Rar.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
      */
52 52
     public static function getDescription()
53 53
     {
54
-        return 'adapter for ext-rar' . (extension_loaded('rar') ? ' (' . phpversion('rar') . ')' : null);
54
+        return 'adapter for ext-rar'.(extension_loaded('rar') ? ' ('.phpversion('rar').')' : null);
55 55
     }
56 56
 
57 57
     /**
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
     public static function getInstallationInstruction()
61 61
     {
62 62
         return !extension_loaded('rar')
63
-            ? 'install [rar] extension.' . "\n" . 'Can be installed with pecl: `pecl install rar`'
63
+            ? 'install [rar] extension.'."\n".'Can be installed with pecl: `pecl install rar`'
64 64
             : null;
65 65
     }
66 66
 
Please login to merge, or discard this patch.