@@ -141,11 +141,13 @@ discard block |
||
| 141 | 141 | { |
| 142 | 142 | static::checkRequirements(); |
| 143 | 143 | |
| 144 | - if (static::$enabledPharData) |
|
| 145 | - return static::createArchiveForPhar($files, $archiveFileName); |
|
| 144 | + if (static::$enabledPharData) { |
|
| 145 | + return static::createArchiveForPhar($files, $archiveFileName); |
|
| 146 | + } |
|
| 146 | 147 | |
| 147 | - if (static::$enabledPearTar) |
|
| 148 | - return static::createArchiveForPear($files, $archiveFileName); |
|
| 148 | + if (static::$enabledPearTar) { |
|
| 149 | + return static::createArchiveForPear($files, $archiveFileName); |
|
| 150 | + } |
|
| 149 | 151 | |
| 150 | 152 | throw new Exception('Archive_Tar nor PharData not available'); |
| 151 | 153 | } |
@@ -177,21 +179,24 @@ discard block |
||
| 177 | 179 | break; |
| 178 | 180 | } |
| 179 | 181 | |
| 180 | - if (isset($tar_aname)) |
|
| 181 | - $tar = new Archive_Tar($tar_aname, $compression); |
|
| 182 | - else |
|
| 183 | - $tar = new Archive_Tar($archiveFileName, $compression); |
|
| 182 | + if (isset($tar_aname)) { |
|
| 183 | + $tar = new Archive_Tar($tar_aname, $compression); |
|
| 184 | + } else { |
|
| 185 | + $tar = new Archive_Tar($archiveFileName, $compression); |
|
| 186 | + } |
|
| 184 | 187 | |
| 185 | 188 | foreach ($files as $localName => $filename) { |
| 186 | 189 | $remove_dir = dirname($filename); |
| 187 | 190 | $add_dir = dirname($localName); |
| 188 | 191 | |
| 189 | 192 | if (is_null($filename)) { |
| 190 | - if ($tar->addString($localName, '') === false) |
|
| 191 | - throw new Exception('Error when adding directory '.$localName.' to archive'); |
|
| 193 | + if ($tar->addString($localName, '') === false) { |
|
| 194 | + throw new Exception('Error when adding directory '.$localName.' to archive'); |
|
| 195 | + } |
|
| 192 | 196 | } else { |
| 193 | - if ($tar->addModify($filename, $add_dir, $remove_dir) === false) |
|
| 194 | - throw new Exception('Error when adding file '.$filename.' to archive'); |
|
| 197 | + if ($tar->addModify($filename, $add_dir, $remove_dir) === false) { |
|
| 198 | + throw new Exception('Error when adding file '.$filename.' to archive'); |
|
| 199 | + } |
|
| 195 | 200 | } |
| 196 | 201 | } |
| 197 | 202 | $tar = null; |
@@ -279,8 +284,9 @@ discard block |
||
| 279 | 284 | |
| 280 | 285 | $this->archiveFileName = realpath($archiveFileName); |
| 281 | 286 | $this->archiveType = static::detectArchiveType($this->archiveFileName); |
| 282 | - if ($this->archiveType === false) |
|
| 283 | - throw new \Exception('Could not detect type for archive '.$this->archiveFileName); |
|
| 287 | + if ($this->archiveType === false) { |
|
| 288 | + throw new \Exception('Could not detect type for archive '.$this->archiveFileName); |
|
| 289 | + } |
|
| 284 | 290 | $this->open($this->archiveType); |
| 285 | 291 | } |
| 286 | 292 | |
@@ -392,8 +398,9 @@ discard block |
||
| 392 | 398 | */ |
| 393 | 399 | public function isFileExists($fileName) |
| 394 | 400 | { |
| 395 | - if ($this->tar instanceof Archive_Tar) |
|
| 396 | - return isset($this->pearFilesIndex[$fileName]); |
|
| 401 | + if ($this->tar instanceof Archive_Tar) { |
|
| 402 | + return isset($this->pearFilesIndex[$fileName]); |
|
| 403 | + } |
|
| 397 | 404 | |
| 398 | 405 | try { |
| 399 | 406 | $this->tar->offsetGet($fileName); |
@@ -411,14 +418,16 @@ discard block |
||
| 411 | 418 | public function getFileData($fileName) |
| 412 | 419 | { |
| 413 | 420 | if ($this->tar instanceof Archive_Tar) { |
| 414 | - if (!isset($this->pearFilesIndex[$fileName])) |
|
| 415 | - throw new Exception('File '.$fileName.' is not found in archive files list'); |
|
| 421 | + if (!isset($this->pearFilesIndex[$fileName])) { |
|
| 422 | + throw new Exception('File '.$fileName.' is not found in archive files list'); |
|
| 423 | + } |
|
| 416 | 424 | |
| 417 | 425 | $index = $this->pearFilesIndex[$fileName]; |
| 418 | 426 | |
| 419 | 427 | $files_list = $this->tar->listContent(); |
| 420 | - if (!isset($files_list[$index])) |
|
| 421 | - throw new Exception('File '.$fileName.' is not found in Tar archive'); |
|
| 428 | + if (!isset($files_list[$index])) { |
|
| 429 | + throw new Exception('File '.$fileName.' is not found in Tar archive'); |
|
| 430 | + } |
|
| 422 | 431 | |
| 423 | 432 | $data = $files_list[$index]; |
| 424 | 433 | unset($files_list); |
@@ -442,8 +451,9 @@ discard block |
||
| 442 | 451 | public function getFileContent($fileName) |
| 443 | 452 | { |
| 444 | 453 | if ($this->tar instanceof Archive_Tar) { |
| 445 | - if (!isset($this->pearFilesIndex[$fileName])) |
|
| 446 | - throw new Exception('File '.$fileName.' is not found in archive files list'); |
|
| 454 | + if (!isset($this->pearFilesIndex[$fileName])) { |
|
| 455 | + throw new Exception('File '.$fileName.' is not found in archive files list'); |
|
| 456 | + } |
|
| 447 | 457 | |
| 448 | 458 | return $this->tar->extractInString($fileName); |
| 449 | 459 | } |
@@ -460,12 +470,14 @@ discard block |
||
| 460 | 470 | { |
| 461 | 471 | $resource = fopen('php://temp', 'r+'); |
| 462 | 472 | if ($this->tar instanceof Archive_Tar) { |
| 463 | - if (!isset($this->pearFilesIndex[$fileName])) |
|
| 464 | - throw new Exception('File '.$fileName.' is not found in archive files list'); |
|
| 473 | + if (!isset($this->pearFilesIndex[$fileName])) { |
|
| 474 | + throw new Exception('File '.$fileName.' is not found in archive files list'); |
|
| 475 | + } |
|
| 465 | 476 | |
| 466 | 477 | fwrite($resource, $this->tar->extractInString($fileName)); |
| 467 | - } else |
|
| 468 | - fwrite($resource, $this->tar->offsetGet($fileName)->getContent()); |
|
| 478 | + } else { |
|
| 479 | + fwrite($resource, $this->tar->offsetGet($fileName)->getContent()); |
|
| 480 | + } |
|
| 469 | 481 | |
| 470 | 482 | rewind($resource); |
| 471 | 483 | return $resource; |
@@ -520,14 +532,16 @@ discard block |
||
| 520 | 532 | */ |
| 521 | 533 | public function deleteFiles(array $files) |
| 522 | 534 | { |
| 523 | - if ($this->tar instanceof Archive_Tar) |
|
| 524 | - throw new UnsupportedOperationException(); |
|
| 535 | + if ($this->tar instanceof Archive_Tar) { |
|
| 536 | + throw new UnsupportedOperationException(); |
|
| 537 | + } |
|
| 525 | 538 | |
| 526 | 539 | $deleted = 0; |
| 527 | 540 | |
| 528 | 541 | foreach ($files as $i => $file) { |
| 529 | - if ($this->tar->delete($file)) |
|
| 530 | - $deleted++; |
|
| 542 | + if ($this->tar->delete($file)) { |
|
| 543 | + $deleted++; |
|
| 544 | + } |
|
| 531 | 545 | } |
| 532 | 546 | |
| 533 | 547 | $this->tar = null; |
@@ -550,11 +564,13 @@ discard block |
||
| 550 | 564 | $remove_dir = dirname($filename); |
| 551 | 565 | $add_dir = dirname($localName); |
| 552 | 566 | if (is_null($filename)) { |
| 553 | - if ($this->tar->addString($localName, "") === false) |
|
| 554 | - return false; |
|
| 567 | + if ($this->tar->addString($localName, "") === false) { |
|
| 568 | + return false; |
|
| 569 | + } |
|
| 555 | 570 | } else { |
| 556 | - if ($this->tar->addModify($filename, $add_dir, $remove_dir) === false) |
|
| 557 | - return false; |
|
| 571 | + if ($this->tar->addModify($filename, $add_dir, $remove_dir) === false) { |
|
| 572 | + return false; |
|
| 573 | + } |
|
| 558 | 574 | $added++; |
| 559 | 575 | } |
| 560 | 576 | } |