@@ -57,7 +57,9 @@ discard block |
||
| 57 | 57 | public static function checkFormatSupport($format) |
| 58 | 58 | { |
| 59 | 59 | $availability = class_exists('\Archive_Tar'); |
| 60 | - if (!$availability) return false; |
|
| 60 | + if (!$availability) { |
|
| 61 | + return false; |
|
| 62 | + } |
|
| 61 | 63 | switch ($format) { |
| 62 | 64 | case Formats::TAR: |
| 63 | 65 | return true; |
@@ -140,10 +142,11 @@ discard block |
||
| 140 | 142 | break; |
| 141 | 143 | } |
| 142 | 144 | |
| 143 | - if (isset($tar_aname)) |
|
| 144 | - $tar = new Archive_Tar($tar_aname, $compression); |
|
| 145 | - else |
|
| 146 | - $tar = new Archive_Tar($archiveFileName, $compression); |
|
| 145 | + if (isset($tar_aname)) { |
|
| 146 | + $tar = new Archive_Tar($tar_aname, $compression); |
|
| 147 | + } else { |
|
| 148 | + $tar = new Archive_Tar($archiveFileName, $compression); |
|
| 149 | + } |
|
| 147 | 150 | |
| 148 | 151 | $current_file = 0; |
| 149 | 152 | $total_files = count($files); |
@@ -152,11 +155,13 @@ discard block |
||
| 152 | 155 | $add_dir = dirname($localName); |
| 153 | 156 | |
| 154 | 157 | if (is_null($filename)) { |
| 155 | - if ($tar->addString($localName, '') === false) |
|
| 156 | - throw new ArchiveCreationException('Error when adding directory '.$localName.' to archive'); |
|
| 158 | + if ($tar->addString($localName, '') === false) { |
|
| 159 | + throw new ArchiveCreationException('Error when adding directory '.$localName.' to archive'); |
|
| 160 | + } |
|
| 157 | 161 | } else { |
| 158 | - if ($tar->addModify($filename, $add_dir, $remove_dir) === false) |
|
| 159 | - throw new ArchiveCreationException('Error when adding file '.$filename.' to archive'); |
|
| 162 | + if ($tar->addModify($filename, $add_dir, $remove_dir) === false) { |
|
| 163 | + throw new ArchiveCreationException('Error when adding file '.$filename.' to archive'); |
|
| 164 | + } |
|
| 160 | 165 | } |
| 161 | 166 | if ($fileProgressCallable !== null) { |
| 162 | 167 | call_user_func_array($fileProgressCallable, [$current_file++, $total_files, $filename, $localName]); |
@@ -216,8 +221,9 @@ discard block |
||
| 216 | 221 | continue; |
| 217 | 222 | } |
| 218 | 223 | // skip directories |
| 219 | - if ($file['typeflag'] == '5' || substr($file['filename'], -1) === '/') |
|
| 220 | - continue; |
|
| 224 | + if ($file['typeflag'] == '5' || substr($file['filename'], -1) === '/') { |
|
| 225 | + continue; |
|
| 226 | + } |
|
| 221 | 227 | $information->files[] = $file['filename']; |
| 222 | 228 | $information->uncompressedFilesSize += $file['size']; |
| 223 | 229 | $this->pearFilesIndex[$file['filename']] = $i; |
@@ -262,14 +268,16 @@ discard block |
||
| 262 | 268 | */ |
| 263 | 269 | public function getFileData($fileName) |
| 264 | 270 | { |
| 265 | - if (!isset($this->pearFilesIndex[$fileName])) |
|
| 266 | - throw new NonExistentArchiveFileException('File '.$fileName.' is not found in archive files list'); |
|
| 271 | + if (!isset($this->pearFilesIndex[$fileName])) { |
|
| 272 | + throw new NonExistentArchiveFileException('File '.$fileName.' is not found in archive files list'); |
|
| 273 | + } |
|
| 267 | 274 | |
| 268 | 275 | $index = $this->pearFilesIndex[$fileName]; |
| 269 | 276 | |
| 270 | 277 | $files_list = $this->tar->listContent(); |
| 271 | - if (!isset($files_list[$index])) |
|
| 272 | - throw new NonExistentArchiveFileException('File '.$fileName.' is not found in Tar archive'); |
|
| 278 | + if (!isset($files_list[$index])) { |
|
| 279 | + throw new NonExistentArchiveFileException('File '.$fileName.' is not found in Tar archive'); |
|
| 280 | + } |
|
| 273 | 281 | |
| 274 | 282 | $data = $files_list[$index]; |
| 275 | 283 | unset($files_list); |
@@ -284,8 +292,9 @@ discard block |
||
| 284 | 292 | */ |
| 285 | 293 | public function getFileContent($fileName) |
| 286 | 294 | { |
| 287 | - if (!isset($this->pearFilesIndex[$fileName])) |
|
| 288 | - throw new NonExistentArchiveFileException('File '.$fileName.' is not found in archive files list'); |
|
| 295 | + if (!isset($this->pearFilesIndex[$fileName])) { |
|
| 296 | + throw new NonExistentArchiveFileException('File '.$fileName.' is not found in archive files list'); |
|
| 297 | + } |
|
| 289 | 298 | |
| 290 | 299 | return $this->tar->extractInString($fileName); |
| 291 | 300 | } |
@@ -295,8 +304,9 @@ discard block |
||
| 295 | 304 | */ |
| 296 | 305 | public function getFileStream($fileName) |
| 297 | 306 | { |
| 298 | - if (!isset($this->pearFilesIndex[$fileName])) |
|
| 299 | - throw new NonExistentArchiveFileException('File '.$fileName.' is not found in archive files list'); |
|
| 307 | + if (!isset($this->pearFilesIndex[$fileName])) { |
|
| 308 | + throw new NonExistentArchiveFileException('File '.$fileName.' is not found in archive files list'); |
|
| 309 | + } |
|
| 300 | 310 | |
| 301 | 311 | return self::wrapStringInStream($this->tar->extractInString($fileName)); |
| 302 | 312 | } |
@@ -58,12 +58,14 @@ discard block |
||
| 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,11 +106,13 @@ discard block |
||
| 104 | 106 | */ |
| 105 | 107 | public static function getInstallationInstruction() |
| 106 | 108 | { |
| 107 | - if (!class_exists('\Archive7z\Archive7z')) |
|
| 108 | - return 'install library `gemorroj/archive7z` and console program p7zip (7za)'; |
|
| 109 | + if (!class_exists('\Archive7z\Archive7z')) { |
|
| 110 | + return 'install library `gemorroj/archive7z` and console program p7zip (7za)'; |
|
| 111 | + } |
|
| 109 | 112 | |
| 110 | - if (Archive7z::getBinaryVersion() === false) |
|
| 111 | - return 'install console program p7zip (7za)'; |
|
| 113 | + if (Archive7z::getBinaryVersion() === false) { |
|
| 114 | + return 'install console program p7zip (7za)'; |
|
| 115 | + } |
|
| 112 | 116 | |
| 113 | 117 | return null; |
| 114 | 118 | } |
@@ -121,8 +125,9 @@ discard block |
||
| 121 | 125 | try { |
| 122 | 126 | $this->format = $format; |
| 123 | 127 | $this->sevenZip = new Archive7z($archiveFileName, null, null); |
| 124 | - if ($password !== null) |
|
| 125 | - $this->sevenZip->setPassword($password); |
|
| 128 | + if ($password !== null) { |
|
| 129 | + $this->sevenZip->setPassword($password); |
|
| 130 | + } |
|
| 126 | 131 | } catch (\Archive7z\Exception $e) { |
| 127 | 132 | throw new Exception('Could not open 7Zip archive: '.$e->getMessage(), $e->getCode(), $e); |
| 128 | 133 | } |
@@ -140,8 +145,9 @@ discard block |
||
| 140 | 145 | continue; |
| 141 | 146 | } |
| 142 | 147 | |
| 143 | - if (!isset($can_get_unix_path)) |
|
| 144 | - $can_get_unix_path = method_exists($entry, 'getUnixPath'); |
|
| 148 | + if (!isset($can_get_unix_path)) { |
|
| 149 | + $can_get_unix_path = method_exists($entry, 'getUnixPath'); |
|
| 150 | + } |
|
| 145 | 151 | |
| 146 | 152 | $information->files[] = $can_get_unix_path |
| 147 | 153 | ? $entry->getUnixPath() |
@@ -159,8 +165,9 @@ discard block |
||
| 159 | 165 | { |
| 160 | 166 | $files = []; |
| 161 | 167 | foreach ($this->sevenZip->getEntries() as $entry) { |
| 162 | - if ($entry->isDirectory()) |
|
| 163 | - continue; |
|
| 168 | + if ($entry->isDirectory()) { |
|
| 169 | + continue; |
|
| 170 | + } |
|
| 164 | 171 | $files[] = $entry->getPath(); |
| 165 | 172 | } |
| 166 | 173 | return $files; |
@@ -301,8 +308,9 @@ discard block |
||
| 301 | 308 | public function addFileFromString($inArchiveName, $content) |
| 302 | 309 | { |
| 303 | 310 | $tmp_file = tempnam(sys_get_temp_dir(), 'ua'); |
| 304 | - if (!$tmp_file) |
|
| 305 | - throw new ArchiveModificationException('Could not create temporarily file'); |
|
| 311 | + if (!$tmp_file) { |
|
| 312 | + throw new ArchiveModificationException('Could not create temporarily file'); |
|
| 313 | + } |
|
| 306 | 314 | |
| 307 | 315 | file_put_contents($tmp_file, $content); |
| 308 | 316 | $this->sevenZip->addEntry($tmp_file, true); |
@@ -352,8 +360,9 @@ discard block |
||
| 352 | 360 | $total_files = count($files); |
| 353 | 361 | |
| 354 | 362 | $seven_zip = new Archive7z($archiveFileName); |
| 355 | - if ($password !== null) |
|
| 356 | - $seven_zip->setPassword($password); |
|
| 363 | + if ($password !== null) { |
|
| 364 | + $seven_zip->setPassword($password); |
|
| 365 | + } |
|
| 357 | 366 | $seven_zip->setCompressionLevel($compressionLevelMap[$compressionLevel]); |
| 358 | 367 | foreach ($files as $localName => $filename) { |
| 359 | 368 | if ($filename !== null) { |
@@ -385,8 +394,9 @@ discard block |
||
| 385 | 394 | Formats::TAR, |
| 386 | 395 | Formats::LZMA, |
| 387 | 396 | Formats::ZIP] |
| 388 | - )) |
|
| 389 | - return self::canRenameFiles(); |
|
| 397 | + )) { |
|
| 398 | + return self::canRenameFiles(); |
|
| 399 | + } |
|
| 390 | 400 | |
| 391 | 401 | return false; |
| 392 | 402 | } |
@@ -24,10 +24,12 @@ discard block |
||
| 24 | 24 | */ |
| 25 | 25 | public function __construct($archiveFileName, $format, $password = null) |
| 26 | 26 | { |
| 27 | - if (static::FORMAT_SUFFIX === null) |
|
| 28 | - throw new \Exception('Format should be initialized'); |
|
| 29 | - if ($password !== null) |
|
| 30 | - throw new UnsupportedOperationException(self::FORMAT_SUFFIX.' archive does not support password!'); |
|
| 27 | + if (static::FORMAT_SUFFIX === null) { |
|
| 28 | + throw new \Exception('Format should be initialized'); |
|
| 29 | + } |
|
| 30 | + if ($password !== null) { |
|
| 31 | + throw new UnsupportedOperationException(self::FORMAT_SUFFIX.' archive does not support password!'); |
|
| 32 | + } |
|
| 31 | 33 | |
| 32 | 34 | $this->fileName = $archiveFileName; |
| 33 | 35 | $this->inArchiveFileName = basename($archiveFileName, '.'.static::FORMAT_SUFFIX); |
@@ -95,8 +97,9 @@ discard block |
||
| 95 | 97 | public function extractArchive($outputFolder) |
| 96 | 98 | { |
| 97 | 99 | $data = $this->getFileContent($this->inArchiveFileName); |
| 98 | - if ($data === false) |
|
| 99 | - throw new ArchiveExtractionException('Could not extract archive'); |
|
| 100 | + if ($data === false) { |
|
| 101 | + throw new ArchiveExtractionException('Could not extract archive'); |
|
| 102 | + } |
|
| 100 | 103 | |
| 101 | 104 | $size = strlen($data); |
| 102 | 105 | $written = file_put_contents($outputFolder.$this->inArchiveFileName, $data); |
@@ -251,13 +251,15 @@ discard block |
||
| 251 | 251 | */ |
| 252 | 252 | public function getFileNames($filter = null) |
| 253 | 253 | { |
| 254 | - if ($filter === null) |
|
| 255 | - return $this->files; |
|
| 254 | + if ($filter === null) { |
|
| 255 | + return $this->files; |
|
| 256 | + } |
|
| 256 | 257 | |
| 257 | 258 | $result = []; |
| 258 | 259 | foreach ($this->files as $file) { |
| 259 | - if (fnmatch($filter, $file)) |
|
| 260 | - $result[] = $file; |
|
| 260 | + if (fnmatch($filter, $file)) { |
|
| 261 | + $result[] = $file; |
|
| 262 | + } |
|
| 261 | 263 | } |
| 262 | 264 | return $result; |
| 263 | 265 | } |
@@ -384,8 +386,9 @@ discard block |
||
| 384 | 386 | { |
| 385 | 387 | $files_list = static::createFilesList($fileOrFiles); |
| 386 | 388 | |
| 387 | - if (empty($files_list)) |
|
| 388 | - throw new EmptyFileListException('Files list is empty!'); |
|
| 389 | + if (empty($files_list)) { |
|
| 390 | + throw new EmptyFileListException('Files list is empty!'); |
|
| 391 | + } |
|
| 389 | 392 | |
| 390 | 393 | $result = $this->archive->addFiles($files_list); |
| 391 | 394 | $this->scanArchive(); |
@@ -404,8 +407,9 @@ discard block |
||
| 404 | 407 | */ |
| 405 | 408 | public function addFile($file, $inArchiveName = null) |
| 406 | 409 | { |
| 407 | - if (!is_file($file)) |
|
| 408 | - throw new InvalidArgumentException($file.' is not a valid file to add in archive'); |
|
| 410 | + if (!is_file($file)) { |
|
| 411 | + throw new InvalidArgumentException($file.' is not a valid file to add in archive'); |
|
| 412 | + } |
|
| 409 | 413 | |
| 410 | 414 | return ($inArchiveName !== null |
| 411 | 415 | ? $this->addFiles([$inArchiveName => $file]) |
@@ -438,8 +442,9 @@ discard block |
||
| 438 | 442 | */ |
| 439 | 443 | public function addDirectory($directory, $inArchivePath = null) |
| 440 | 444 | { |
| 441 | - if (!is_dir($directory) || !is_readable($directory)) |
|
| 442 | - throw new InvalidArgumentException($directory.' is not a valid directory to add in archive'); |
|
| 445 | + if (!is_dir($directory) || !is_readable($directory)) { |
|
| 446 | + throw new InvalidArgumentException($directory.' is not a valid directory to add in archive'); |
|
| 447 | + } |
|
| 443 | 448 | |
| 444 | 449 | return ($inArchivePath !== null |
| 445 | 450 | ? $this->addFiles([$inArchivePath => $directory]) |
@@ -463,13 +468,15 @@ discard block |
||
| 463 | 468 | { |
| 464 | 469 | $archiveType = Formats::detectArchiveFormat($archiveName, false); |
| 465 | 470 | |
| 466 | - if ($archiveType === false) |
|
| 467 | - throw new UnsupportedArchiveException('Could not detect archive type for name "'.$archiveName.'"'); |
|
| 471 | + if ($archiveType === false) { |
|
| 472 | + throw new UnsupportedArchiveException('Could not detect archive type for name "'.$archiveName.'"'); |
|
| 473 | + } |
|
| 468 | 474 | |
| 469 | 475 | $files_list = static::createFilesList($fileOrFiles); |
| 470 | 476 | |
| 471 | - if (empty($files_list)) |
|
| 472 | - throw new EmptyFileListException('Files list is empty!'); |
|
| 477 | + if (empty($files_list)) { |
|
| 478 | + throw new EmptyFileListException('Files list is empty!'); |
|
| 479 | + } |
|
| 473 | 480 | |
| 474 | 481 | $totalSize = 0; |
| 475 | 482 | foreach ($files_list as $fn) { |
@@ -521,16 +528,19 @@ discard block |
||
| 521 | 528 | $fileProgressCallable = null |
| 522 | 529 | ) |
| 523 | 530 | { |
| 524 | - if (file_exists($archiveName)) |
|
| 525 | - throw new FileAlreadyExistsException('Archive '.$archiveName.' already exists!'); |
|
| 531 | + if (file_exists($archiveName)) { |
|
| 532 | + throw new FileAlreadyExistsException('Archive '.$archiveName.' already exists!'); |
|
| 533 | + } |
|
| 526 | 534 | |
| 527 | 535 | $info = static::prepareForArchiving($fileOrFiles, $archiveName); |
| 528 | 536 | |
| 529 | - if (!Formats::canCreate($info['type'])) |
|
| 530 | - throw new UnsupportedArchiveException('Unsupported archive type: '.$info['type'].' of archive '.$archiveName); |
|
| 537 | + if (!Formats::canCreate($info['type'])) { |
|
| 538 | + throw new UnsupportedArchiveException('Unsupported archive type: '.$info['type'].' of archive '.$archiveName); |
|
| 539 | + } |
|
| 531 | 540 | |
| 532 | - if ($password !== null && !Formats::canEncrypt($info['type'])) |
|
| 533 | - throw new UnsupportedOperationException('Archive type '.$info['type'].' can not be encrypted'); |
|
| 541 | + if ($password !== null && !Formats::canEncrypt($info['type'])) { |
|
| 542 | + throw new UnsupportedOperationException('Archive type '.$info['type'].' can not be encrypted'); |
|
| 543 | + } |
|
| 534 | 544 | |
| 535 | 545 | /** @var BasicDriver $driver */ |
| 536 | 546 | $driver = Formats::getFormatDriver($info['type'], true); |
@@ -578,8 +588,9 @@ discard block |
||
| 578 | 588 | */ |
| 579 | 589 | public static function archiveDirectory($directory, $archiveName, $compressionLevel = BasicDriver::COMPRESSION_AVERAGE, $password = null) |
| 580 | 590 | { |
| 581 | - if (!is_dir($directory) || !is_readable($directory)) |
|
| 582 | - throw new InvalidArgumentException($directory.' is not a valid directory to archive'); |
|
| 591 | + if (!is_dir($directory) || !is_readable($directory)) { |
|
| 592 | + throw new InvalidArgumentException($directory.' is not a valid directory to archive'); |
|
| 593 | + } |
|
| 583 | 594 | |
| 584 | 595 | return static::archiveFiles($directory, $archiveName, $compressionLevel, $password) > 0; |
| 585 | 596 | } |
@@ -615,9 +626,9 @@ discard block |
||
| 615 | 626 | if (is_array($nodes)) { |
| 616 | 627 | foreach ($nodes as $destination => $source) { |
| 617 | 628 | // new format |
| 618 | - if (is_numeric($destination)) |
|
| 619 | - $destination = $source; |
|
| 620 | - else { |
|
| 629 | + if (is_numeric($destination)) { |
|
| 630 | + $destination = $source; |
|
| 631 | + } else { |
|
| 621 | 632 | // old format |
| 622 | 633 | if (is_string($source) && !file_exists($source)) { |
| 623 | 634 | list($destination, $source) = [$source, $destination]; |
@@ -651,11 +662,12 @@ discard block |
||
| 651 | 662 | |
| 652 | 663 | } else if (is_string($nodes)) { // passed one file or directory |
| 653 | 664 | // if is directory |
| 654 | - if (is_dir($nodes)) |
|
| 655 | - static::importFilesFromDir(rtrim($nodes, '/\\*').'/*', null, true, |
|
| 665 | + if (is_dir($nodes)) { |
|
| 666 | + static::importFilesFromDir(rtrim($nodes, '/\\*').'/*', null, true, |
|
| 656 | 667 | $files); |
| 657 | - else if (is_file($nodes)) |
|
| 658 | - $files[basename($nodes)] = $nodes; |
|
| 668 | + } else if (is_file($nodes)) { |
|
| 669 | + $files[basename($nodes)] = $nodes; |
|
| 670 | + } |
|
| 659 | 671 | } |
| 660 | 672 | |
| 661 | 673 | return $files; |
@@ -672,8 +684,9 @@ discard block |
||
| 672 | 684 | // $map[$destination] = rtrim($source, '/*'); |
| 673 | 685 | // do not map root archive folder |
| 674 | 686 | |
| 675 | - if ($destination !== null) |
|
| 676 | - $map[$destination] = null; |
|
| 687 | + if ($destination !== null) { |
|
| 688 | + $map[$destination] = null; |
|
| 689 | + } |
|
| 677 | 690 | |
| 678 | 691 | foreach (glob($source, GLOB_MARK) as $node) { |
| 679 | 692 | if (in_array(substr($node, -1), ['/', '\\'], true) && $recursive) { |
@@ -33,7 +33,8 @@ |
||
| 33 | 33 | $output->writeln("\t". 'uncompressed: '.implode(' ', $this->formatSize($archive->getOriginalSize(), 2))); |
| 34 | 34 | $output->writeln("\t" . 'compressed: ' . implode(' ', $this->formatSize($archive->getCompressedSize(), 2))); |
| 35 | 35 | $output->writeln("\t" . 'ratio: <info>' . round($archive->getOriginalSize() / $archive->getCompressedSize(), 6) . '/1 (' . floor($archive->getCompressedSize() / $archive->getOriginalSize() * 100) . '%</info>)'); |
| 36 | - if (!empty($comment = $archive->getComment())) |
|
| 37 | - $output->writeln('Comment: <comment>' . $comment . '</comment>'); |
|
| 36 | + if (!empty($comment = $archive->getComment())) { |
|
| 37 | + $output->writeln('Comment: <comment>' . $comment . '</comment>'); |
|
| 38 | + } |
|
| 38 | 39 | } |
| 39 | 40 | } |
@@ -41,8 +41,9 @@ |
||
| 41 | 41 | $output->writeln("\t" . 'compressed: ' . implode(' ', $this->formatSize($details->compressedSize, 2))); |
| 42 | 42 | $output->writeln("\t" . 'ratio: <info>' . round($details->uncompressedSize / $details->compressedSize, 6) . '/1 (' . floor($details->compressedSize / $details->uncompressedSize * 100) . '%</info>)'); |
| 43 | 43 | $output->writeln('Modificated: ' . $this->formatDate($details->modificationTime)); |
| 44 | - if (!empty($comment = $details->comment)) |
|
| 45 | - $output->writeln('Comment: <comment>' . $comment . '</comment>'); |
|
| 44 | + if (!empty($comment = $details->comment)) { |
|
| 45 | + $output->writeln('Comment: <comment>' . $comment . '</comment>'); |
|
| 46 | + } |
|
| 46 | 47 | |
| 47 | 48 | if (empty($input->getArgument('file'))) { |
| 48 | 49 | $helper = $this->getHelper('question'); |
@@ -15,12 +15,14 @@ discard block |
||
| 15 | 15 | */ |
| 16 | 16 | protected function open($file, $password = null) |
| 17 | 17 | { |
| 18 | - if (!UnifiedArchive::canOpen($file)) |
|
| 19 | - throw new \Exception('Could not open archive '.$file.'. Try installing suggested packages or run `cam -f` to see formats support.'); |
|
| 18 | + if (!UnifiedArchive::canOpen($file)) { |
|
| 19 | + throw new \Exception('Could not open archive '.$file.'. Try installing suggested packages or run `cam -f` to see formats support.'); |
|
| 20 | + } |
|
| 20 | 21 | |
| 21 | 22 | $archive = UnifiedArchive::open($file, $password); |
| 22 | - if ($archive === null) |
|
| 23 | - throw new \Exception('Could not open archive '.$file); |
|
| 23 | + if ($archive === null) { |
|
| 24 | + throw new \Exception('Could not open archive '.$file); |
|
| 25 | + } |
|
| 24 | 26 | |
| 25 | 27 | return $archive; |
| 26 | 28 | } |
@@ -33,17 +35,18 @@ discard block |
||
| 33 | 35 | */ |
| 34 | 36 | public function formatDate($unixtime) |
| 35 | 37 | { |
| 36 | - if (strtotime('today') < $unixtime) |
|
| 37 | - return 'Today, '.date('G:m', $unixtime); |
|
| 38 | - else if (strtotime('yesterday') < $unixtime) |
|
| 39 | - return 'Yesterday, '.date('G:m', $unixtime); |
|
| 40 | - else { |
|
| 38 | + if (strtotime('today') < $unixtime) { |
|
| 39 | + return 'Today, '.date('G:m', $unixtime); |
|
| 40 | + } else if (strtotime('yesterday') < $unixtime) { |
|
| 41 | + return 'Yesterday, '.date('G:m', $unixtime); |
|
| 42 | + } else { |
|
| 41 | 43 | $datetime = new \DateTime(); |
| 42 | 44 | $datetime->setTimestamp($unixtime); |
| 43 | - if ($datetime->format('Y') == date('Y')) |
|
| 44 | - return $datetime->format('d M, H:m'); |
|
| 45 | - else |
|
| 46 | - return $datetime->format('d M Y, H:m'); |
|
| 45 | + if ($datetime->format('Y') == date('Y')) { |
|
| 46 | + return $datetime->format('d M, H:m'); |
|
| 47 | + } else { |
|
| 48 | + return $datetime->format('d M Y, H:m'); |
|
| 49 | + } |
|
| 47 | 50 | } |
| 48 | 51 | } |
| 49 | 52 | |
@@ -58,9 +58,9 @@ |
||
| 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 | } |