@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | { |
21 | 21 | if (!UnifiedArchive::canOpen($file, !empty($password))) { |
22 | 22 | throw new \Exception( |
23 | - 'Could not open archive ' . $file . '. Try installing suggested packages or run `cam -f` to see formats support.' |
|
23 | + 'Could not open archive '.$file.'. Try installing suggested packages or run `cam -f` to see formats support.' |
|
24 | 24 | ); |
25 | 25 | } |
26 | 26 | |
@@ -92,10 +92,10 @@ discard block |
||
92 | 92 | protected function resolveDriverName($driver) |
93 | 93 | { |
94 | 94 | if (strpos($driver, '\\') === false) { |
95 | - if (class_exists('\\wapmorgan\\UnifiedArchive\\Drivers\\' . $driver)) { |
|
96 | - $driver = '\\wapmorgan\\UnifiedArchive\\Drivers\\' . $driver; |
|
97 | - } else if (class_exists('\\wapmorgan\\UnifiedArchive\\Drivers\\OneFile\\' . $driver)) { |
|
98 | - $driver = '\\wapmorgan\\UnifiedArchive\\Drivers\\OneFile\\' . $driver; |
|
95 | + if (class_exists('\\wapmorgan\\UnifiedArchive\\Drivers\\'.$driver)) { |
|
96 | + $driver = '\\wapmorgan\\UnifiedArchive\\Drivers\\'.$driver; |
|
97 | + } else if (class_exists('\\wapmorgan\\UnifiedArchive\\Drivers\\OneFile\\'.$driver)) { |
|
98 | + $driver = '\\wapmorgan\\UnifiedArchive\\Drivers\\OneFile\\'.$driver; |
|
99 | 99 | } |
100 | 100 | } |
101 | 101 | if ($driver[0] !== '\\') { |
@@ -25,8 +25,9 @@ discard block |
||
25 | 25 | } |
26 | 26 | |
27 | 27 | $archive = UnifiedArchive::open($file, [], $password); |
28 | - if ($archive === null) |
|
29 | - throw new \Exception('Could not open archive '.$file); |
|
28 | + if ($archive === null) { |
|
29 | + throw new \Exception('Could not open archive '.$file); |
|
30 | + } |
|
30 | 31 | |
31 | 32 | return $archive; |
32 | 33 | } |
@@ -39,17 +40,18 @@ discard block |
||
39 | 40 | */ |
40 | 41 | public function formatDate($unixtime) |
41 | 42 | { |
42 | - if (strtotime('today') < $unixtime) |
|
43 | - return 'Today, '.date('G:m', $unixtime); |
|
44 | - else if (strtotime('yesterday') < $unixtime) |
|
45 | - return 'Yesterday, '.date('G:m', $unixtime); |
|
46 | - else { |
|
43 | + if (strtotime('today') < $unixtime) { |
|
44 | + return 'Today, '.date('G:m', $unixtime); |
|
45 | + } else if (strtotime('yesterday') < $unixtime) { |
|
46 | + return 'Yesterday, '.date('G:m', $unixtime); |
|
47 | + } else { |
|
47 | 48 | $datetime = new \DateTime(); |
48 | 49 | $datetime->setTimestamp($unixtime); |
49 | - if ($datetime->format('Y') == date('Y')) |
|
50 | - return $datetime->format('d M, H:m'); |
|
51 | - else |
|
52 | - return $datetime->format('d M Y, H:m'); |
|
50 | + if ($datetime->format('Y') == date('Y')) { |
|
51 | + return $datetime->format('d M, H:m'); |
|
52 | + } else { |
|
53 | + return $datetime->format('d M Y, H:m'); |
|
54 | + } |
|
53 | 55 | } |
54 | 56 | } |
55 | 57 |
@@ -34,9 +34,9 @@ discard block |
||
34 | 34 | if ($driver !== null) { |
35 | 35 | $driver = $this->resolveDriverName($driver); |
36 | 36 | if (!class_exists($driver) || !is_a($driver, BasicDriver::class, true)) { |
37 | - throw new \InvalidArgumentException('Class "' . $driver . '" not found or not in BasicDriver children'); |
|
37 | + throw new \InvalidArgumentException('Class "'.$driver.'" not found or not in BasicDriver children'); |
|
38 | 38 | } |
39 | - $output->writeln('Supported formats by <info>' . $driver . '</info>'); |
|
39 | + $output->writeln('Supported formats by <info>'.$driver.'</info>'); |
|
40 | 40 | |
41 | 41 | $headers = array_keys(Abilities::$abilitiesLabels); |
42 | 42 | array_unshift($headers, 'format'); |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | foreach (array_combine(array_values(Abilities::$abilitiesShortCuts), array_keys( |
92 | 92 | Abilities::$abilitiesLabels |
93 | 93 | )) as $shortCut => $label) { |
94 | - $output->writeln('<info>' . $shortCut . '</info> - ' . $label); |
|
94 | + $output->writeln('<info>'.$shortCut.'</info> - '.$label); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | return 0; |
@@ -41,7 +41,7 @@ |
||
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 | $headers = array_keys(Abilities::$abilitiesLabels); |
@@ -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); |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | if ($archiveName !== null) { |
113 | 113 | $archiveType = Formats::detectArchiveFormat($archiveName, false); |
114 | 114 | if ($archiveType === null) { |
115 | - throw new UnsupportedArchiveException('Could not detect archive type for name "' . $archiveName . '"'); |
|
115 | + throw new UnsupportedArchiveException('Could not detect archive type for name "'.$archiveName.'"'); |
|
116 | 116 | } |
117 | 117 | } |
118 | 118 | |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | ) |
179 | 179 | { |
180 | 180 | if (file_exists($archiveName)) { |
181 | - throw new FileAlreadyExistsException('Archive ' . $archiveName . ' already exists!'); |
|
181 | + throw new FileAlreadyExistsException('Archive '.$archiveName.' already exists!'); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | $info = static::prepareForArchiving($fileOrFiles, $archiveName); |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | $fileProgressCallable = null |
230 | 230 | ) |
231 | 231 | { |
232 | - $info = static::prepareForArchiving($fileOrFiles, '.' . Formats::getFormatExtension($archiveFormat)); |
|
232 | + $info = static::prepareForArchiving($fileOrFiles, '.'.Formats::getFormatExtension($archiveFormat)); |
|
233 | 233 | try { |
234 | 234 | $driver = static::getCreationDriver($archiveFormat, true, $password !== null); |
235 | 235 | } catch (UnsupportedArchiveException $e) { |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | protected static function getCreationDriver($archiveFormat, $inString, $encrypted) |
254 | 254 | { |
255 | 255 | if (!Formats::canCreate($archiveFormat)) { |
256 | - throw new UnsupportedArchiveException('Unsupported archive type: ' . $archiveFormat); |
|
256 | + throw new UnsupportedArchiveException('Unsupported archive type: '.$archiveFormat); |
|
257 | 257 | } |
258 | 258 | |
259 | 259 | $abilities = [Abilities::CREATE]; |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | |
264 | 264 | if ($encrypted) { |
265 | 265 | if (!Formats::canEncrypt($archiveFormat)) { |
266 | - throw new UnsupportedOperationException('Archive type ' . $archiveFormat . ' can not be encrypted'); |
|
266 | + throw new UnsupportedOperationException('Archive type '.$archiveFormat.' can not be encrypted'); |
|
267 | 267 | } |
268 | 268 | $abilities[] = Abilities::CREATE_ENCRYPTED; |
269 | 269 | } |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | /** @var BasicDriver $driver */ |
272 | 272 | $driver = Formats::getFormatDriver($archiveFormat, $abilities); |
273 | 273 | if ($driver === null) { |
274 | - throw new UnsupportedArchiveException('Unsupported archive type: ' . $archiveFormat . ' of archive '); |
|
274 | + throw new UnsupportedArchiveException('Unsupported archive type: '.$archiveFormat.' of archive '); |
|
275 | 275 | } |
276 | 276 | return $driver; |
277 | 277 | } |
@@ -294,10 +294,10 @@ discard block |
||
294 | 294 | $driver = Formats::getFormatDriver($format, $abilities); |
295 | 295 | if ($driver === null) { |
296 | 296 | throw new UnsupportedArchiveException( |
297 | - 'Format ' . $format . ' driver with abilities (' |
|
297 | + 'Format '.$format.' driver with abilities (' |
|
298 | 298 | . implode( |
299 | 299 | ', ', |
300 | - array_map(function ($ability) { |
|
300 | + array_map(function($ability) { |
|
301 | 301 | return array_search($ability, Abilities::$abilitiesLabels); |
302 | 302 | }, $abilities) |
303 | 303 | ) |
@@ -489,7 +489,7 @@ discard block |
||
489 | 489 | public function getFileData($fileName) |
490 | 490 | { |
491 | 491 | if (!in_array($fileName, $this->files, true)) { |
492 | - throw new NonExistentArchiveFileException('File ' . $fileName . ' does not exist in archive'); |
|
492 | + throw new NonExistentArchiveFileException('File '.$fileName.' does not exist in archive'); |
|
493 | 493 | } |
494 | 494 | |
495 | 495 | return $this->archive->getFileData($fileName); |
@@ -505,7 +505,7 @@ discard block |
||
505 | 505 | public function getFileContent($fileName) |
506 | 506 | { |
507 | 507 | if (!in_array($fileName, $this->files, true)) { |
508 | - throw new NonExistentArchiveFileException('File ' . $fileName . ' does not exist in archive'); |
|
508 | + throw new NonExistentArchiveFileException('File '.$fileName.' does not exist in archive'); |
|
509 | 509 | } |
510 | 510 | |
511 | 511 | return $this->archive->getFileContent($fileName); |
@@ -521,7 +521,7 @@ discard block |
||
521 | 521 | public function getFileStream($fileName) |
522 | 522 | { |
523 | 523 | if (!in_array($fileName, $this->files, true)) { |
524 | - throw new NonExistentArchiveFileException('File ' . $fileName . ' does not exist in archive'); |
|
524 | + throw new NonExistentArchiveFileException('File '.$fileName.' does not exist in archive'); |
|
525 | 525 | } |
526 | 526 | |
527 | 527 | return $this->archive->getFileStream($fileName); |
@@ -656,7 +656,7 @@ discard block |
||
656 | 656 | $newFiles = []; |
657 | 657 | foreach ($files as $file) { |
658 | 658 | foreach ($archiveFiles as $archiveFile) { |
659 | - if (fnmatch($file . '*', $archiveFile)) { |
|
659 | + if (fnmatch($file.'*', $archiveFile)) { |
|
660 | 660 | $newFiles[] = $archiveFile; |
661 | 661 | } |
662 | 662 | } |
@@ -689,8 +689,8 @@ discard block |
||
689 | 689 | if (is_array($source)) { |
690 | 690 | foreach ($source as $sourceItem) { |
691 | 691 | static::importFilesFromDir( |
692 | - rtrim($sourceItem, '/\\*') . '/*', |
|
693 | - !empty($destination) ? $destination . '/' : null, |
|
692 | + rtrim($sourceItem, '/\\*').'/*', |
|
693 | + !empty($destination) ? $destination.'/' : null, |
|
694 | 694 | true, |
695 | 695 | $files |
696 | 696 | ); |
@@ -698,8 +698,8 @@ discard block |
||
698 | 698 | } else if (is_dir($source)) { |
699 | 699 | // one source for directories |
700 | 700 | static::importFilesFromDir( |
701 | - rtrim($source, '/\\*') . '/*', |
|
702 | - !empty($destination) ? $destination . '/' : null, |
|
701 | + rtrim($source, '/\\*').'/*', |
|
702 | + !empty($destination) ? $destination.'/' : null, |
|
703 | 703 | true, |
704 | 704 | $files |
705 | 705 | ); |
@@ -711,9 +711,9 @@ discard block |
||
711 | 711 | } else if (is_string($nodes)) { // passed one file or directory |
712 | 712 | // if is directory |
713 | 713 | if (is_dir($nodes)) { |
714 | - $nodes = rtrim($nodes, '/\\*') . '/'; |
|
714 | + $nodes = rtrim($nodes, '/\\*').'/'; |
|
715 | 715 | static::importFilesFromDir( |
716 | - $nodes . '*', |
|
716 | + $nodes.'*', |
|
717 | 717 | $nodes, |
718 | 718 | true, |
719 | 719 | $files |
@@ -742,10 +742,10 @@ discard block |
||
742 | 742 | |
743 | 743 | foreach (glob($source, GLOB_MARK) as $node) { |
744 | 744 | if (in_array(substr($node, -1), ['/', '\\'], true) && $recursive) { |
745 | - static::importFilesFromDir(str_replace('\\', '/', $node) . '*', |
|
746 | - $destination . basename($node) . '/', $recursive, $map); |
|
745 | + static::importFilesFromDir(str_replace('\\', '/', $node).'*', |
|
746 | + $destination.basename($node).'/', $recursive, $map); |
|
747 | 747 | } elseif (is_file($node) && is_readable($node)) { |
748 | - $map[$destination . basename($node)] = $node; |
|
748 | + $map[$destination.basename($node)] = $node; |
|
749 | 749 | } |
750 | 750 | } |
751 | 751 | } |
@@ -964,7 +964,7 @@ discard block |
||
964 | 964 | public static function archiveFile($file, $archiveName, $compressionLevel = BasicDriver::COMPRESSION_AVERAGE, $password = null) |
965 | 965 | { |
966 | 966 | if (!is_file($file)) { |
967 | - throw new InvalidArgumentException($file . ' is not a valid file to archive'); |
|
967 | + throw new InvalidArgumentException($file.' is not a valid file to archive'); |
|
968 | 968 | } |
969 | 969 | |
970 | 970 | return static::create($file, $archiveName, $compressionLevel, $password) === 1; |
@@ -985,7 +985,7 @@ discard block |
||
985 | 985 | public static function archiveDirectory($directory, $archiveName, $compressionLevel = BasicDriver::COMPRESSION_AVERAGE, $password = null) |
986 | 986 | { |
987 | 987 | if (!is_dir($directory) || !is_readable($directory)) |
988 | - throw new InvalidArgumentException($directory . ' is not a valid directory to archive'); |
|
988 | + throw new InvalidArgumentException($directory.' is not a valid directory to archive'); |
|
989 | 989 | |
990 | 990 | return static::create($directory, $archiveName, $compressionLevel, $password) > 0; |
991 | 991 | } |
@@ -1147,7 +1147,7 @@ discard block |
||
1147 | 1147 | public function addFile($file, $inArchiveName = null) |
1148 | 1148 | { |
1149 | 1149 | if (!is_file($file)) |
1150 | - throw new InvalidArgumentException($file . ' is not a valid file to add in archive'); |
|
1150 | + throw new InvalidArgumentException($file.' is not a valid file to add in archive'); |
|
1151 | 1151 | |
1152 | 1152 | return ($inArchiveName !== null |
1153 | 1153 | ? $this->add([$inArchiveName => $file]) |
@@ -1168,7 +1168,7 @@ discard block |
||
1168 | 1168 | public function addDirectory($directory, $inArchivePath = null) |
1169 | 1169 | { |
1170 | 1170 | if (!is_dir($directory) || !is_readable($directory)) |
1171 | - throw new InvalidArgumentException($directory . ' is not a valid directory to add in archive'); |
|
1171 | + throw new InvalidArgumentException($directory.' is not a valid directory to add in archive'); |
|
1172 | 1172 | |
1173 | 1173 | return ($inArchivePath !== null |
1174 | 1174 | ? $this->add([$inArchivePath => $directory]) |