Passed
Push — master ( afad4e...ae0184 )
by f
40:32 queued 25:34
created
src/Drivers/OneFile/Bzip.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@
 block discarded – undo
7 7
 
8 8
 class Bzip extends OneFileDriver
9 9
 {
10
-    const FORMAT_SUFFIX =  'bz2';
10
+    const FORMAT_SUFFIX = 'bz2';
11 11
     const PHP_EXTENSION = 'bz2';
12 12
     const FORMAT = Formats::BZIP;
13 13
 
Please login to merge, or discard this patch.
src/Drivers/OneFile/OneFileDriver.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@
 block discarded – undo
31 31
 
32 32
     public static function getInstallationInstruction()
33 33
     {
34
-        return 'install `' . static::PHP_EXTENSION . '` extension';
34
+        return 'install `'.static::PHP_EXTENSION.'` extension';
35 35
     }
36 36
 
37 37
     public static function getSupportedFormats()
Please login to merge, or discard this patch.
Braces   +9 added lines, -6 removed lines patch added patch discarded remove patch
@@ -59,10 +59,12 @@  discard block
 block discarded – undo
59 59
      */
60 60
     public function __construct($archiveFileName, $format, $password = null)
61 61
     {
62
-        if (static::FORMAT_SUFFIX === null)
63
-            throw new \Exception('Format should be initialized');
64
-        if ($password !== null)
65
-            throw new UnsupportedOperationException(self::FORMAT_SUFFIX.' archive does not support password!');
62
+        if (static::FORMAT_SUFFIX === null) {
63
+                    throw new \Exception('Format should be initialized');
64
+        }
65
+        if ($password !== null) {
66
+                    throw new UnsupportedOperationException(self::FORMAT_SUFFIX.' archive does not support password!');
67
+        }
66 68
 
67 69
         parent::__construct($archiveFileName, $format);
68 70
 
@@ -131,8 +133,9 @@  discard block
 block discarded – undo
131 133
     public function extractArchive($outputFolder)
132 134
     {
133 135
         $data = $this->getFileContent($this->inArchiveFileName);
134
-        if ($data === false)
135
-            throw new ArchiveExtractionException('Could not extract archive');
136
+        if ($data === false) {
137
+                    throw new ArchiveExtractionException('Could not extract archive');
138
+        }
136 139
 
137 140
         $size = strlen($data);
138 141
         $written = file_put_contents($outputFolder.$this->inArchiveFileName, $data);
Please login to merge, or discard this patch.
src/Drivers/OneFile/Lzma.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
  */
14 14
 class Lzma extends OneFileDriver
15 15
 {
16
-    const FORMAT_SUFFIX =  'xz';
16
+    const FORMAT_SUFFIX = 'xz';
17 17
     const PHP_EXTENSION = 'xz';
18 18
     const FORMAT = Formats::LZMA;
19 19
 
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
      */
31 31
     public static function getInstallationInstruction()
32 32
     {
33
-        return 'install [xz] extension' . "\n" . 'For 5.x: https://github.com/payden/php-xz' . "\n" . 'For 7.x/8.x: https://github.com/codemasher/php-ext-xz';
33
+        return 'install [xz] extension'."\n".'For 5.x: https://github.com/payden/php-xz'."\n".'For 7.x/8.x: https://github.com/codemasher/php-ext-xz';
34 34
     }
35 35
 
36 36
     /**
Please login to merge, or discard this patch.
src/Drivers/TarByPear.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
      */
54 54
     public static function getInstallationInstruction()
55 55
     {
56
-        return 'install library [pear/archive_tar]: `composer require pear/archive_tar`' . "\n"  . ' and optionally php-extensions (zlib, bz2)';
56
+        return 'install library [pear/archive_tar]: `composer require pear/archive_tar`'."\n".' and optionally php-extensions (zlib, bz2)';
57 57
     }
58 58
 
59 59
     /**
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
                 $compression = 'lzma2';
161 161
                 break;
162 162
             case 'z':
163
-                $tar_aname = 'compress.lzw://' . $archiveFileName;
163
+                $tar_aname = 'compress.lzw://'.$archiveFileName;
164 164
                 break;
165 165
         }
166 166
 
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
 
218 218
             case Formats::TAR_LZW:
219 219
                 LzwStreamWrapper::registerWrapper();
220
-                $this->tar = new Archive_Tar('compress.lzw://' . $this->fileName);
220
+                $this->tar = new Archive_Tar('compress.lzw://'.$this->fileName);
221 221
                 break;
222 222
 
223 223
             default:
@@ -335,7 +335,7 @@  discard block
 block discarded – undo
335 335
         $result = $this->tar->extractList($files, $outputFolder);
336 336
         if ($result === false) {
337 337
             if (isset($this->tar->error_object)) {
338
-                throw new ArchiveExtractionException('Error when extracting from ' . $this->fileName . ': ' . $this->tar->error_object->getMessage(0));
338
+                throw new ArchiveExtractionException('Error when extracting from '.$this->fileName.': '.$this->tar->error_object->getMessage(0));
339 339
             }
340 340
             throw new ArchiveExtractionException('Error when extracting from '.$this->fileName);
341 341
         }
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
         $result = $this->tar->extract($outputFolder);
352 352
         if ($result === false) {
353 353
             if (isset($this->tar->error_object)) {
354
-                throw new ArchiveExtractionException('Error when extracting ' . $this->fileName . ': '
354
+                throw new ArchiveExtractionException('Error when extracting '.$this->fileName.': '
355 355
                                                      . $this->tar->error_object->toString()
356 356
                 );
357 357
             }
Please login to merge, or discard this patch.
Braces   +23 added lines, -16 removed lines patch added patch discarded remove patch
@@ -164,10 +164,11 @@  discard block
 block discarded – undo
164 164
                 break;
165 165
         }
166 166
 
167
-        if (isset($tar_aname))
168
-            $tar = new Archive_Tar($tar_aname, $compression);
169
-        else
170
-            $tar = new Archive_Tar($archiveFileName, $compression);
167
+        if (isset($tar_aname)) {
168
+                    $tar = new Archive_Tar($tar_aname, $compression);
169
+        } else {
170
+                    $tar = new Archive_Tar($archiveFileName, $compression);
171
+        }
171 172
 
172 173
         $current_file = 0;
173 174
         $total_files = count($files);
@@ -179,8 +180,9 @@  discard block
 block discarded – undo
179 180
 //                if ($tar->addString($localName, '') === false)
180 181
 //                    throw new ArchiveCreationException('Error when adding directory '.$localName.' to archive');
181 182
             } else {
182
-                if ($tar->addModify($filename, $add_dir, $remove_dir) === false)
183
-                    throw new ArchiveCreationException('Error when adding file '.$filename.' to archive');
183
+                if ($tar->addModify($filename, $add_dir, $remove_dir) === false) {
184
+                                    throw new ArchiveCreationException('Error when adding file '.$filename.' to archive');
185
+                }
184 186
             }
185 187
             if ($fileProgressCallable !== null) {
186 188
                 call_user_func_array($fileProgressCallable, [$current_file++, $total_files, $filename, $localName]);
@@ -241,8 +243,9 @@  discard block
 block discarded – undo
241 243
                 continue;
242 244
             }
243 245
             // skip directories
244
-            if ($file['typeflag'] == '5' || substr($file['filename'], -1) === '/')
245
-                continue;
246
+            if ($file['typeflag'] == '5' || substr($file['filename'], -1) === '/') {
247
+                            continue;
248
+            }
246 249
             $information->files[] = $file['filename'];
247 250
             $information->uncompressedFilesSize += $file['size'];
248 251
             $this->pearFilesIndex[$file['filename']] = $i;
@@ -288,14 +291,16 @@  discard block
 block discarded – undo
288 291
      */
289 292
     public function getFileData($fileName)
290 293
     {
291
-        if (!isset($this->pearFilesIndex[$fileName]))
292
-            throw new NonExistentArchiveFileException('File '.$fileName.' is not found in archive files list');
294
+        if (!isset($this->pearFilesIndex[$fileName])) {
295
+                    throw new NonExistentArchiveFileException('File '.$fileName.' is not found in archive files list');
296
+        }
293 297
 
294 298
         $index = $this->pearFilesIndex[$fileName];
295 299
 
296 300
         $files_list = $this->tar->listContent();
297
-        if (!isset($files_list[$index]))
298
-            throw new NonExistentArchiveFileException('File '.$fileName.' is not found in Tar archive');
301
+        if (!isset($files_list[$index])) {
302
+                    throw new NonExistentArchiveFileException('File '.$fileName.' is not found in Tar archive');
303
+        }
299 304
 
300 305
         $data = $files_list[$index];
301 306
         unset($files_list);
@@ -310,8 +315,9 @@  discard block
 block discarded – undo
310 315
      */
311 316
     public function getFileContent($fileName)
312 317
     {
313
-        if (!isset($this->pearFilesIndex[$fileName]))
314
-            throw new NonExistentArchiveFileException('File '.$fileName.' is not found in archive files list');
318
+        if (!isset($this->pearFilesIndex[$fileName])) {
319
+                    throw new NonExistentArchiveFileException('File '.$fileName.' is not found in archive files list');
320
+        }
315 321
 
316 322
         return $this->tar->extractInString($fileName);
317 323
     }
@@ -321,8 +327,9 @@  discard block
 block discarded – undo
321 327
      */
322 328
     public function getFileStream($fileName)
323 329
     {
324
-        if (!isset($this->pearFilesIndex[$fileName]))
325
-            throw new NonExistentArchiveFileException('File '.$fileName.' is not found in archive files list');
330
+        if (!isset($this->pearFilesIndex[$fileName])) {
331
+                    throw new NonExistentArchiveFileException('File '.$fileName.' is not found in archive files list');
332
+        }
326 333
 
327 334
         return self::wrapStringInStream($this->tar->extractInString($fileName));
328 335
     }
Please login to merge, or discard this patch.
src/Drivers/Cab.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -82,8 +82,9 @@
 block discarded – undo
82 82
     public function __construct($archiveFileName, $format, $password = null)
83 83
     {
84 84
         parent::__construct($archiveFileName, $format);
85
-        if ($password !== null)
86
-            throw new UnsupportedOperationException('Cab archive does not support password!');
85
+        if ($password !== null) {
86
+                    throw new UnsupportedOperationException('Cab archive does not support password!');
87
+        }
87 88
         $this->open($archiveFileName);
88 89
     }
89 90
 
Please login to merge, or discard this patch.
src/Commands/TestCommand.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@
 block discarded – undo
27 27
 
28 28
         $errored = [];
29 29
         foreach ($files as $file) {
30
-            $output->write($file . ' ... ');
30
+            $output->write($file.' ... ');
31 31
             if ($archive->test($file) === true) {
32 32
                 $output->writeln('<info>ok</info>');
33 33
             } else {
Please login to merge, or discard this patch.
src/Commands/InfoCommand.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -27,15 +27,15 @@
 block discarded – undo
27 27
         $file = realpath($input->getArgument('archive'));
28 28
         $archive = $this->getArchive($input, $output);
29 29
 
30
-        $output->writeln('Filename: ' . $file . ' (changed <comment>' . $this->formatDate(filemtime($file)) . '</comment>)');
31
-        $output->writeln('Type: <info>' . $archive->getFormat() . '</info>, mime <info>' . $archive->getMimeType() . '</info> (via driver <comment>' . $archive->getDriverType() . '</comment>)');
32
-        $output->writeln('Contains: ' . $archive->countFiles() . ' file' . ($archive->countFiles() > 1 ? 's' : null));
30
+        $output->writeln('Filename: '.$file.' (changed <comment>'.$this->formatDate(filemtime($file)).'</comment>)');
31
+        $output->writeln('Type: <info>'.$archive->getFormat().'</info>, mime <info>'.$archive->getMimeType().'</info> (via driver <comment>'.$archive->getDriverType().'</comment>)');
32
+        $output->writeln('Contains: '.$archive->countFiles().' file'.($archive->countFiles() > 1 ? 's' : null));
33 33
         $output->writeln('Size:');
34
-        $output->writeln("\t". 'uncompressed: '.implode(' ', $this->formatSize($archive->getOriginalSize(), 2)));
35
-        $output->writeln("\t" . 'compressed: ' . implode(' ', $this->formatSize($archive->getCompressedSize(), 2)));
36
-        $output->writeln("\t" . 'ratio: <info>' . round($archive->getOriginalSize() / $archive->getCompressedSize(), 6) . '/1 (' . floor($archive->getCompressedSize() / $archive->getOriginalSize() * 100) . '%</info>)');
34
+        $output->writeln("\t".'uncompressed: '.implode(' ', $this->formatSize($archive->getOriginalSize(), 2)));
35
+        $output->writeln("\t".'compressed: '.implode(' ', $this->formatSize($archive->getCompressedSize(), 2)));
36
+        $output->writeln("\t".'ratio: <info>'.round($archive->getOriginalSize() / $archive->getCompressedSize(), 6).'/1 ('.floor($archive->getCompressedSize() / $archive->getOriginalSize() * 100).'%</info>)');
37 37
         if ($archive->getDriver()->checkAbility(BasicDriver::GET_COMMENT) && !empty($comment = $archive->getComment()))
38
-            $output->writeln('Comment: <comment>' . $comment . '</comment>');
38
+            $output->writeln('Comment: <comment>'.$comment.'</comment>');
39 39
 
40 40
         return 0;
41 41
     }
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -34,8 +34,9 @@
 block discarded – undo
34 34
         $output->writeln("\t". 'uncompressed: '.implode(' ', $this->formatSize($archive->getOriginalSize(), 2)));
35 35
         $output->writeln("\t" . 'compressed: ' . implode(' ', $this->formatSize($archive->getCompressedSize(), 2)));
36 36
         $output->writeln("\t" . 'ratio: <info>' . round($archive->getOriginalSize() / $archive->getCompressedSize(), 6) . '/1 (' . floor($archive->getCompressedSize() / $archive->getOriginalSize() * 100) . '%</info>)');
37
-        if ($archive->getDriver()->checkAbility(BasicDriver::GET_COMMENT) && !empty($comment = $archive->getComment()))
38
-            $output->writeln('Comment: <comment>' . $comment . '</comment>');
37
+        if ($archive->getDriver()->checkAbility(BasicDriver::GET_COMMENT) && !empty($comment = $archive->getComment())) {
38
+                    $output->writeln('Comment: <comment>' . $comment . '</comment>');
39
+        }
39 40
 
40 41
         return 0;
41 42
     }
Please login to merge, or discard this patch.
src/Commands/BaseCommand.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -114,10 +114,10 @@
 block discarded – undo
114 114
     protected function resolveDriverName($driver)
115 115
     {
116 116
         if (strpos($driver, '\\') === false) {
117
-            if (class_exists('\\wapmorgan\\UnifiedArchive\\Drivers\\' . $driver)) {
118
-                $driver = '\\wapmorgan\\UnifiedArchive\\Drivers\\' . $driver;
119
-            } else if (class_exists('\\wapmorgan\\UnifiedArchive\\Drivers\\OneFile\\' . $driver)) {
120
-                $driver = '\\wapmorgan\\UnifiedArchive\\Drivers\\OneFile\\' . $driver;
117
+            if (class_exists('\\wapmorgan\\UnifiedArchive\\Drivers\\'.$driver)) {
118
+                $driver = '\\wapmorgan\\UnifiedArchive\\Drivers\\'.$driver;
119
+            } else if (class_exists('\\wapmorgan\\UnifiedArchive\\Drivers\\OneFile\\'.$driver)) {
120
+                $driver = '\\wapmorgan\\UnifiedArchive\\Drivers\\OneFile\\'.$driver;
121 121
             }
122 122
         }
123 123
         if ($driver[0] !== '\\') {
Please login to merge, or discard this patch.
Braces   +16 added lines, -13 removed lines patch added patch discarded remove patch
@@ -43,12 +43,14 @@  discard block
 block discarded – undo
43 43
      */
44 44
     protected function open($file, $password = null)
45 45
     {
46
-        if (!UnifiedArchive::canOpen($file))
47
-            throw new \Exception('Could not open archive '.$file.'. Try installing suggested packages or run `cam -f` to see formats support.');
46
+        if (!UnifiedArchive::canOpen($file)) {
47
+                    throw new \Exception('Could not open archive '.$file.'. Try installing suggested packages or run `cam -f` to see formats support.');
48
+        }
48 49
 
49 50
         $archive = UnifiedArchive::open($file, [], $password);
50
-        if ($archive === null)
51
-            throw new \Exception('Could not open archive '.$file);
51
+        if ($archive === null) {
52
+                    throw new \Exception('Could not open archive '.$file);
53
+        }
52 54
 
53 55
         return $archive;
54 56
     }
@@ -61,17 +63,18 @@  discard block
 block discarded – undo
61 63
      */
62 64
     public function formatDate($unixtime)
63 65
     {
64
-        if (strtotime('today') < $unixtime)
65
-            return 'Today, '.date('G:m', $unixtime);
66
-        else if (strtotime('yesterday') < $unixtime)
67
-            return 'Yesterday, '.date('G:m', $unixtime);
68
-        else {
66
+        if (strtotime('today') < $unixtime) {
67
+                    return 'Today, '.date('G:m', $unixtime);
68
+        } else if (strtotime('yesterday') < $unixtime) {
69
+                    return 'Yesterday, '.date('G:m', $unixtime);
70
+        } else {
69 71
             $datetime = new \DateTime();
70 72
             $datetime->setTimestamp($unixtime);
71
-            if ($datetime->format('Y') == date('Y'))
72
-                return $datetime->format('d M, H:m');
73
-            else
74
-                return $datetime->format('d M Y, H:m');
73
+            if ($datetime->format('Y') == date('Y')) {
74
+                            return $datetime->format('d M, H:m');
75
+            } else {
76
+                            return $datetime->format('d M Y, H:m');
77
+            }
75 78
         }
76 79
     }
77 80
 
Please login to merge, or discard this patch.
src/Commands/FormatsCommand.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -33,9 +33,9 @@  discard block
 block discarded – undo
33 33
         if ($driver !== null) {
34 34
             $driver = $this->resolveDriverName($driver);
35 35
             if (!class_exists($driver) || !is_a($driver, BasicDriver::class, true)) {
36
-                throw new \InvalidArgumentException('Class "' . $driver . '" not found or not in BasicDriver children');
36
+                throw new \InvalidArgumentException('Class "'.$driver.'" not found or not in BasicDriver children');
37 37
             }
38
-            $output->writeln('Supported formats by <info>' . $driver . '</info>');
38
+            $output->writeln('Supported formats by <info>'.$driver.'</info>');
39 39
 
40 40
             $table->setHeaders(['format', ...array_keys(self::$abilitiesLabels)]);
41 41
             foreach ($driver::getSupportedFormats() as $i => $format) {
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
         $table->render();
87 87
 
88 88
         foreach (array_combine(array_values(self::$abilitiesShortCuts), array_keys(self::$abilitiesLabels)) as $shortCut => $label) {
89
-            $output->writeln('<info>' . $shortCut . '</info> - ' . $label);
89
+            $output->writeln('<info>'.$shortCut.'</info> - '.$label);
90 90
         }
91 91
 
92 92
         return 0;
Please login to merge, or discard this patch.