@@ -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 | |
@@ -87,8 +87,9 @@ |
||
| 87 | 87 | : $this->zip->getEntries(); |
| 88 | 88 | |
| 89 | 89 | foreach ($files as $info) { |
| 90 | - if (method_exists($info, 'isFolder') ? $info->isFolder() : $info->isDirectory()) |
|
| 91 | - continue; |
|
| 90 | + if (method_exists($info, 'isFolder') ? $info->isFolder() : $info->isDirectory()) { |
|
| 91 | + continue; |
|
| 92 | + } |
|
| 92 | 93 | |
| 93 | 94 | $this->files[] = $information->files[] = str_replace('\\', '/', $info->getName()); |
| 94 | 95 | $information->compressedFilesSize += $info->getCompressedSize(); |
@@ -31,11 +31,11 @@ |
||
| 31 | 31 | $archive = $this->getArchive($input, $output); |
| 32 | 32 | |
| 33 | 33 | if (disk_free_space($output_dir) < $archive->getOriginalSize()) { |
| 34 | - throw new \LogicException('Archive size ' . implode($this->formatSize($archive->getOriginalSize())) . ' is more that available on disk ' |
|
| 34 | + throw new \LogicException('Archive size '.implode($this->formatSize($archive->getOriginalSize())).' is more that available on disk ' |
|
| 35 | 35 | . implode($this->formatSize(disk_free_space($output_dir)))); |
| 36 | 36 | } |
| 37 | 37 | $archive->extract($output_dir, $entry_selector, true); |
| 38 | - $output->writeln('<info>Extracted all archive contents (' . implode($this->formatSize($archive->getOriginalSize())) . ')</info>'); |
|
| 38 | + $output->writeln('<info>Extracted all archive contents ('.implode($this->formatSize($archive->getOriginalSize())).')</info>'); |
|
| 39 | 39 | |
| 40 | 40 | return 0; |
| 41 | 41 | } |
@@ -60,17 +60,17 @@ |
||
| 60 | 60 | foreach ($archive->getFiles($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->getFiles($filter) as $file) { |
@@ -33,7 +33,7 @@ |
||
| 33 | 33 | list($archive, $file) = $this->getArchiveAndFile($input, $output); |
| 34 | 34 | |
| 35 | 35 | $archive->delete($file); |
| 36 | - $output->writeln('<comment>- file "' . $file . '"</comment>'); |
|
| 36 | + $output->writeln('<comment>- file "'.$file.'"</comment>'); |
|
| 37 | 37 | |
| 38 | 38 | return 0; |
| 39 | 39 | } |
@@ -33,7 +33,7 @@ |
||
| 33 | 33 | $entry_selector = $input->getArgument('entrySelector'); |
| 34 | 34 | |
| 35 | 35 | $archive->extract($output_dir, $entry_selector, true); |
| 36 | - $output->writeln('<info>Extracted:</info> ' . implode(', ', $entry_selector) . ' (' . count($entry_selector) . ') file(s)'); |
|
| 36 | + $output->writeln('<info>Extracted:</info> '.implode(', ', $entry_selector).' ('.count($entry_selector).') file(s)'); |
|
| 37 | 37 | |
| 38 | 38 | return 0; |
| 39 | 39 | } |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | public static function open($fileName, $abilities = [], $password = null) |
| 65 | 65 | { |
| 66 | 66 | if (!file_exists($fileName) || !is_readable($fileName)) { |
| 67 | - throw new InvalidArgumentException('Could not open file: ' . $fileName . ' is not readable'); |
|
| 67 | + throw new InvalidArgumentException('Could not open file: '.$fileName.' is not readable'); |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | $format = Formats::detectArchiveFormat($fileName); |
@@ -287,7 +287,7 @@ discard block |
||
| 287 | 287 | public function getFileData($fileName) |
| 288 | 288 | { |
| 289 | 289 | if (!in_array($fileName, $this->files, true)) { |
| 290 | - throw new NonExistentArchiveFileException('File ' . $fileName . ' does not exist in archive'); |
|
| 290 | + throw new NonExistentArchiveFileException('File '.$fileName.' does not exist in archive'); |
|
| 291 | 291 | } |
| 292 | 292 | |
| 293 | 293 | return $this->archive->getFileData($fileName); |
@@ -303,7 +303,7 @@ discard block |
||
| 303 | 303 | public function getFileContent($fileName) |
| 304 | 304 | { |
| 305 | 305 | if (!in_array($fileName, $this->files, true)) { |
| 306 | - throw new NonExistentArchiveFileException('File ' . $fileName . ' does not exist in archive'); |
|
| 306 | + throw new NonExistentArchiveFileException('File '.$fileName.' does not exist in archive'); |
|
| 307 | 307 | } |
| 308 | 308 | |
| 309 | 309 | return $this->archive->getFileContent($fileName); |
@@ -319,7 +319,7 @@ discard block |
||
| 319 | 319 | public function getFileStream($fileName) |
| 320 | 320 | { |
| 321 | 321 | if (!in_array($fileName, $this->files, true)) { |
| 322 | - throw new NonExistentArchiveFileException('File ' . $fileName . ' does not exist in archive'); |
|
| 322 | + throw new NonExistentArchiveFileException('File '.$fileName.' does not exist in archive'); |
|
| 323 | 323 | } |
| 324 | 324 | |
| 325 | 325 | return $this->archive->getFileStream($fileName); |
@@ -416,7 +416,7 @@ discard block |
||
| 416 | 416 | public function addFile($file, $inArchiveName = null) |
| 417 | 417 | { |
| 418 | 418 | if (!is_file($file)) |
| 419 | - throw new InvalidArgumentException($file . ' is not a valid file to add in archive'); |
|
| 419 | + throw new InvalidArgumentException($file.' is not a valid file to add in archive'); |
|
| 420 | 420 | |
| 421 | 421 | return ($inArchiveName !== null |
| 422 | 422 | ? $this->add([$inArchiveName => $file]) |
@@ -450,7 +450,7 @@ discard block |
||
| 450 | 450 | public function addDirectory($directory, $inArchivePath = null) |
| 451 | 451 | { |
| 452 | 452 | if (!is_dir($directory) || !is_readable($directory)) |
| 453 | - throw new InvalidArgumentException($directory . ' is not a valid directory to add in archive'); |
|
| 453 | + throw new InvalidArgumentException($directory.' is not a valid directory to add in archive'); |
|
| 454 | 454 | |
| 455 | 455 | return ($inArchivePath !== null |
| 456 | 456 | ? $this->add([$inArchivePath => $directory]) |
@@ -500,7 +500,7 @@ discard block |
||
| 500 | 500 | if ($archiveName !== null) { |
| 501 | 501 | $archiveType = Formats::detectArchiveFormat($archiveName, false); |
| 502 | 502 | if ($archiveType === false) { |
| 503 | - throw new UnsupportedArchiveException('Could not detect archive type for name "' . $archiveName . '"'); |
|
| 503 | + throw new UnsupportedArchiveException('Could not detect archive type for name "'.$archiveName.'"'); |
|
| 504 | 504 | } |
| 505 | 505 | } |
| 506 | 506 | |
@@ -562,17 +562,17 @@ discard block |
||
| 562 | 562 | ) |
| 563 | 563 | { |
| 564 | 564 | if (file_exists($archiveName)) |
| 565 | - throw new FileAlreadyExistsException('Archive ' . $archiveName . ' already exists!'); |
|
| 565 | + throw new FileAlreadyExistsException('Archive '.$archiveName.' already exists!'); |
|
| 566 | 566 | |
| 567 | 567 | $info = static::prepareForArchiving($fileOrFiles, $archiveName); |
| 568 | 568 | |
| 569 | 569 | $abilities = [BasicDriver::CREATE]; |
| 570 | 570 | |
| 571 | 571 | if (!Formats::canCreate($info['type'])) |
| 572 | - throw new UnsupportedArchiveException('Unsupported archive type: ' . $info['type'] . ' of archive ' . $archiveName); |
|
| 572 | + throw new UnsupportedArchiveException('Unsupported archive type: '.$info['type'].' of archive '.$archiveName); |
|
| 573 | 573 | |
| 574 | 574 | if ($password !== null && !Formats::canEncrypt($info['type'])) |
| 575 | - throw new UnsupportedOperationException('Archive type ' . $info['type'] . ' can not be encrypted'); |
|
| 575 | + throw new UnsupportedOperationException('Archive type '.$info['type'].' can not be encrypted'); |
|
| 576 | 576 | if ($password !== null) { |
| 577 | 577 | $abilities[] = BasicDriver::CREATE_ENCRYPTED; |
| 578 | 578 | } |
@@ -580,7 +580,7 @@ discard block |
||
| 580 | 580 | /** @var BasicDriver $driver */ |
| 581 | 581 | $driver = Formats::getFormatDriver($info['type'], $abilities); |
| 582 | 582 | if ($driver === null) { |
| 583 | - throw new UnsupportedArchiveException('Unsupported archive type: ' . $info['type'] . ' of archive '); |
|
| 583 | + throw new UnsupportedArchiveException('Unsupported archive type: '.$info['type'].' of archive '); |
|
| 584 | 584 | } |
| 585 | 585 | |
| 586 | 586 | return $driver::createArchive( |
@@ -632,11 +632,11 @@ discard block |
||
| 632 | 632 | $info = static::prepareForArchiving($fileOrFiles); |
| 633 | 633 | $abilities = [BasicDriver::CREATE, BasicDriver::CREATE_IN_STRING]; |
| 634 | 634 | if (!Formats::canCreate($info['type'])) { |
| 635 | - throw new UnsupportedArchiveException('Unsupported archive type: ' . $info['type'] . ' of archive ' . $archiveName); |
|
| 635 | + throw new UnsupportedArchiveException('Unsupported archive type: '.$info['type'].' of archive '.$archiveName); |
|
| 636 | 636 | } |
| 637 | 637 | |
| 638 | 638 | if ($password !== null && !Formats::canEncrypt($info['type'])) { |
| 639 | - throw new UnsupportedOperationException('Archive type ' . $info['type'] . ' can not be encrypted'); |
|
| 639 | + throw new UnsupportedOperationException('Archive type '.$info['type'].' can not be encrypted'); |
|
| 640 | 640 | } |
| 641 | 641 | if ($password !== null) { |
| 642 | 642 | $abilities[] = BasicDriver::CREATE_ENCRYPTED; |
@@ -645,7 +645,7 @@ discard block |
||
| 645 | 645 | /** @var BasicDriver $driver */ |
| 646 | 646 | $driver = Formats::getFormatDriver($info['type'], $abilities); |
| 647 | 647 | if ($driver === null) { |
| 648 | - throw new UnsupportedArchiveException('Unsupported archive type: ' . $info['type'] . ' of archive '); |
|
| 648 | + throw new UnsupportedArchiveException('Unsupported archive type: '.$info['type'].' of archive '); |
|
| 649 | 649 | } |
| 650 | 650 | |
| 651 | 651 | return $driver::createArchiveInString( |
@@ -671,7 +671,7 @@ discard block |
||
| 671 | 671 | public static function archiveFile($file, $archiveName, $compressionLevel = BasicDriver::COMPRESSION_AVERAGE, $password = null) |
| 672 | 672 | { |
| 673 | 673 | if (!is_file($file)) { |
| 674 | - throw new InvalidArgumentException($file . ' is not a valid file to archive'); |
|
| 674 | + throw new InvalidArgumentException($file.' is not a valid file to archive'); |
|
| 675 | 675 | } |
| 676 | 676 | |
| 677 | 677 | return static::archive($file, $archiveName, $compressionLevel, $password) === 1; |
@@ -691,7 +691,7 @@ discard block |
||
| 691 | 691 | public static function archiveDirectory($directory, $archiveName, $compressionLevel = BasicDriver::COMPRESSION_AVERAGE, $password = null) |
| 692 | 692 | { |
| 693 | 693 | if (!is_dir($directory) || !is_readable($directory)) |
| 694 | - throw new InvalidArgumentException($directory . ' is not a valid directory to archive'); |
|
| 694 | + throw new InvalidArgumentException($directory.' is not a valid directory to archive'); |
|
| 695 | 695 | |
| 696 | 696 | return static::archive($directory, $archiveName, $compressionLevel, $password) > 0; |
| 697 | 697 | } |
@@ -707,7 +707,7 @@ discard block |
||
| 707 | 707 | $newFiles = []; |
| 708 | 708 | foreach ($files as $file) { |
| 709 | 709 | foreach ($archiveFiles as $archiveFile) { |
| 710 | - if (fnmatch($file . '*', $archiveFile)) { |
|
| 710 | + if (fnmatch($file.'*', $archiveFile)) { |
|
| 711 | 711 | $newFiles[] = $archiveFile; |
| 712 | 712 | } |
| 713 | 713 | } |
@@ -742,8 +742,8 @@ discard block |
||
| 742 | 742 | if (is_array($source)) { |
| 743 | 743 | foreach ($source as $sourceItem) { |
| 744 | 744 | static::importFilesFromDir( |
| 745 | - rtrim($sourceItem, '/\\*') . '/*', |
|
| 746 | - !empty($destination) ? $destination . '/' : null, |
|
| 745 | + rtrim($sourceItem, '/\\*').'/*', |
|
| 746 | + !empty($destination) ? $destination.'/' : null, |
|
| 747 | 747 | true, |
| 748 | 748 | $files |
| 749 | 749 | ); |
@@ -751,8 +751,8 @@ discard block |
||
| 751 | 751 | } else if (is_dir($source)) { |
| 752 | 752 | // one source for directories |
| 753 | 753 | static::importFilesFromDir( |
| 754 | - rtrim($source, '/\\*') . '/*', |
|
| 755 | - !empty($destination) ? $destination . '/' : null, |
|
| 754 | + rtrim($source, '/\\*').'/*', |
|
| 755 | + !empty($destination) ? $destination.'/' : null, |
|
| 756 | 756 | true, |
| 757 | 757 | $files |
| 758 | 758 | ); |
@@ -764,7 +764,7 @@ discard block |
||
| 764 | 764 | } else if (is_string($nodes)) { // passed one file or directory |
| 765 | 765 | // if is directory |
| 766 | 766 | if (is_dir($nodes)) |
| 767 | - static::importFilesFromDir(rtrim($nodes, '/\\*') . '/*', null, true, |
|
| 767 | + static::importFilesFromDir(rtrim($nodes, '/\\*').'/*', null, true, |
|
| 768 | 768 | $files); |
| 769 | 769 | else if (is_file($nodes)) |
| 770 | 770 | $files[basename($nodes)] = $nodes; |
@@ -789,10 +789,10 @@ discard block |
||
| 789 | 789 | |
| 790 | 790 | foreach (glob($source, GLOB_MARK) as $node) { |
| 791 | 791 | if (in_array(substr($node, -1), ['/', '\\'], true) && $recursive) { |
| 792 | - static::importFilesFromDir(str_replace('\\', '/', $node) . '*', |
|
| 793 | - $destination . basename($node) . '/', $recursive, $map); |
|
| 792 | + static::importFilesFromDir(str_replace('\\', '/', $node).'*', |
|
| 793 | + $destination.basename($node).'/', $recursive, $map); |
|
| 794 | 794 | } elseif (is_file($node) && is_readable($node)) { |
| 795 | - $map[$destination . basename($node)] = $node; |
|
| 795 | + $map[$destination.basename($node)] = $node; |
|
| 796 | 796 | } |
| 797 | 797 | } |
| 798 | 798 | } |
@@ -266,13 +266,15 @@ discard block |
||
| 266 | 266 | */ |
| 267 | 267 | public function getFiles($filter = null) |
| 268 | 268 | { |
| 269 | - if ($filter === null) |
|
| 270 | - return $this->files; |
|
| 269 | + if ($filter === null) { |
|
| 270 | + return $this->files; |
|
| 271 | + } |
|
| 271 | 272 | |
| 272 | 273 | $result = []; |
| 273 | 274 | foreach ($this->files as $file) { |
| 274 | - if (fnmatch($filter, $file)) |
|
| 275 | - $result[] = $file; |
|
| 275 | + if (fnmatch($filter, $file)) { |
|
| 276 | + $result[] = $file; |
|
| 277 | + } |
|
| 276 | 278 | } |
| 277 | 279 | return $result; |
| 278 | 280 | } |
@@ -395,8 +397,9 @@ discard block |
||
| 395 | 397 | { |
| 396 | 398 | $files_list = static::createFilesList($fileOrFiles); |
| 397 | 399 | |
| 398 | - if (empty($files_list)) |
|
| 399 | - throw new EmptyFileListException('Files list is empty!'); |
|
| 400 | + if (empty($files_list)) { |
|
| 401 | + throw new EmptyFileListException('Files list is empty!'); |
|
| 402 | + } |
|
| 400 | 403 | |
| 401 | 404 | $result = $this->archive->addFiles($files_list); |
| 402 | 405 | $this->scanArchive(); |
@@ -415,8 +418,9 @@ discard block |
||
| 415 | 418 | */ |
| 416 | 419 | public function addFile($file, $inArchiveName = null) |
| 417 | 420 | { |
| 418 | - if (!is_file($file)) |
|
| 419 | - throw new InvalidArgumentException($file . ' is not a valid file to add in archive'); |
|
| 421 | + if (!is_file($file)) { |
|
| 422 | + throw new InvalidArgumentException($file . ' is not a valid file to add in archive'); |
|
| 423 | + } |
|
| 420 | 424 | |
| 421 | 425 | return ($inArchiveName !== null |
| 422 | 426 | ? $this->add([$inArchiveName => $file]) |
@@ -449,8 +453,9 @@ discard block |
||
| 449 | 453 | */ |
| 450 | 454 | public function addDirectory($directory, $inArchivePath = null) |
| 451 | 455 | { |
| 452 | - if (!is_dir($directory) || !is_readable($directory)) |
|
| 453 | - throw new InvalidArgumentException($directory . ' is not a valid directory to add in archive'); |
|
| 456 | + if (!is_dir($directory) || !is_readable($directory)) { |
|
| 457 | + throw new InvalidArgumentException($directory . ' is not a valid directory to add in archive'); |
|
| 458 | + } |
|
| 454 | 459 | |
| 455 | 460 | return ($inArchivePath !== null |
| 456 | 461 | ? $this->add([$inArchivePath => $directory]) |
@@ -506,8 +511,9 @@ discard block |
||
| 506 | 511 | |
| 507 | 512 | $files_list = static::createFilesList($fileOrFiles); |
| 508 | 513 | |
| 509 | - if (empty($files_list)) |
|
| 510 | - throw new EmptyFileListException('Files list is empty!'); |
|
| 514 | + if (empty($files_list)) { |
|
| 515 | + throw new EmptyFileListException('Files list is empty!'); |
|
| 516 | + } |
|
| 511 | 517 | |
| 512 | 518 | $totalSize = 0; |
| 513 | 519 | foreach ($files_list as $fn) { |
@@ -561,18 +567,21 @@ discard block |
||
| 561 | 567 | $fileProgressCallable = null |
| 562 | 568 | ) |
| 563 | 569 | { |
| 564 | - if (file_exists($archiveName)) |
|
| 565 | - throw new FileAlreadyExistsException('Archive ' . $archiveName . ' already exists!'); |
|
| 570 | + if (file_exists($archiveName)) { |
|
| 571 | + throw new FileAlreadyExistsException('Archive ' . $archiveName . ' already exists!'); |
|
| 572 | + } |
|
| 566 | 573 | |
| 567 | 574 | $info = static::prepareForArchiving($fileOrFiles, $archiveName); |
| 568 | 575 | |
| 569 | 576 | $abilities = [BasicDriver::CREATE]; |
| 570 | 577 | |
| 571 | - if (!Formats::canCreate($info['type'])) |
|
| 572 | - throw new UnsupportedArchiveException('Unsupported archive type: ' . $info['type'] . ' of archive ' . $archiveName); |
|
| 578 | + if (!Formats::canCreate($info['type'])) { |
|
| 579 | + throw new UnsupportedArchiveException('Unsupported archive type: ' . $info['type'] . ' of archive ' . $archiveName); |
|
| 580 | + } |
|
| 573 | 581 | |
| 574 | - if ($password !== null && !Formats::canEncrypt($info['type'])) |
|
| 575 | - throw new UnsupportedOperationException('Archive type ' . $info['type'] . ' can not be encrypted'); |
|
| 582 | + if ($password !== null && !Formats::canEncrypt($info['type'])) { |
|
| 583 | + throw new UnsupportedOperationException('Archive type ' . $info['type'] . ' can not be encrypted'); |
|
| 584 | + } |
|
| 576 | 585 | if ($password !== null) { |
| 577 | 586 | $abilities[] = BasicDriver::CREATE_ENCRYPTED; |
| 578 | 587 | } |
@@ -690,8 +699,9 @@ discard block |
||
| 690 | 699 | */ |
| 691 | 700 | public static function archiveDirectory($directory, $archiveName, $compressionLevel = BasicDriver::COMPRESSION_AVERAGE, $password = null) |
| 692 | 701 | { |
| 693 | - if (!is_dir($directory) || !is_readable($directory)) |
|
| 694 | - throw new InvalidArgumentException($directory . ' is not a valid directory to archive'); |
|
| 702 | + if (!is_dir($directory) || !is_readable($directory)) { |
|
| 703 | + throw new InvalidArgumentException($directory . ' is not a valid directory to archive'); |
|
| 704 | + } |
|
| 695 | 705 | |
| 696 | 706 | return static::archive($directory, $archiveName, $compressionLevel, $password) > 0; |
| 697 | 707 | } |
@@ -727,9 +737,9 @@ discard block |
||
| 727 | 737 | if (is_array($nodes)) { |
| 728 | 738 | foreach ($nodes as $destination => $source) { |
| 729 | 739 | // new format |
| 730 | - if (is_numeric($destination)) |
|
| 731 | - $destination = $source; |
|
| 732 | - else { |
|
| 740 | + if (is_numeric($destination)) { |
|
| 741 | + $destination = $source; |
|
| 742 | + } else { |
|
| 733 | 743 | // old format |
| 734 | 744 | if (is_string($source) && !file_exists($source)) { |
| 735 | 745 | list($destination, $source) = [$source, $destination]; |
@@ -763,11 +773,12 @@ discard block |
||
| 763 | 773 | |
| 764 | 774 | } else if (is_string($nodes)) { // passed one file or directory |
| 765 | 775 | // if is directory |
| 766 | - if (is_dir($nodes)) |
|
| 767 | - static::importFilesFromDir(rtrim($nodes, '/\\*') . '/*', null, true, |
|
| 776 | + if (is_dir($nodes)) { |
|
| 777 | + static::importFilesFromDir(rtrim($nodes, '/\\*') . '/*', null, true, |
|
| 768 | 778 | $files); |
| 769 | - else if (is_file($nodes)) |
|
| 770 | - $files[basename($nodes)] = $nodes; |
|
| 779 | + } else if (is_file($nodes)) { |
|
| 780 | + $files[basename($nodes)] = $nodes; |
|
| 781 | + } |
|
| 771 | 782 | } |
| 772 | 783 | |
| 773 | 784 | return $files; |
@@ -784,8 +795,9 @@ discard block |
||
| 784 | 795 | // $map[$destination] = rtrim($source, '/*'); |
| 785 | 796 | // do not map root archive folder |
| 786 | 797 | |
| 787 | - if ($destination !== null) |
|
| 788 | - $map[$destination] = null; |
|
| 798 | + if ($destination !== null) { |
|
| 799 | + $map[$destination] = null; |
|
| 800 | + } |
|
| 789 | 801 | |
| 790 | 802 | foreach (glob($source, GLOB_MARK) as $node) { |
| 791 | 803 | if (in_array(substr($node, -1), ['/', '\\'], true) && $recursive) { |