@@ -27,14 +27,14 @@ |
||
| 27 | 27 | list($archive, $file) = $this->getArchiveAndFile($input, $output); |
| 28 | 28 | $destination = $input->getArgument('destination'); |
| 29 | 29 | if (is_dir($destination)) { |
| 30 | - $destination = $destination . '/' . basename($file); |
|
| 30 | + $destination = $destination.'/'.basename($file); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | $overwrite = $input->getOption('overwrite'); |
| 34 | 34 | |
| 35 | 35 | if (file_exists($destination) && !$overwrite) { |
| 36 | 36 | if ($input->getOption('no-interaction')) { |
| 37 | - throw new \LogicException('File destination ' . $destination . ' exists'); |
|
| 37 | + throw new \LogicException('File destination '.$destination.' exists'); |
|
| 38 | 38 | } |
| 39 | 39 | } |
| 40 | 40 | |
@@ -46,8 +46,9 @@ |
||
| 46 | 46 | $this->compressedSize = $compressedSize; |
| 47 | 47 | $this->uncompressedSize = $uncompressedSize; |
| 48 | 48 | $this->modificationTime = $modificationTime; |
| 49 | - if ($isCompressed === null) |
|
| 50 | - $isCompressed = $uncompressedSize !== $compressedSize; |
|
| 49 | + if ($isCompressed === null) { |
|
| 50 | + $isCompressed = $uncompressedSize !== $compressedSize; |
|
| 51 | + } |
|
| 51 | 52 | $this->isCompressed = $isCompressed; |
| 52 | 53 | $this->comment = $comment; |
| 53 | 54 | $this->crc32 = $crc32; |
@@ -108,7 +108,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 | } |
@@ -36,12 +36,14 @@ discard block |
||
| 36 | 36 | */ |
| 37 | 37 | public static function getInstallationInstruction() |
| 38 | 38 | { |
| 39 | - if (!class_exists('\Archive7z\Archive7z')) |
|
| 40 | - return 'install library [gemorroj/archive7z]: `composer require gemorroj/archive7z`' . "\n" |
|
| 39 | + if (!class_exists('\Archive7z\Archive7z')) { |
|
| 40 | + return 'install library [gemorroj/archive7z]: `composer require gemorroj/archive7z`' . "\n" |
|
| 41 | 41 | . ' and console program p7zip [7za]: `apt install p7zip-full` - depends on OS'; |
| 42 | + } |
|
| 42 | 43 | |
| 43 | - if (Archive7z::getBinaryVersion() === false) |
|
| 44 | - return 'install console program p7zip [7za]: `apt install p7zip-full` - depends on OS'; |
|
| 44 | + if (Archive7z::getBinaryVersion() === false) { |
|
| 45 | + return 'install console program p7zip [7za]: `apt install p7zip-full` - depends on OS'; |
|
| 46 | + } |
|
| 45 | 47 | |
| 46 | 48 | return null; |
| 47 | 49 | } |
@@ -145,8 +147,9 @@ discard block |
||
| 145 | 147 | try { |
| 146 | 148 | $this->format = $format; |
| 147 | 149 | $this->sevenZip = new Archive7z($archiveFileName, null, null); |
| 148 | - if ($password !== null) |
|
| 149 | - $this->sevenZip->setPassword($password); |
|
| 150 | + if ($password !== null) { |
|
| 151 | + $this->sevenZip->setPassword($password); |
|
| 152 | + } |
|
| 150 | 153 | } catch (\Archive7z\Exception $e) { |
| 151 | 154 | throw new Exception('Could not open 7Zip archive: '.$e->getMessage(), $e->getCode(), $e); |
| 152 | 155 | } |
@@ -164,8 +167,9 @@ discard block |
||
| 164 | 167 | continue; |
| 165 | 168 | } |
| 166 | 169 | |
| 167 | - if (!isset($can_get_unix_path)) |
|
| 168 | - $can_get_unix_path = method_exists($entry, 'getUnixPath'); |
|
| 170 | + if (!isset($can_get_unix_path)) { |
|
| 171 | + $can_get_unix_path = method_exists($entry, 'getUnixPath'); |
|
| 172 | + } |
|
| 169 | 173 | |
| 170 | 174 | $information->files[] = $can_get_unix_path |
| 171 | 175 | ? $entry->getUnixPath() |
@@ -183,8 +187,9 @@ discard block |
||
| 183 | 187 | { |
| 184 | 188 | $files = []; |
| 185 | 189 | foreach ($this->sevenZip->getEntries() as $entry) { |
| 186 | - if ($entry->isDirectory()) |
|
| 187 | - continue; |
|
| 190 | + if ($entry->isDirectory()) { |
|
| 191 | + continue; |
|
| 192 | + } |
|
| 188 | 193 | $files[] = $entry->getPath(); |
| 189 | 194 | } |
| 190 | 195 | return $files; |
@@ -336,8 +341,9 @@ discard block |
||
| 336 | 341 | public function addFileFromString($inArchiveName, $content) |
| 337 | 342 | { |
| 338 | 343 | $tmp_file = tempnam(sys_get_temp_dir(), 'ua'); |
| 339 | - if (!$tmp_file) |
|
| 340 | - throw new ArchiveModificationException('Could not create temporarily file'); |
|
| 344 | + if (!$tmp_file) { |
|
| 345 | + throw new ArchiveModificationException('Could not create temporarily file'); |
|
| 346 | + } |
|
| 341 | 347 | |
| 342 | 348 | file_put_contents($tmp_file, $content); |
| 343 | 349 | $this->sevenZip->addEntry($tmp_file, true); |
@@ -387,8 +393,9 @@ discard block |
||
| 387 | 393 | $total_files = count($files); |
| 388 | 394 | |
| 389 | 395 | $seven_zip = new Archive7z($archiveFileName); |
| 390 | - if ($password !== null) |
|
| 391 | - $seven_zip->setPassword($password); |
|
| 396 | + if ($password !== null) { |
|
| 397 | + $seven_zip->setPassword($password); |
|
| 398 | + } |
|
| 392 | 399 | $seven_zip->setCompressionLevel($compressionLevelMap[$compressionLevel]); |
| 393 | 400 | foreach ($files as $archiveName => $localName) { |
| 394 | 401 | if ($localName !== null) { |
@@ -61,10 +61,11 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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; |
@@ -63,9 +63,9 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | /** |
@@ -86,8 +86,9 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | } |
@@ -28,7 +28,7 @@ |
||
| 28 | 28 | |
| 29 | 29 | public static function getDescription() |
| 30 | 30 | { |
| 31 | - return 'adapter for ext-zip'.(extension_loaded('zip') && defined('\ZipArchive::LIBZIP_VERSION') ? ' ('. ZipArchive::LIBZIP_VERSION.')' : null); |
|
| 31 | + return 'adapter for ext-zip'.(extension_loaded('zip') && defined('\ZipArchive::LIBZIP_VERSION') ? ' ('.ZipArchive::LIBZIP_VERSION.')' : null); |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | /** |
@@ -53,7 +53,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | } |
@@ -164,10 +164,11 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | } |
@@ -82,8 +82,9 @@ |
||
| 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 | |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | if ($typeDriverConfig[1]) { |
| 64 | 64 | // $type_messages[] = '<info>' . $typeDriverClass . '</info>: ' . $typeDriverConfig[0]; |
| 65 | 65 | $table->setRow($i++, [ |
| 66 | - '<info>' . $this->getDriverBaseName($typeDriverClass) . '</info>', |
|
| 66 | + '<info>'.$this->getDriverBaseName($typeDriverClass).'</info>', |
|
| 67 | 67 | BasicDriver::$typeLabels[$typeDriverClass::TYPE], |
| 68 | 68 | $typeDriverConfig[0], |
| 69 | 69 | ]); |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | // $type_messages[] = '<error>' . $typeDriverClass . '</error>: ' . $typeDriverConfig[0]; |
| 72 | 72 | // $type_messages[] = $this->formatInstallation($typeDriverConfig[2], 4); |
| 73 | 73 | $table->setRow($i++, [ |
| 74 | - '<comment>' . $this->getDriverBaseName($typeDriverClass) . '</comment>', |
|
| 74 | + '<comment>'.$this->getDriverBaseName($typeDriverClass).'</comment>', |
|
| 75 | 75 | BasicDriver::$typeLabels[$typeDriverClass::TYPE], |
| 76 | 76 | $this->formatInstallation($typeDriverConfig[2], 0), |
| 77 | 77 | ]); |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | protected function formatInstallation($doc, $leftPadding = 4) |
| 95 | 95 | { |
| 96 | 96 | return implode("\n", array_map( |
| 97 | - function($line) use ($leftPadding) { return str_repeat(' ', $leftPadding) . $line; }, |
|
| 97 | + function($line) use ($leftPadding) { return str_repeat(' ', $leftPadding).$line; }, |
|
| 98 | 98 | explode( |
| 99 | 99 | "\n", |
| 100 | 100 | preg_replace('~`(.+?)`~', '<options=bold,underscore>$1</>', $doc) |
@@ -136,11 +136,11 @@ discard block |
||
| 136 | 136 | $this->files[$file->Location] = $directory.$file->strd_FileId; |
| 137 | 137 | $this->filesSize += $file->DataLen; |
| 138 | 138 | |
| 139 | - $this->filesData[$directory . $file->strd_FileId] = |
|
| 139 | + $this->filesData[$directory.$file->strd_FileId] = |
|
| 140 | 140 | [ |
| 141 | 141 | 'size' => $file->DataLen, |
| 142 | 142 | 'mtime' => |
| 143 | - strtotime((string)$file->isoRecDate), |
|
| 143 | + strtotime((string) $file->isoRecDate), |
|
| 144 | 144 | ]; |
| 145 | 145 | } |
| 146 | 146 | } |
@@ -242,7 +242,7 @@ discard block |
||
| 242 | 242 | public function extractFiles($outputFolder, array $files) |
| 243 | 243 | { |
| 244 | 244 | foreach ($files as $file) { |
| 245 | - $destination_file = rtrim($outputFolder, '/'). '/' . ltrim($file, '/'); |
|
| 245 | + $destination_file = rtrim($outputFolder, '/').'/'.ltrim($file, '/'); |
|
| 246 | 246 | $destination_dir = dirname($destination_file); |
| 247 | 247 | |
| 248 | 248 | if (!empty($destination_dir)) { |
@@ -84,8 +84,9 @@ discard block |
||
| 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 |
||
| 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 |
@@ -131,8 +133,9 @@ discard block |
||
| 131 | 133 | if ($files) { |
| 132 | 134 | /** @var \CFileDirDescriptors $file */ |
| 133 | 135 | foreach ($files as $file) { |
| 134 | - if (in_array($file->strd_FileId, ['.', '..']) || $file->IsDirectory()) |
|
| 135 | - continue; |
|
| 136 | + if (in_array($file->strd_FileId, ['.', '..']) || $file->IsDirectory()) { |
|
| 137 | + continue; |
|
| 138 | + } |
|
| 136 | 139 | $this->files[$file->Location] = $directory.$file->strd_FileId; |
| 137 | 140 | $this->filesSize += $file->DataLen; |
| 138 | 141 | |
@@ -184,8 +187,9 @@ discard block |
||
| 184 | 187 | */ |
| 185 | 188 | public function getFileData($fileName) |
| 186 | 189 | { |
| 187 | - if (!isset($this->filesData[$fileName])) |
|
| 188 | - return false; |
|
| 190 | + if (!isset($this->filesData[$fileName])) { |
|
| 191 | + return false; |
|
| 192 | + } |
|
| 189 | 193 | |
| 190 | 194 | return new ArchiveEntry( |
| 191 | 195 | $fileName, |
@@ -225,11 +229,14 @@ discard block |
||
| 225 | 229 | protected function prepareForFileExtracting($fileName) |
| 226 | 230 | { |
| 227 | 231 | $Location = array_search($fileName, $this->files, true); |
| 228 | - if (!isset($this->filesData[$fileName])) return false; |
|
| 232 | + if (!isset($this->filesData[$fileName])) { |
|
| 233 | + return false; |
|
| 234 | + } |
|
| 229 | 235 | $data = $this->filesData[$fileName]; |
| 230 | 236 | $Location_Real = $Location * $this->blockSize; |
| 231 | - if ($this->iso->Seek($Location_Real, SEEK_SET) === false) |
|
| 232 | - return false; |
|
| 237 | + if ($this->iso->Seek($Location_Real, SEEK_SET) === false) { |
|
| 238 | + return false; |
|
| 239 | + } |
|
| 233 | 240 | return $data; |
| 234 | 241 | } |
| 235 | 242 | |