@@ -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,12 +106,14 @@ discard block |
||
| 104 | 106 | */ |
| 105 | 107 | public static function getInstallationInstruction() |
| 106 | 108 | { |
| 107 | - if (!class_exists('\Archive7z\Archive7z')) |
|
| 108 | - return 'install library [gemorroj/archive7z]: `composer require gemorroj/archive7z`' . "\n" |
|
| 109 | + if (!class_exists('\Archive7z\Archive7z')) { |
|
| 110 | + return 'install library [gemorroj/archive7z]: `composer require gemorroj/archive7z`' . "\n" |
|
| 109 | 111 | . ' and console program p7zip [7za]: `apt install p7zip-full` - depends on OS'; |
| 112 | + } |
|
| 110 | 113 | |
| 111 | - if (Archive7z::getBinaryVersion() === false) |
|
| 112 | - return 'install console program p7zip [7za]: `apt install p7zip-full` - depends on OS'; |
|
| 114 | + if (Archive7z::getBinaryVersion() === false) { |
|
| 115 | + return 'install console program p7zip [7za]: `apt install p7zip-full` - depends on OS'; |
|
| 116 | + } |
|
| 113 | 117 | |
| 114 | 118 | return null; |
| 115 | 119 | } |
@@ -122,8 +126,9 @@ discard block |
||
| 122 | 126 | try { |
| 123 | 127 | $this->format = $format; |
| 124 | 128 | $this->sevenZip = new Archive7z($archiveFileName, null, null); |
| 125 | - if ($password !== null) |
|
| 126 | - $this->sevenZip->setPassword($password); |
|
| 129 | + if ($password !== null) { |
|
| 130 | + $this->sevenZip->setPassword($password); |
|
| 131 | + } |
|
| 127 | 132 | } catch (\Archive7z\Exception $e) { |
| 128 | 133 | throw new Exception('Could not open 7Zip archive: '.$e->getMessage(), $e->getCode(), $e); |
| 129 | 134 | } |
@@ -141,8 +146,9 @@ discard block |
||
| 141 | 146 | continue; |
| 142 | 147 | } |
| 143 | 148 | |
| 144 | - if (!isset($can_get_unix_path)) |
|
| 145 | - $can_get_unix_path = method_exists($entry, 'getUnixPath'); |
|
| 149 | + if (!isset($can_get_unix_path)) { |
|
| 150 | + $can_get_unix_path = method_exists($entry, 'getUnixPath'); |
|
| 151 | + } |
|
| 146 | 152 | |
| 147 | 153 | $information->files[] = $can_get_unix_path |
| 148 | 154 | ? $entry->getUnixPath() |
@@ -160,8 +166,9 @@ discard block |
||
| 160 | 166 | { |
| 161 | 167 | $files = []; |
| 162 | 168 | foreach ($this->sevenZip->getEntries() as $entry) { |
| 163 | - if ($entry->isDirectory()) |
|
| 164 | - continue; |
|
| 169 | + if ($entry->isDirectory()) { |
|
| 170 | + continue; |
|
| 171 | + } |
|
| 165 | 172 | $files[] = $entry->getPath(); |
| 166 | 173 | } |
| 167 | 174 | return $files; |
@@ -302,8 +309,9 @@ discard block |
||
| 302 | 309 | public function addFileFromString($inArchiveName, $content) |
| 303 | 310 | { |
| 304 | 311 | $tmp_file = tempnam(sys_get_temp_dir(), 'ua'); |
| 305 | - if (!$tmp_file) |
|
| 306 | - throw new ArchiveModificationException('Could not create temporarily file'); |
|
| 312 | + if (!$tmp_file) { |
|
| 313 | + throw new ArchiveModificationException('Could not create temporarily file'); |
|
| 314 | + } |
|
| 307 | 315 | |
| 308 | 316 | file_put_contents($tmp_file, $content); |
| 309 | 317 | $this->sevenZip->addEntry($tmp_file, true); |
@@ -353,8 +361,9 @@ discard block |
||
| 353 | 361 | $total_files = count($files); |
| 354 | 362 | |
| 355 | 363 | $seven_zip = new Archive7z($archiveFileName); |
| 356 | - if ($password !== null) |
|
| 357 | - $seven_zip->setPassword($password); |
|
| 364 | + if ($password !== null) { |
|
| 365 | + $seven_zip->setPassword($password); |
|
| 366 | + } |
|
| 358 | 367 | $seven_zip->setCompressionLevel($compressionLevelMap[$compressionLevel]); |
| 359 | 368 | foreach ($files as $localName => $filename) { |
| 360 | 369 | if ($filename !== null) { |
@@ -386,8 +395,9 @@ discard block |
||
| 386 | 395 | Formats::TAR, |
| 387 | 396 | Formats::LZMA, |
| 388 | 397 | Formats::ZIP] |
| 389 | - )) |
|
| 390 | - return self::canRenameFiles(); |
|
| 398 | + )) { |
|
| 399 | + return self::canRenameFiles(); |
|
| 400 | + } |
|
| 391 | 401 | |
| 392 | 402 | return false; |
| 393 | 403 | } |