@@ -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 | /** |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | */ |
| 22 | 22 | public static function getDescription() |
| 23 | 23 | { |
| 24 | - return 'adapter for ext-rar' . (self::isInstalled() ? ' (' . phpversion('rar') . ')' : null); |
|
| 24 | + return 'adapter for ext-rar'.(self::isInstalled() ? ' ('.phpversion('rar').')' : null); |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | /** |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | */ |
| 30 | 30 | public static function getInstallationInstruction() |
| 31 | 31 | { |
| 32 | - return 'install [rar] extension.' . "\n" . 'Can be installed with pecl: `pecl install rar`'; |
|
| 32 | + return 'install [rar] extension.'."\n".'Can be installed with pecl: `pecl install rar`'; |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | /** |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | */ |
| 81 | 81 | protected function open($archiveFileName, $password) |
| 82 | 82 | { |
| 83 | - $this->rar = \RarArchive::open($archiveFileName, $password, function ($vol) { |
|
| 83 | + $this->rar = \RarArchive::open($archiveFileName, $password, function($vol) { |
|
| 84 | 84 | var_dump($vol); |
| 85 | 85 | return null; |
| 86 | 86 | }); |
@@ -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) { |
@@ -29,7 +29,7 @@ |
||
| 29 | 29 | */ |
| 30 | 30 | public static function getInstallationInstruction() |
| 31 | 31 | { |
| 32 | - return 'install [' . static::EXTENSION_NAME . '] extension' . "\n" . 'For 5.x: https://github.com/payden/php-xz' . "\n" . 'For 7.x/8.x: https://github.com/codemasher/php-ext-xz'; |
|
| 32 | + return 'install ['.static::EXTENSION_NAME.'] extension'."\n".'For 5.x: https://github.com/payden/php-xz'."\n".'For 7.x/8.x: https://github.com/codemasher/php-ext-xz'; |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | /** |
@@ -50,10 +50,10 @@ |
||
| 50 | 50 | { |
| 51 | 51 | $suffix = Formats::getFormatExtension(static::FORMAT); |
| 52 | 52 | if ($suffix === null) { |
| 53 | - throw new \Exception('Format suffix is empty for ' . static::FORMAT . ', it should be initialized!'); |
|
| 53 | + throw new \Exception('Format suffix is empty for '.static::FORMAT.', it should be initialized!'); |
|
| 54 | 54 | } |
| 55 | 55 | if ($password !== null) { |
| 56 | - throw new UnsupportedOperationException($suffix . ' archive does not support password!'); |
|
| 56 | + throw new UnsupportedOperationException($suffix.' archive does not support password!'); |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | parent::__construct($archiveFileName, $format); |
@@ -122,8 +122,9 @@ |
||
| 122 | 122 | public function extractArchive($outputFolder) |
| 123 | 123 | { |
| 124 | 124 | $data = $this->getFileContent($this->inArchiveFileName); |
| 125 | - if ($data === false) |
|
| 126 | - throw new ArchiveExtractionException('Could not extract archive'); |
|
| 125 | + if ($data === false) { |
|
| 126 | + throw new ArchiveExtractionException('Could not extract archive'); |
|
| 127 | + } |
|
| 127 | 128 | |
| 128 | 129 | $size = strlen($data); |
| 129 | 130 | $written = file_put_contents($outputFolder.$this->inArchiveFileName, $data); |
@@ -15,6 +15,6 @@ |
||
| 15 | 15 | |
| 16 | 16 | public static function getInstallationInstruction() |
| 17 | 17 | { |
| 18 | - return 'install [' . static::EXTENSION_NAME . '] php extension'; |
|
| 18 | + return 'install ['.static::EXTENSION_NAME.'] php extension'; |
|
| 19 | 19 | } |
| 20 | 20 | } |
@@ -15,6 +15,6 @@ |
||
| 15 | 15 | |
| 16 | 16 | public static function getInstallationInstruction() |
| 17 | 17 | { |
| 18 | - return 'install library [ ' . static::PACKAGE_NAME . ']: `composer require ' . static::PACKAGE_NAME . '`'; |
|
| 18 | + return 'install library [ '.static::PACKAGE_NAME.']: `composer require '.static::PACKAGE_NAME.'`'; |
|
| 19 | 19 | } |
| 20 | 20 | } |