Passed
Push — master ( 96860e...392c1d )
by f
11:16
created
src/Commands/BaseArchiveCommand.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -29,20 +29,20 @@
 block discarded – undo
29 29
     protected function getArchive(InputInterface $input, OutputInterface $output)
30 30
     {
31 31
         $file = realpath($input->getArgument('archive'));
32
-        $output->writeln('<comment>Opening ' . $file . '</comment>', OutputInterface::VERBOSITY_VERY_VERBOSE);
32
+        $output->writeln('<comment>Opening '.$file.'</comment>', OutputInterface::VERBOSITY_VERY_VERBOSE);
33 33
         if (!is_file($file)) {
34
-            throw new \InvalidArgumentException('File ' . $input->getArgument('archive') . ' is not accessible');
34
+            throw new \InvalidArgumentException('File '.$input->getArgument('archive').' is not accessible');
35 35
         }
36
-        $output->writeln('<comment>Format ' . Formats::detectArchiveFormat($file).'</comment>', OutputInterface::VERBOSITY_VERY_VERBOSE);
36
+        $output->writeln('<comment>Format '.Formats::detectArchiveFormat($file).'</comment>', OutputInterface::VERBOSITY_VERY_VERBOSE);
37 37
         $password = $input->getOption('password');
38 38
         if (empty($password)) {
39 39
             $password = null;
40 40
         } else {
41
-            $output->writeln('<comment>Passing password: ' . strlen($password).'</comment>', OutputInterface::VERBOSITY_VERY_VERBOSE);
41
+            $output->writeln('<comment>Passing password: '.strlen($password).'</comment>', OutputInterface::VERBOSITY_VERY_VERBOSE);
42 42
         }
43 43
         $archive = $this->open($file, $password);
44
-        $output->writeln('<comment>Driver ' . $archive->getDriverType() . '</comment>', OutputInterface::VERBOSITY_VERBOSE);
45
-        $output->writeln('<comment>Driver abilities: ' . implode(', ', $this->getDriverFormatAbilities($archive->getDriverType(), $archive->getFormat())) . '</comment>', OutputInterface::VERBOSITY_VERBOSE);
44
+        $output->writeln('<comment>Driver '.$archive->getDriverType().'</comment>', OutputInterface::VERBOSITY_VERBOSE);
45
+        $output->writeln('<comment>Driver abilities: '.implode(', ', $this->getDriverFormatAbilities($archive->getDriverType(), $archive->getFormat())).'</comment>', OutputInterface::VERBOSITY_VERBOSE);
46 46
         return $archive;
47 47
     }
48 48
 
Please login to merge, or discard this patch.
src/Commands/CreateCommand.php 2 patches
Braces   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -58,9 +58,9 @@
 block discarded – undo
58 58
         $comment = $input->getOption('comment');
59 59
 
60 60
         if (file_exists($archive_file)) {
61
-            if (is_dir($archive_file))
62
-                throw new \InvalidArgumentException($archive_file . ' is a directory!');
63
-            else {
61
+            if (is_dir($archive_file)) {
62
+                            throw new \InvalidArgumentException($archive_file . ' is a directory!');
63
+            } else {
64 64
                 throw new \InvalidArgumentException('File "' . $archive_file . '" already exists!');
65 65
             }
66 66
         }
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
         $password = $input->getOption('password');
48 48
         $compression = $input->getOption('compression');
49 49
         if (!isset(static::$compressionLevels[$compression])) {
50
-            throw new \InvalidArgumentException('Compression "' . $compression . '" is not valid');
50
+            throw new \InvalidArgumentException('Compression "'.$compression.'" is not valid');
51 51
         }
52 52
         $compression = static::$compressionLevels[$compression];
53 53
         $path = $input->getOption('path');
@@ -59,9 +59,9 @@  discard block
 block discarded – undo
59 59
 
60 60
         if (file_exists($archive_file)) {
61 61
             if (is_dir($archive_file))
62
-                throw new \InvalidArgumentException($archive_file . ' is a directory!');
62
+                throw new \InvalidArgumentException($archive_file.' is a directory!');
63 63
             else {
64
-                throw new \InvalidArgumentException('File "' . $archive_file . '" already exists!');
64
+                throw new \InvalidArgumentException('File "'.$archive_file.'" already exists!');
65 65
             }
66 66
         }
67 67
 
@@ -73,11 +73,11 @@  discard block
 block discarded – undo
73 73
                 case 'full':
74 74
                     $destination = ltrim($file_to_pack, '/');
75 75
                     $files_list[$destination] = $file_to_pack;
76
-                    $output->writeln('<comment>' . $file_to_pack . ' => ' . $destination . '</comment>', OutputInterface::VERBOSITY_VERBOSE);
76
+                    $output->writeln('<comment>'.$file_to_pack.' => '.$destination.'</comment>', OutputInterface::VERBOSITY_VERBOSE);
77 77
                     break;
78 78
                 case 'root':
79 79
                     if (is_dir($file_to_pack)) {
80
-                        $output->writeln('<comment>' . $file_to_pack . ' => root</comment>', OutputInterface::VERBOSITY_VERBOSE);
80
+                        $output->writeln('<comment>'.$file_to_pack.' => root</comment>', OutputInterface::VERBOSITY_VERBOSE);
81 81
                         if (!isset($files_list[''])) {
82 82
                             $files_list[''] = $file_to_pack;
83 83
                         } elseif (is_string($files_list[''])) {
@@ -86,35 +86,35 @@  discard block
 block discarded – undo
86 86
                             $files_list[''][] = $file_to_pack;
87 87
                         }
88 88
                     } else {
89
-                        $output->writeln('<comment>' . $file_to_pack . ' => ' . basename($file_to_pack) . '</comment>', OutputInterface::VERBOSITY_VERBOSE);
89
+                        $output->writeln('<comment>'.$file_to_pack.' => '.basename($file_to_pack).'</comment>', OutputInterface::VERBOSITY_VERBOSE);
90 90
                         $files_list[basename($file_to_pack)] = $file_to_pack;
91 91
                     }
92 92
                     break;
93 93
                 case 'relative':
94 94
                     $destination = ltrim($file_to_pack, '/.');
95 95
                     $files_list[$destination] = $file_to_pack;
96
-                    $output->writeln('<comment>' . $file_to_pack . ' => ' . $destination . '</comment>', OutputInterface::VERBOSITY_VERBOSE);
96
+                    $output->writeln('<comment>'.$file_to_pack.' => '.$destination.'</comment>', OutputInterface::VERBOSITY_VERBOSE);
97 97
                     break;
98 98
                 case 'basename':
99 99
                     $destination = basename($file_to_pack);
100 100
                     $files_list[$destination] = $file_to_pack;
101
-                    $output->writeln('<comment>' . $file_to_pack . ' => ' . $destination . '</comment>', OutputInterface::VERBOSITY_VERBOSE);
101
+                    $output->writeln('<comment>'.$file_to_pack.' => '.$destination.'</comment>', OutputInterface::VERBOSITY_VERBOSE);
102 102
                     break;
103 103
             }
104 104
         }
105 105
 
106 106
         $information = UnifiedArchive::prepareForArchiving($files_list, $archive_file);
107 107
         if ($dry_run) {
108
-            $output->writeln('Format: <info>' . $information['type'] . '</info>');
109
-            $output->writeln('Original size: <info>' . implode($this->formatSize($information['totalSize'])) . '</info>');
110
-            $output->writeln('Files: <info>' . $information['numberOfFiles'] . '</info>');
108
+            $output->writeln('Format: <info>'.$information['type'].'</info>');
109
+            $output->writeln('Original size: <info>'.implode($this->formatSize($information['totalSize'])).'</info>');
110
+            $output->writeln('Files: <info>'.$information['numberOfFiles'].'</info>');
111 111
             foreach ($information['files'] as $destination => $source) {
112 112
                 // is folder
113 113
                 if ($source === null) {
114 114
                     continue;
115 115
                 }
116 116
 
117
-                $output->writeln($source . ' => <comment>' . $destination . '</comment>');
117
+                $output->writeln($source.' => <comment>'.$destination.'</comment>');
118 118
             }
119 119
             return 0;
120 120
         }
@@ -124,10 +124,10 @@  discard block
 block discarded – undo
124 124
         $progressBar = new ProgressBar($output, $information['numberOfFiles']);
125 125
         $progressBar->setFormat('archiving');
126 126
         $progressBar->start();
127
-        $archived_files = UnifiedArchive::archiveFiles($files_list, $archive_file, $compression, $password, function ($currentFile, $totalFiles, $fsFilename, $archiveFilename)
127
+        $archived_files = UnifiedArchive::archiveFiles($files_list, $archive_file, $compression, $password, function($currentFile, $totalFiles, $fsFilename, $archiveFilename)
128 128
             use ($progressBar) {
129 129
             if ($fsFilename === null) {
130
-                $progressBar->setMessage('Creating ' . $archiveFilename);
130
+                $progressBar->setMessage('Creating '.$archiveFilename);
131 131
             } else {
132 132
                 $progressBar->setMessage($fsFilename);
133 133
             }
@@ -146,8 +146,8 @@  discard block
 block discarded – undo
146 146
             $archive->setComment($comment);
147 147
         }
148 148
 
149
-        $output->writeln('Created <info>' . $archive_file . '</info> with <comment>' . $archived_files . '</comment> file(s) ('
150
-                         . implode($this->formatSize($archive->getOriginalSize())) . ') of total size '
149
+        $output->writeln('Created <info>'.$archive_file.'</info> with <comment>'.$archived_files.'</comment> file(s) ('
150
+                         . implode($this->formatSize($archive->getOriginalSize())).') of total size '
151 151
                          . implode($this->formatSize(filesize($archive_file))));
152 152
 
153 153
         return 0;
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(['driver', 'open', 'stream', 'create', 'append', 'update', 'encrypt']);
Please login to merge, or discard this patch.
src/Commands/ListCommand.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -60,17 +60,17 @@
 block discarded – undo
60 60
             foreach ($archive->getFileNames($filter) as $file) {
61 61
                 $details = $archive->getFileData($file);
62 62
                 $output->writeln(($details->isCompressed && $details->uncompressedSize > 0 ? 'x' : '-')
63
-                                 . ' ' . str_pad(
63
+                                 . ' '.str_pad(
64 64
                                      $human_readable_size ? implode($this->formatSize($details->uncompressedSize)) : $details->uncompressedSize,
65 65
                                      $uncomp_size_length,
66 66
                                      ' ',
67 67
                                      STR_PAD_LEFT)
68
-                                 . ' ' . str_pad(
68
+                                 . ' '.str_pad(
69 69
                                      $human_readable_size ? implode($this->formatSize($details->compressedSize)) : $details->compressedSize,
70 70
                                      $comp_size_length,
71 71
                                      ' ',
72 72
                                      STR_PAD_LEFT)
73
-                                 . ' ' . $this->formatDateShort($details->modificationTime) . ' ' . $details->path);
73
+                                 . ' '.$this->formatDateShort($details->modificationTime).' '.$details->path);
74 74
             }
75 75
         } else {
76 76
             foreach ($archive->getFileNames($filter) as $file) {
Please login to merge, or discard this patch.
src/Commands/DriversCommand.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -35,13 +35,13 @@
 block discarded – undo
35 35
             if (!empty($install)) {
36 36
                 $notInstalled[] = [$driverClass, $description, $install];
37 37
             } else {
38
-                $output->writeln($formatter->formatSection($driverClass, $description) . ': ' . implode(', ', $driverClass::getSupportedFormats()));
38
+                $output->writeln($formatter->formatSection($driverClass, $description).': '.implode(', ', $driverClass::getSupportedFormats()));
39 39
             }
40 40
         }
41 41
 
42 42
         if (!empty($notInstalled)) {
43 43
             foreach ($notInstalled as $data) {
44
-                $output->writeln($formatter->formatSection($data[0], $data[1] . ': ' . implode(', ', $data[0]::getSupportedFormats()), 'error'));
44
+                $output->writeln($formatter->formatSection($data[0], $data[1].': '.implode(', ', $data[0]::getSupportedFormats()), 'error'));
45 45
                 $data[2] = preg_replace('~`(.+?)`~', '<options=bold,underscore>$1</>', $data[2]);
46 46
                 $output->writeln($formatter->formatSection($data[0], $data[2], 'comment'));
47 47
             }
Please login to merge, or discard this patch.
src/Commands/FormatsCommand.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -36,9 +36,9 @@
 block discarded – undo
36 36
                 $driver = '\\'.$driver;
37 37
             }
38 38
             if (!class_exists($driver) || !is_a($driver, BasicDriver::class, true)) {
39
-                throw new \InvalidArgumentException('Class "' . $driver . '" not found or not in BasicDriver children');
39
+                throw new \InvalidArgumentException('Class "'.$driver.'" not found or not in BasicDriver children');
40 40
             }
41
-            $output->writeln('Supported format by <info>' . $driver . '</info>');
41
+            $output->writeln('Supported format by <info>'.$driver.'</info>');
42 42
 
43 43
             $table->setHeaders(['format', 'stream', 'create', 'append', 'update', 'encrypt']);
44 44
             foreach ($driver::getSupportedFormats() as $i => $format) {
Please login to merge, or discard this patch.
src/Drivers/SevenZip.php 2 patches
Braces   +30 added lines, -20 removed lines patch added patch discarded remove patch
@@ -58,12 +58,14 @@  discard block
 block discarded – undo
58 58
     public static function checkFormatSupport($format)
59 59
     {
60 60
         $available = class_exists('\Archive7z\Archive7z') && Archive7z::getBinaryVersion() !== false;
61
-        if (!$available)
62
-            return false;
61
+        if (!$available) {
62
+                    return false;
63
+        }
63 64
 
64 65
         // in 4.0.0 version it was supporting only 7z
65
-        if (!Archive7z::supportsAllFormats())
66
-            return $format === Formats::SEVEN_ZIP;
66
+        if (!Archive7z::supportsAllFormats()) {
67
+                    return $format === Formats::SEVEN_ZIP;
68
+        }
67 69
 
68 70
         switch ($format) {
69 71
             case Formats::SEVEN_ZIP:
@@ -104,12 +106,14 @@  discard block
 block discarded – undo
104 106
      */
105 107
     public static function getInstallationInstruction()
106 108
     {
107
-        if (!class_exists('\Archive7z\Archive7z'))
108
-            return 'install library [gemorroj/archive7z]: `composer require gemorroj/archive7z`' . "\n"
109
+        if (!class_exists('\Archive7z\Archive7z')) {
110
+                    return 'install library [gemorroj/archive7z]: `composer require gemorroj/archive7z`' . "\n"
109 111
                 . ' and console program p7zip [7za]: `apt install p7zip-full` - depends on OS';
112
+        }
110 113
 
111
-        if (Archive7z::getBinaryVersion() === false)
112
-            return 'install console program p7zip [7za]: `apt install p7zip-full` - depends on OS';
114
+        if (Archive7z::getBinaryVersion() === false) {
115
+                    return 'install console program p7zip [7za]: `apt install p7zip-full` - depends on OS';
116
+        }
113 117
 
114 118
         return null;
115 119
     }
@@ -122,8 +126,9 @@  discard block
 block discarded – undo
122 126
         try {
123 127
             $this->format = $format;
124 128
             $this->sevenZip = new Archive7z($archiveFileName, null, null);
125
-            if ($password !== null)
126
-                $this->sevenZip->setPassword($password);
129
+            if ($password !== null) {
130
+                            $this->sevenZip->setPassword($password);
131
+            }
127 132
         } catch (\Archive7z\Exception $e) {
128 133
             throw new Exception('Could not open 7Zip archive: '.$e->getMessage(), $e->getCode(), $e);
129 134
         }
@@ -141,8 +146,9 @@  discard block
 block discarded – undo
141 146
                 continue;
142 147
             }
143 148
 
144
-            if (!isset($can_get_unix_path))
145
-                $can_get_unix_path = method_exists($entry, 'getUnixPath');
149
+            if (!isset($can_get_unix_path)) {
150
+                            $can_get_unix_path = method_exists($entry, 'getUnixPath');
151
+            }
146 152
 
147 153
             $information->files[] = $can_get_unix_path
148 154
                 ? $entry->getUnixPath()
@@ -160,8 +166,9 @@  discard block
 block discarded – undo
160 166
     {
161 167
         $files = [];
162 168
         foreach ($this->sevenZip->getEntries() as $entry) {
163
-            if ($entry->isDirectory())
164
-                continue;
169
+            if ($entry->isDirectory()) {
170
+                            continue;
171
+            }
165 172
             $files[] = $entry->getPath();
166 173
         }
167 174
         return $files;
@@ -302,8 +309,9 @@  discard block
 block discarded – undo
302 309
     public function addFileFromString($inArchiveName, $content)
303 310
     {
304 311
         $tmp_file = tempnam(sys_get_temp_dir(), 'ua');
305
-        if (!$tmp_file)
306
-            throw new ArchiveModificationException('Could not create temporarily file');
312
+        if (!$tmp_file) {
313
+                    throw new ArchiveModificationException('Could not create temporarily file');
314
+        }
307 315
 
308 316
         file_put_contents($tmp_file, $content);
309 317
         $this->sevenZip->addEntry($tmp_file, true);
@@ -353,8 +361,9 @@  discard block
 block discarded – undo
353 361
             $total_files = count($files);
354 362
 
355 363
             $seven_zip = new Archive7z($archiveFileName);
356
-            if ($password !== null)
357
-                $seven_zip->setPassword($password);
364
+            if ($password !== null) {
365
+                            $seven_zip->setPassword($password);
366
+            }
358 367
             $seven_zip->setCompressionLevel($compressionLevelMap[$compressionLevel]);
359 368
             foreach ($files as $localName => $filename) {
360 369
                 if ($filename !== null) {
@@ -386,8 +395,9 @@  discard block
 block discarded – undo
386 395
             Formats::TAR,
387 396
             Formats::LZMA,
388 397
             Formats::ZIP]
389
-        ))
390
-            return self::canRenameFiles();
398
+        )) {
399
+                    return self::canRenameFiles();
400
+        }
391 401
 
392 402
         return false;
393 403
     }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
     public static function getInstallationInstruction()
109 109
     {
110 110
         if (!class_exists('\Archive7z\Archive7z'))
111
-            return 'install library [gemorroj/archive7z]: `composer require gemorroj/archive7z`' . "\n"
111
+            return 'install library [gemorroj/archive7z]: `composer require gemorroj/archive7z`'."\n"
112 112
                 . ' and console program p7zip [7za]: `apt install p7zip-full` - depends on OS';
113 113
 
114 114
         if (Archive7z::getBinaryVersion() === false)
@@ -150,8 +150,8 @@  discard block
 block discarded – undo
150 150
             $information->files[] = $can_get_unix_path
151 151
                 ? $entry->getUnixPath()
152 152
                 : str_replace('\\', '/', $entry->getPath());
153
-            $information->compressedFilesSize += (int)$entry->getPackedSize();
154
-            $information->uncompressedFilesSize += (int)$entry->getSize();
153
+            $information->compressedFilesSize += (int) $entry->getPackedSize();
154
+            $information->uncompressedFilesSize += (int) $entry->getSize();
155 155
         }
156 156
         return $information;
157 157
     }
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
     {
210 210
         $entry = $this->sevenZip->getEntry($fileName);
211 211
         if ($entry === null) {
212
-            throw new NonExistentArchiveFileException('File ' . $fileName . ' does not exist');
212
+            throw new NonExistentArchiveFileException('File '.$fileName.' does not exist');
213 213
         }
214 214
         return $entry->getContent();
215 215
     }
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
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
  */
13 13
 class Lzma extends OneFileDriver
14 14
 {
15
-    const FORMAT_SUFFIX =  'xz';
15
+    const FORMAT_SUFFIX = 'xz';
16 16
 
17 17
     /**
18 18
      * @return array
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
     public static function getInstallationInstruction()
51 51
     {
52 52
         return !extension_loaded('xz')
53
-            ? 'install [xz] extension' . "\n" . 'For 5.x: https://github.com/payden/php-xz' . "\n" . 'For 7.x: https://github.com/codemasher/php-ext-xz'
53
+            ? 'install [xz] extension'."\n".'For 5.x: https://github.com/payden/php-xz'."\n".'For 7.x: https://github.com/codemasher/php-ext-xz'
54 54
             : null;
55 55
     }
56 56
 
Please login to merge, or discard this patch.
src/PclZipInterface.php 2 patches
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
 
273 273
         $report = array();
274 274
         foreach ($this->listContent() as $file_header) {
275
-            $file_header = (object)$file_header;
275
+            $file_header = (object) $file_header;
276 276
             // add file information to report
277 277
             $report[] = $file_header;
278 278
             // refuse by select rule
@@ -406,7 +406,7 @@  discard block
 block discarded – undo
406 406
         }
407 407
 
408 408
         foreach ($report as $i => $reportItem) {
409
-            $report[$i] = (array)$reportItem;
409
+            $report[$i] = (array) $reportItem;
410 410
         }
411 411
 
412 412
         return $report;
@@ -457,7 +457,7 @@  discard block
 block discarded – undo
457 457
 
458 458
         $report = [];
459 459
         foreach ($this->listContent() as $file_header) {
460
-            $file_header = (object)$file_header;
460
+            $file_header = (object) $file_header;
461 461
             // select by select rule
462 462
             if (call_user_func($selectFilter, $file_header->stored_filename,
463 463
                     $file_header->filename, $file_header->index)
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
         }
478 478
 
479 479
         foreach ($report as $i => $reportItem) {
480
-            $report[$i] = (array)$reportItem;
480
+            $report[$i] = (array) $reportItem;
481 481
         }
482 482
 
483 483
         return $report;
@@ -539,7 +539,7 @@  discard block
 block discarded – undo
539 539
             }
540 540
         }
541 541
 
542
-        call_user_func(function ($directory) {
542
+        call_user_func(function($directory) {
543 543
             foreach (glob($directory.'/*') as $f) {
544 544
                 if (is_dir($f)) call_user_func(__FUNCTION__, $f);
545 545
                 else unlink($f);
@@ -568,16 +568,16 @@  discard block
 block discarded – undo
568 568
         $filters = array();
569 569
         if (isset($options[PCLZIP_OPT_REMOVE_PATH])
570 570
             && !isset($options[PCLZIP_OPT_REMOVE_ALL_PATH]))
571
-            $filters[] = function (&$key, &$value) use ($options) {
571
+            $filters[] = function(&$key, &$value) use ($options) {
572 572
                 $key = str_replace($key, null, $key);
573 573
             };
574 574
         if (isset($options[PCLZIP_OPT_REMOVE_ALL_PATH]))
575
-            $filters[] = function (&$key, &$value) {
575
+            $filters[] = function(&$key, &$value) {
576 576
                 $key = basename($key);
577 577
             };
578 578
         if (isset($options[PCLZIP_OPT_ADD_PATH]))
579
-            $filters[] = function (&$key, &$value) use ($options) {
580
-                $key = rtrim($options[PCLZIP_OPT_ADD_PATH], '/') . '/' .
579
+            $filters[] = function(&$key, &$value) use ($options) {
580
+                $key = rtrim($options[PCLZIP_OPT_ADD_PATH], '/').'/'.
581 581
                     ltrim($key, '/');
582 582
             };
583 583
         return $filters;
@@ -591,7 +591,7 @@  discard block
 block discarded – undo
591 591
      */
592 592
     private function extractCallbacks(array $options, $preCallbackConst, $postCallbackConst)
593 593
     {
594
-        $preCallback = $postCallback = function () { return true; };
594
+        $preCallback = $postCallback = function() { return true; };
595 595
 
596 596
         if (isset($options[$preCallbackConst]) && is_callable($options[$preCallbackConst]))
597 597
             $preCallback = $options[$preCallbackConst];
@@ -608,8 +608,8 @@  discard block
 block discarded – undo
608 608
      */
609 609
     private function makeKeyValueArrayFromList(array $options)
610 610
     {
611
-        $keys = array_filter($options, function ($v) {return ($v%2) == 0;}, ARRAY_FILTER_USE_KEY);
612
-        $values = array_filter($options, function ($v) {return ($v%2) == 1;}, ARRAY_FILTER_USE_KEY);
611
+        $keys = array_filter($options, function($v) {return ($v % 2) == 0; }, ARRAY_FILTER_USE_KEY);
612
+        $values = array_filter($options, function($v) {return ($v % 2) == 1; }, ARRAY_FILTER_USE_KEY);
613 613
         if (count($values) < count($keys)) $values[] = true;
614 614
         return array_combine($keys, $values);
615 615
     }
@@ -658,7 +658,7 @@  discard block
 block discarded – undo
658 658
                 range($parts[0], $parts[1]), $allowedIndexes);
659 659
         }
660 660
 
661
-        return function ($key, $value, $index) use ($allowedIndexes) {
661
+        return function($key, $value, $index) use ($allowedIndexes) {
662 662
             return in_array($index, $allowedIndexes)
663 663
                 ? self::SELECT_FILTER_PASS
664 664
                 : self::SELECT_FILTER_REFUSE;
@@ -675,7 +675,7 @@  discard block
 block discarded – undo
675 675
             ? $names
676 676
             : explode(',', $names);
677 677
 
678
-        return function ($key, $value) use ($allowedNames) {
678
+        return function($key, $value) use ($allowedNames) {
679 679
             foreach ($allowedNames as $name) {
680 680
                 // select directory with nested files
681 681
                 if (in_array(substr($name, -1), ['/', '\\'])) {
@@ -703,7 +703,7 @@  discard block
 block discarded – undo
703 703
      */
704 704
     protected function createByEregSelector($regex)
705 705
     {
706
-        return function ($key, $value) use ($regex) {
706
+        return function($key, $value) use ($regex) {
707 707
             return (ereg($regex, $key) !== false)
708 708
                 ? self::SELECT_FILTER_PASS
709 709
                 : self::SELECT_FILTER_REFUSE;
@@ -716,7 +716,7 @@  discard block
 block discarded – undo
716 716
      */
717 717
     protected function createByPregSelector($regex)
718 718
     {
719
-        return function ($key, $value) use ($regex) {
719
+        return function($key, $value) use ($regex) {
720 720
             return preg_match($regex, $key)
721 721
                 ? self::SELECT_FILTER_PASS
722 722
                 : self::SELECT_FILTER_REFUSE;
@@ -743,7 +743,7 @@  discard block
 block discarded – undo
743 743
             $selectFilter = $this->createByIndexSelector($options[PCLZIP_OPT_BY_INDEX]);
744 744
         // no rule
745 745
         else
746
-            $selectFilter = function () {
746
+            $selectFilter = function() {
747 747
                 return self::SELECT_FILTER_PASS;
748 748
             };
749 749
         return $selectFilter;
@@ -783,9 +783,9 @@  discard block
 block discarded – undo
783 783
         if (isset($options[PCLZIP_OPT_COMMENT]))
784 784
             $comment = $options[PCLZIP_OPT_COMMENT];
785 785
         else if (isset($options[PCLZIP_OPT_ADD_COMMENT])) {;
786
-            $comment = $currentComment . $options[PCLZIP_OPT_ADD_COMMENT];
786
+            $comment = $currentComment.$options[PCLZIP_OPT_ADD_COMMENT];
787 787
         } else if (isset($options[PCLZIP_OPT_PREPEND_COMMENT])) {
788
-            $comment = $options[PCLZIP_OPT_PREPEND_COMMENT] . $currentComment;
788
+            $comment = $options[PCLZIP_OPT_PREPEND_COMMENT].$currentComment;
789 789
         }
790 790
         return $comment;
791 791
     }
Please login to merge, or discard this patch.
Braces   +99 added lines, -57 removed lines patch added patch discarded remove patch
@@ -137,8 +137,11 @@  discard block
 block discarded – undo
137 137
      */
138 138
     public function create($content)
139 139
     {
140
-        if (is_array($content)) $paths_list = $content;
141
-        else $paths_list = explode(',', $content);
140
+        if (is_array($content)) {
141
+         $paths_list = $content;
142
+        } else {
143
+         $paths_list = explode(',', $content);
144
+        }
142 145
 
143 146
         $options = $this->makeOptionsFromArguments(func_get_args());
144 147
 
@@ -146,8 +149,9 @@  discard block
 block discarded – undo
146 149
         $filters = $this->createFilters($options);
147 150
         list($preAddCallback, $postAddCallback) = $this->extractCallbacks($options, PCLZIP_CB_PRE_ADD, PCLZIP_CB_POST_ADD);
148 151
 
149
-        if (!empty($comment = $this->buildComment($options, null)))
150
-            $this->archive->setComment($comment);
152
+        if (!empty($comment = $this->buildComment($options, null))) {
153
+                    $this->archive->setComment($comment);
154
+        }
151 155
 
152 156
         // scan filesystem for files list
153 157
         return $this->addSnippets($paths_list, $filters, $preAddCallback, $postAddCallback);
@@ -167,16 +171,18 @@  discard block
 block discarded – undo
167 171
             $localname = $fileToAdd;
168 172
             $filename = $fileToAdd;
169 173
 
170
-            foreach ($filters as $filter)
171
-                call_user_func($filter, $localname, $filename);
174
+            foreach ($filters as $filter) {
175
+                            call_user_func($filter, $localname, $filename);
176
+            }
172 177
 
173 178
             $file_header = $this->createFileHeader($localname, $filename);
174 179
             if (call_user_func($preAddCallback, $file_header) == 1) {
175 180
                 //
176 181
                 // Check for max length > 255
177 182
                 //
178
-                if (strlen(basename($file_header->stored_filename)) > 255)
179
-                    $file_header->status = 'filename_too_long';
183
+                if (strlen(basename($file_header->stored_filename)) > 255) {
184
+                                    $file_header->status = 'filename_too_long';
185
+                }
180 186
                 if (is_file($filename)) {
181 187
                     $this->archive->addFiles([
182 188
                         $file_header->stored_filename => $file_header->filename,
@@ -248,27 +254,35 @@  discard block
 block discarded – undo
248 254
         }
249 255
 
250 256
         // filters initiation
251
-        if (isset($options[PCLZIP_OPT_PATH]))
252
-            $extractPath = rtrim($options[PCLZIP_OPT_PATH], '/');
253
-        else $extractPath = rtrim(getcwd(), '/');
257
+        if (isset($options[PCLZIP_OPT_PATH])) {
258
+                    $extractPath = rtrim($options[PCLZIP_OPT_PATH], '/');
259
+        } else {
260
+         $extractPath = rtrim(getcwd(), '/');
261
+        }
254 262
 
255 263
         $filters = $this->createFilters($options);
256 264
         list($preExtractCallback, $postExtractCallback) = $this->extractCallbacks($options, PCLZIP_CB_PRE_EXTRACT, PCLZIP_CB_POST_EXTRACT);
257 265
         $selectFilter = $this->createSelector($options);
258 266
 
259
-        if (isset($options[PCLZIP_OPT_EXTRACT_AS_STRING]))
260
-            $anotherOutputFormat = PCLZIP_OPT_EXTRACT_AS_STRING;
261
-        else if (isset($options[PCLZIP_OPT_EXTRACT_IN_OUTPUT]))
262
-            $anotherOutputFormat = PCLZIP_OPT_EXTRACT_IN_OUTPUT;
263
-        else $anotherOutputFormat = false;
267
+        if (isset($options[PCLZIP_OPT_EXTRACT_AS_STRING])) {
268
+                    $anotherOutputFormat = PCLZIP_OPT_EXTRACT_AS_STRING;
269
+        } else if (isset($options[PCLZIP_OPT_EXTRACT_IN_OUTPUT])) {
270
+                    $anotherOutputFormat = PCLZIP_OPT_EXTRACT_IN_OUTPUT;
271
+        } else {
272
+         $anotherOutputFormat = false;
273
+        }
264 274
 
265
-        if (isset($options[PCLZIP_OPT_REPLACE_NEWER]))
266
-            $doNotReplaceNewer = false;
267
-        else $doNotReplaceNewer = true;
275
+        if (isset($options[PCLZIP_OPT_REPLACE_NEWER])) {
276
+                    $doNotReplaceNewer = false;
277
+        } else {
278
+         $doNotReplaceNewer = true;
279
+        }
268 280
 
269
-        if (isset($options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION]))
270
-            $restrictExtractDir = $options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION];
271
-        else $restrictExtractDir = false;
281
+        if (isset($options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION])) {
282
+                    $restrictExtractDir = $options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION];
283
+        } else {
284
+         $restrictExtractDir = false;
285
+        }
272 286
 
273 287
         $report = array();
274 288
         foreach ($this->listContent() as $file_header) {
@@ -339,8 +353,10 @@  discard block
 block discarded – undo
339 353
             // extract content
340 354
             else if ($anotherOutputFormat === false) {
341 355
                 // apply path filters
342
-                foreach ($filters as $filter) call_user_func($filter,
356
+                foreach ($filters as $filter) {
357
+                 call_user_func($filter,
343 358
                     $file_header->stored_filename, $file_header->filename);
359
+                }
344 360
                 // dir extraction process
345 361
                 if ($file_header->folder) {
346 362
                     // if dir doesn't exist
@@ -431,15 +447,19 @@  discard block
 block discarded – undo
431 447
      */
432 448
     public function add($content)
433 449
     {
434
-        if (is_array($content)) $paths_list = $content;
435
-        else $paths_list = explode(',', $content);
450
+        if (is_array($content)) {
451
+         $paths_list = $content;
452
+        } else {
453
+         $paths_list = explode(',', $content);
454
+        }
436 455
 
437 456
         $options = $this->makeOptionsFromArguments(func_get_args());
438 457
         $filters = $this->createFilters($options);
439 458
         list($preAddCallback, $postAddCallback) = $this->extractCallbacks($options, PCLZIP_CB_PRE_ADD, PCLZIP_CB_POST_ADD);
440 459
 
441
-        if (!empty($comment = $this->buildComment($options, $this->archive->getComment())))
442
-            $this->archive->setComment($comment);
460
+        if (!empty($comment = $this->buildComment($options, $this->archive->getComment()))) {
461
+                    $this->archive->setComment($comment);
462
+        }
443 463
 
444 464
         // scan filesystem for files list
445 465
         return $this->addSnippets($paths_list, $filters, $preAddCallback, $postAddCallback);
@@ -511,8 +531,12 @@  discard block
 block discarded – undo
511 531
         }
512 532
 
513 533
         $tempDir = tempnam(PCLZIP_TEMPORARY_DIR, 'merging');
514
-        if (file_exists($tempDir)) unlink($tempDir);
515
-        if (!mkdir($tempDir)) return 0;
534
+        if (file_exists($tempDir)) {
535
+         unlink($tempDir);
536
+        }
537
+        if (!mkdir($tempDir)) {
538
+         return 0;
539
+        }
516 540
 
517 541
         // go through archive content list and copy all files
518 542
         foreach ($a->getFileNames() as $filename) {
@@ -541,8 +565,11 @@  discard block
 block discarded – undo
541 565
 
542 566
         call_user_func(function ($directory) {
543 567
             foreach (glob($directory.'/*') as $f) {
544
-                if (is_dir($f)) call_user_func(__FUNCTION__, $f);
545
-                else unlink($f);
568
+                if (is_dir($f)) {
569
+                 call_user_func(__FUNCTION__, $f);
570
+                } else {
571
+                 unlink($f);
572
+                }
546 573
             }
547 574
         }, $tempDir);
548 575
 
@@ -567,18 +594,21 @@  discard block
 block discarded – undo
567 594
     {
568 595
         $filters = array();
569 596
         if (isset($options[PCLZIP_OPT_REMOVE_PATH])
570
-            && !isset($options[PCLZIP_OPT_REMOVE_ALL_PATH]))
571
-            $filters[] = function (&$key, &$value) use ($options) {
597
+            && !isset($options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
598
+                    $filters[] = function (&$key, &$value) use ($options) {
572 599
                 $key = str_replace($key, null, $key);
600
+        }
573 601
             };
574
-        if (isset($options[PCLZIP_OPT_REMOVE_ALL_PATH]))
575
-            $filters[] = function (&$key, &$value) {
602
+        if (isset($options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
603
+                    $filters[] = function (&$key, &$value) {
576 604
                 $key = basename($key);
605
+        }
577 606
             };
578
-        if (isset($options[PCLZIP_OPT_ADD_PATH]))
579
-            $filters[] = function (&$key, &$value) use ($options) {
607
+        if (isset($options[PCLZIP_OPT_ADD_PATH])) {
608
+                    $filters[] = function (&$key, &$value) use ($options) {
580 609
                 $key = rtrim($options[PCLZIP_OPT_ADD_PATH], '/') . '/' .
581 610
                     ltrim($key, '/');
611
+        }
582 612
             };
583 613
         return $filters;
584 614
     }
@@ -593,11 +623,13 @@  discard block
 block discarded – undo
593 623
     {
594 624
         $preCallback = $postCallback = function () { return true; };
595 625
 
596
-        if (isset($options[$preCallbackConst]) && is_callable($options[$preCallbackConst]))
597
-            $preCallback = $options[$preCallbackConst];
626
+        if (isset($options[$preCallbackConst]) && is_callable($options[$preCallbackConst])) {
627
+                    $preCallback = $options[$preCallbackConst];
628
+        }
598 629
 
599
-        if (isset($options[$postCallbackConst]) && is_callable($options[$postCallbackConst]))
600
-            $postCallback = $options[$postCallbackConst];
630
+        if (isset($options[$postCallbackConst]) && is_callable($options[$postCallbackConst])) {
631
+                    $postCallback = $options[$postCallbackConst];
632
+        }
601 633
 
602 634
         return [$preCallback, $postCallback];
603 635
     }
@@ -610,7 +642,9 @@  discard block
 block discarded – undo
610 642
     {
611 643
         $keys = array_filter($options, function ($v) {return ($v%2) == 0;}, ARRAY_FILTER_USE_KEY);
612 644
         $values = array_filter($options, function ($v) {return ($v%2) == 1;}, ARRAY_FILTER_USE_KEY);
613
-        if (count($values) < count($keys)) $values[] = true;
645
+        if (count($values) < count($keys)) {
646
+         $values[] = true;
647
+        }
614 648
         return array_combine($keys, $values);
615 649
     }
616 650
 
@@ -653,9 +687,12 @@  discard block
 block discarded – undo
653 687
         $allowedIndexes = array();
654 688
         foreach ($indexes as $rule) {
655 689
             $parts = explode('-', $rule);
656
-            if (count($parts) == 1) $allowedIndexes[] = $rule;
657
-            else $allowedIndexes = array_merge(
690
+            if (count($parts) == 1) {
691
+             $allowedIndexes[] = $rule;
692
+            } else {
693
+             $allowedIndexes = array_merge(
658 694
                 range($parts[0], $parts[1]), $allowedIndexes);
695
+            }
659 696
         }
660 697
 
661 698
         return function ($key, $value, $index) use ($allowedIndexes) {
@@ -730,21 +767,26 @@  discard block
 block discarded – undo
730 767
     protected function createSelector(array $options)
731 768
     {
732 769
         // exact matching
733
-        if (isset($options[PCLZIP_OPT_BY_NAME]))
734
-            $selectFilter = $this->createByNameSelector($options[PCLZIP_OPT_BY_NAME]);
770
+        if (isset($options[PCLZIP_OPT_BY_NAME])) {
771
+                    $selectFilter = $this->createByNameSelector($options[PCLZIP_OPT_BY_NAME]);
772
+        }
735 773
         // <ereg> rule
736
-        else if (isset($options[PCLZIP_OPT_BY_EREG]) && function_exists('ereg'))
737
-            $selectFilter = $this->createByEregSelector($options[PCLZIP_OPT_BY_EREG]);
774
+        else if (isset($options[PCLZIP_OPT_BY_EREG]) && function_exists('ereg')) {
775
+                    $selectFilter = $this->createByEregSelector($options[PCLZIP_OPT_BY_EREG]);
776
+        }
738 777
         // <preg_match> rule
739
-        else if (isset($options[PCLZIP_OPT_BY_PREG]))
740
-            $selectFilter = $this->createByPregSelector($options[PCLZIP_OPT_BY_PREG]);
778
+        else if (isset($options[PCLZIP_OPT_BY_PREG])) {
779
+                    $selectFilter = $this->createByPregSelector($options[PCLZIP_OPT_BY_PREG]);
780
+        }
741 781
         // index rule
742
-        else if (isset($options[PCLZIP_OPT_BY_INDEX]))
743
-            $selectFilter = $this->createByIndexSelector($options[PCLZIP_OPT_BY_INDEX]);
782
+        else if (isset($options[PCLZIP_OPT_BY_INDEX])) {
783
+                    $selectFilter = $this->createByIndexSelector($options[PCLZIP_OPT_BY_INDEX]);
784
+        }
744 785
         // no rule
745
-        else
746
-            $selectFilter = function () {
786
+        else {
787
+                    $selectFilter = function () {
747 788
                 return self::SELECT_FILTER_PASS;
789
+        }
748 790
             };
749 791
         return $selectFilter;
750 792
     }
@@ -780,9 +822,9 @@  discard block
 block discarded – undo
780 822
     protected function buildComment(array $options, $currentComment)
781 823
     {
782 824
         $comment = null;
783
-        if (isset($options[PCLZIP_OPT_COMMENT]))
784
-            $comment = $options[PCLZIP_OPT_COMMENT];
785
-        else if (isset($options[PCLZIP_OPT_ADD_COMMENT])) {;
825
+        if (isset($options[PCLZIP_OPT_COMMENT])) {
826
+                    $comment = $options[PCLZIP_OPT_COMMENT];
827
+        } else if (isset($options[PCLZIP_OPT_ADD_COMMENT])) {;
786 828
             $comment = $currentComment . $options[PCLZIP_OPT_ADD_COMMENT];
787 829
         } else if (isset($options[PCLZIP_OPT_PREPEND_COMMENT])) {
788 830
             $comment = $options[PCLZIP_OPT_PREPEND_COMMENT] . $currentComment;
Please login to merge, or discard this patch.