Passed
Push — master ( 125b29...554a92 )
by f
27:06 queued 12:02
created
src/Drivers/Zip.php 1 patch
Braces   +36 added lines, -24 removed lines patch added patch discarded remove patch
@@ -86,8 +86,9 @@  discard block
 block discarded – undo
86 86
     {
87 87
         parent::__construct($archiveFileName, $format);
88 88
         $this->open($archiveFileName);
89
-        if ($password !== null)
90
-            $this->zip->setPassword($password);
89
+        if ($password !== null) {
90
+                    $this->zip->setPassword($password);
91
+        }
91 92
     }
92 93
 
93 94
     /**
@@ -121,8 +122,9 @@  discard block
 block discarded – undo
121 122
         for ($i = 0; $i < $this->zip->numFiles; $i++) {
122 123
             $file = $this->zip->statIndex($i);
123 124
             // skip directories
124
-            if (in_array(substr($file['name'], -1), ['/', '\\'], true))
125
-                continue;
125
+            if (in_array(substr($file['name'], -1), ['/', '\\'], true)) {
126
+                            continue;
127
+            }
126 128
             $this->pureFilesNumber++;
127 129
             $information->files[$i] = $file['name'];
128 130
             $information->compressedFilesSize += $file['comp_size'];
@@ -157,8 +159,9 @@  discard block
 block discarded – undo
157 159
         for ($i = 0; $i < $this->zip->numFiles; $i++) {
158 160
             $file_name = $this->zip->getNameIndex($i);
159 161
             // skip directories
160
-            if (in_array(substr($file_name, -1), ['/', '\\'], true))
161
-                continue;
162
+            if (in_array(substr($file_name, -1), ['/', '\\'], true)) {
163
+                            continue;
164
+            }
162 165
             $files[] = $file_name;
163 166
         }
164 167
         return $files;
@@ -203,8 +206,9 @@  discard block
 block discarded – undo
203 206
     public function getFileContent($fileName)
204 207
     {
205 208
         $result = $this->zip->getFromName($fileName);
206
-        if ($result === false)
207
-            throw new Exception('Could not get file information: '.$result.'. May use password?');
209
+        if ($result === false) {
210
+                    throw new Exception('Could not get file information: '.$result.'. May use password?');
211
+        }
208 212
         return $result;
209 213
     }
210 214
 
@@ -225,8 +229,9 @@  discard block
 block discarded – undo
225 229
      */
226 230
     public function extractFiles($outputFolder, array $files)
227 231
     {
228
-        if ($this->zip->extractTo($outputFolder, $files) === false)
229
-            throw new ArchiveExtractionException($this->zip->getStatusString(), $this->zip->status);
232
+        if ($this->zip->extractTo($outputFolder, $files) === false) {
233
+                    throw new ArchiveExtractionException($this->zip->getStatusString(), $this->zip->status);
234
+        }
230 235
 
231 236
         return count($files);
232 237
     }
@@ -238,8 +243,9 @@  discard block
 block discarded – undo
238 243
      */
239 244
     public function extractArchive($outputFolder)
240 245
     {
241
-        if ($this->zip->extractTo($outputFolder) === false)
242
-            throw new ArchiveExtractionException($this->zip->getStatusString(), $this->zip->status);
246
+        if ($this->zip->extractTo($outputFolder) === false) {
247
+                    throw new ArchiveExtractionException($this->zip->getStatusString(), $this->zip->status);
248
+        }
243 249
 
244 250
         return $this->pureFilesNumber;
245 251
     }
@@ -254,8 +260,9 @@  discard block
 block discarded – undo
254 260
     {
255 261
         $count = 0;
256 262
         foreach ($files as $file) {
257
-            if ($this->zip->deleteName($file) === false)
258
-                throw new ArchiveModificationException($this->zip->getStatusString(), $this->zip->status);
263
+            if ($this->zip->deleteName($file) === false) {
264
+                            throw new ArchiveModificationException($this->zip->getStatusString(), $this->zip->status);
265
+            }
259 266
             $count++;
260 267
         }
261 268
 
@@ -278,11 +285,13 @@  discard block
 block discarded – undo
278 285
         $added_files = 0;
279 286
         foreach ($files as $localName => $fileName) {
280 287
             if (is_null($fileName)) {
281
-                if ($this->zip->addEmptyDir($localName) === false)
282
-                    throw new ArchiveModificationException($this->zip->getStatusString(), $this->zip->status);
288
+                if ($this->zip->addEmptyDir($localName) === false) {
289
+                                    throw new ArchiveModificationException($this->zip->getStatusString(), $this->zip->status);
290
+                }
283 291
             } else {
284
-                if ($this->zip->addFile($fileName, $localName) === false)
285
-                    throw new ArchiveModificationException($this->zip->getStatusString(), $this->zip->status);
292
+                if ($this->zip->addFile($fileName, $localName) === false) {
293
+                                    throw new ArchiveModificationException($this->zip->getStatusString(), $this->zip->status);
294
+                }
286 295
                 $added_files++;
287 296
             }
288 297
         }
@@ -335,8 +344,9 @@  discard block
 block discarded – undo
335 344
         $zip = new ZipArchive();
336 345
         $result = $zip->open($archiveFileName, ZipArchive::CREATE);
337 346
 
338
-        if ($result !== true)
339
-            throw new ArchiveCreationException('ZipArchive error: '.$result);
347
+        if ($result !== true) {
348
+                    throw new ArchiveCreationException('ZipArchive error: '.$result);
349
+        }
340 350
 
341 351
         $can_set_compression_level = method_exists($zip, 'setCompressionName');
342 352
         $can_encrypt = static::canEncrypt(Formats::ZIP);
@@ -354,11 +364,13 @@  discard block
 block discarded – undo
354 364
 
355 365
         foreach ($files as $localName => $fileName) {
356 366
             if ($fileName === null) {
357
-                if ($zip->addEmptyDir($localName) === false)
358
-                    throw new ArchiveCreationException('Could not archive directory "'.$localName.'": '.$zip->getStatusString(), $zip->status);
367
+                if ($zip->addEmptyDir($localName) === false) {
368
+                                    throw new ArchiveCreationException('Could not archive directory "'.$localName.'": '.$zip->getStatusString(), $zip->status);
369
+                }
359 370
             } else {
360
-                if ($zip->addFile($fileName, $localName) === false)
361
-                    throw new ArchiveCreationException('Could not archive file "'.$fileName.'": '.$zip->getStatusString(), $zip->status);
371
+                if ($zip->addFile($fileName, $localName) === false) {
372
+                                    throw new ArchiveCreationException('Could not archive file "'.$fileName.'": '.$zip->getStatusString(), $zip->status);
373
+                }
362 374
                 if ($can_set_compression_level) {
363 375
                     $zip->setCompressionName($localName, $compressionLevelMap[$compressionLevel]);
364 376
                 }
Please login to merge, or discard this patch.
src/Drivers/TarByPear.php 1 patch
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.
src/Drivers/AlchemyZippy.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -63,9 +63,9 @@  discard block
 block discarded – undo
63 63
     public static function getInstallationInstruction()
64 64
     {
65 65
         self::init();
66
-        return 'install library [alchemy/zippy]: `composer require alchemy/zippy`' . "\n"  . ' and console programs (tar, zip): `apt install tar zip` - depends on OS'
67
-            . "\n" . 'If you install SevenZip and AlchemyZippy:' . "\n" .
68
-            '1. You should specify symfony/console version before installation to any **3.x.x version**:' . "\n" . '`composer require symfony/process:~3.4`, because they require different `symfony/process` versions.' . "\n" .
66
+        return 'install library [alchemy/zippy]: `composer require alchemy/zippy`'."\n".' and console programs (tar, zip): `apt install tar zip` - depends on OS'
67
+            . "\n".'If you install SevenZip and AlchemyZippy:'."\n".
68
+            '1. You should specify symfony/console version before installation to any **3.x.x version**:'."\n".'`composer require symfony/process:~3.4`, because they require different `symfony/process` versions.'."\n".
69 69
             '2. Install archive7z version 4.0.0: `composer require gemorroj/archive7z:~4.0`';
70 70
     }
71 71
 
@@ -190,8 +190,8 @@  discard block
 block discarded – undo
190 190
 
191 191
             $this->files[] = $information->files[] = str_replace('\\', '/', $member->getLocation());
192 192
             $this->members[str_replace('\\', '/', $member->getLocation())] = $member;
193
-            $information->compressedFilesSize += (int)$member->getSize();
194
-            $information->uncompressedFilesSize += (int)$member->getSize();
193
+            $information->compressedFilesSize += (int) $member->getSize();
194
+            $information->uncompressedFilesSize += (int) $member->getSize();
195 195
         }
196 196
         return $information;
197 197
     }
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
     public function getFileContent($fileName)
241 241
     {
242 242
         $member = $this->getMember($fileName);
243
-        return (string)$member;
243
+        return (string) $member;
244 244
     }
245 245
 
246 246
     /**
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
     public function getFileStream($fileName)
250 250
     {
251 251
         $member = $this->getMember($fileName);
252
-        return self::wrapStringInStream((string)$member);
252
+        return self::wrapStringInStream((string) $member);
253 253
     }
254 254
 
255 255
     /**
Please login to merge, or discard this patch.
src/Drivers/Iso.php 1 patch
Braces   +18 added lines, -11 removed lines patch added patch discarded remove patch
@@ -84,8 +84,9 @@  discard block
 block discarded – undo
84 84
     {
85 85
         parent::__construct($archiveFileName, $format);
86 86
         $this->open($archiveFileName);
87
-        if ($password !== null)
88
-            throw new UnsupportedOperationException('Iso archive does not support password!');
87
+        if ($password !== null) {
88
+                    throw new UnsupportedOperationException('Iso archive does not support password!');
89
+        }
89 90
     }
90 91
 
91 92
     /**
@@ -108,8 +109,9 @@  discard block
 block discarded – undo
108 109
 
109 110
         /** @var \CVolumeDescriptor $usedDesc */
110 111
         $usedDesc = $this->iso->GetDescriptor(SUPPLEMENTARY_VOLUME_DESC);
111
-        if (!$usedDesc)
112
-            $usedDesc = $this->iso->GetDescriptor(PRIMARY_VOLUME_DESC);
112
+        if (!$usedDesc) {
113
+                    $usedDesc = $this->iso->GetDescriptor(PRIMARY_VOLUME_DESC);
114
+        }
113 115
         $this->blockSize = $usedDesc->iBlockSize;
114 116
         $directories = $usedDesc->LoadMPathTable($this->iso);
115 117
         // iterate over all directories
@@ -130,8 +132,9 @@  discard block
 block discarded – undo
130 132
             if ($files) {
131 133
                 /** @var \CFileDirDescriptors $file */
132 134
                 foreach ($files as $file) {
133
-                    if (in_array($file->strd_FileId, ['.', '..']) || $file->IsDirectory())
134
-                        continue;
135
+                    if (in_array($file->strd_FileId, ['.', '..']) || $file->IsDirectory()) {
136
+                                            continue;
137
+                    }
135 138
                     $this->files[$file->Location] = $directory.$file->strd_FileId;
136 139
                     $this->filesSize += $file->DataLen;
137 140
 
@@ -183,8 +186,9 @@  discard block
 block discarded – undo
183 186
      */
184 187
     public function getFileData($fileName)
185 188
     {
186
-        if (!isset($this->filesData[$fileName]))
187
-            return false;
189
+        if (!isset($this->filesData[$fileName])) {
190
+                    return false;
191
+        }
188 192
 
189 193
         return new ArchiveEntry($fileName, $this->filesData[$fileName]['size'],
190 194
             $this->filesData[$fileName]['size'], $this->filesData[$fileName]['mtime'],false);
@@ -219,11 +223,14 @@  discard block
 block discarded – undo
219 223
     protected function prepareForFileExtracting($fileName)
220 224
     {
221 225
         $Location = array_search($fileName, $this->files, true);
222
-        if (!isset($this->filesData[$fileName])) return false;
226
+        if (!isset($this->filesData[$fileName])) {
227
+         return false;
228
+        }
223 229
         $data = $this->filesData[$fileName];
224 230
         $Location_Real = $Location * $this->blockSize;
225
-        if ($this->iso->Seek($Location_Real, SEEK_SET) === false)
226
-            return false;
231
+        if ($this->iso->Seek($Location_Real, SEEK_SET) === false) {
232
+                    return false;
233
+        }
227 234
         return $data;
228 235
     }
229 236
 
Please login to merge, or discard this patch.
src/Drivers/OneFile/OneFileDriver.php 1 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/TarByPhar.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -213,7 +213,7 @@
 block discarded – undo
213 213
      */
214 214
     public function getFileStream($fileName)
215 215
     {
216
-        return fopen('phar://'.$this->fileName . '/' . $fileName, 'rb');
216
+        return fopen('phar://'.$this->fileName.'/'.$fileName, 'rb');
217 217
     }
218 218
 
219 219
     /**
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.