Passed
Push — 0.1.x ( 073687...336e3c )
by f
01:46
created
src/Formats/Tar.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
                 $compression = 'lzma2';
173 173
                 break;
174 174
             case 'z':
175
-                $tar_aname = 'compress.lzw://' . $archiveFileName;
175
+                $tar_aname = 'compress.lzw://'.$archiveFileName;
176 176
                 break;
177 177
         }
178 178
 
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
                 }
328 328
 
329 329
                 LzwStreamWrapper::registerWrapper();
330
-                $this->tar = new Archive_Tar('compress.lzw://' . $this->archiveFileName);
330
+                $this->tar = new Archive_Tar('compress.lzw://'.$this->archiveFileName);
331 331
                 break;
332 332
 
333 333
             default:
Please login to merge, or discard this patch.
Braces   +50 added lines, -34 removed lines patch added patch discarded remove patch
@@ -141,11 +141,13 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
             }
Please login to merge, or discard this patch.
src/Formats/Gzip.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@
 block discarded – undo
15 15
     {
16 16
         $fp = fopen($file, 'rb');
17 17
         if (filesize($file) < 18 || strcmp(fread($fp, 2), "\x1f\x8b")) {
18
-            return false;  // Not GZIP format (See RFC 1952)
18
+            return false; // Not GZIP format (See RFC 1952)
19 19
         }
20 20
         $method = fread($fp, 1);
21 21
         $flags = fread($fp, 1);
Please login to merge, or discard this patch.
src/PclzipZipInterface.php 2 patches
Spacing   +37 added lines, -38 removed lines patch added patch discarded remove patch
@@ -147,8 +147,8 @@  discard block
 block discarded – undo
147 147
             }
148 148
         } else {
149 149
             $options = array_combine(
150
-                array_filter($options, function ($v) {return (bool) $v&2;}),
151
-                array_filter($options, function ($v) {return (bool) ($v-1)&2;})
150
+                array_filter($options, function($v) {return (bool) $v & 2; }),
151
+                array_filter($options, function($v) {return (bool) ($v - 1) & 2; })
152 152
             );
153 153
         }
154 154
 
@@ -156,12 +156,12 @@  discard block
 block discarded – undo
156 156
         $filters = array();
157 157
         if (isset($options[PCLZIP_OPT_REMOVE_PATH])
158 158
             && !isset($options[PCLZIP_OPT_REMOVE_ALL_PATH]))
159
-            $filters[] = function (&$key, &$value) use ($options) {
159
+            $filters[] = function(&$key, &$value) use ($options) {
160 160
                 $key = str_replace($key, null, $key); };
161 161
         if (isset($options[PCLZIP_OPT_REMOVE_ALL_PATH]))
162
-            $filters[] = function (&$key, &$value) { $key = basename($key); };
162
+            $filters[] = function(&$key, &$value) { $key = basename($key); };
163 163
         if (isset($options[PCLZIP_OPT_ADD_PATH]))
164
-            $filters[] = function (&$key, &$value) use ($options) {
164
+            $filters[] = function(&$key, &$value) use ($options) {
165 165
                 $key = rtrim($options[PCLZIP_OPT_ADD_PATH], '/').'/'.
166 166
                     ltrim($key, '/');
167 167
             };
@@ -169,12 +169,12 @@  discard block
 block discarded – undo
169 169
         if (isset($options[PCLZIP_CB_PRE_ADD])
170 170
             && is_callable($options[PCLZIP_CB_PRE_ADD]))
171 171
             $preAddCallback = $options[PCLZIP_CB_PRE_ADD];
172
-        else $preAddCallback = function () { return 1; };
172
+        else $preAddCallback = function() { return 1; };
173 173
 
174 174
         if (isset($options[PCLZIP_CB_POST_ADD])
175 175
             && is_callable($options[PCLZIP_CB_POST_ADD]))
176 176
             $postAddCallback = $options[PCLZIP_CB_POST_ADD];
177
-        else $postAddCallback = function () { return 1; };
177
+        else $postAddCallback = function() { return 1; };
178 178
 
179 179
         if (isset($options[PCLZIP_OPT_COMMENT]))
180 180
             $this->archive->setArchiveComment($options[PCLZIP_OPT_COMMENT]);
@@ -248,8 +248,7 @@  discard block
 block discarded – undo
248 248
                 'size' => $statIndex['size'],
249 249
                 'compressed_size' => $statIndex['comp_size'],
250 250
                 'mtime' => $statIndex,
251
-                'comment' => ($comment = $this->archive->getCommentIndex
252
-                    ($statIndex['index']) !== false) ? $comment : null,
251
+                'comment' => ($comment = $this->archive->getCommentIndex($statIndex['index']) !== false) ? $comment : null,
253 252
                 'folder' => in_array(substr($statIndex['name'], -1),
254 253
                     array('/', '\\')),
255 254
                 'index' => $statIndex['index'],
@@ -279,8 +278,8 @@  discard block
 block discarded – undo
279 278
             }
280 279
         } else {
281 280
             $options = array_combine(
282
-                array_filter($options, function ($v) {return (bool) $v&2;}),
283
-                array_filter($options, function ($v) {return (bool) ($v-1)&2;})
281
+                array_filter($options, function($v) {return (bool) $v & 2; }),
282
+                array_filter($options, function($v) {return (bool) ($v - 1) & 2; })
284 283
             );
285 284
         }
286 285
 
@@ -292,13 +291,13 @@  discard block
 block discarded – undo
292 291
         $filters = array();
293 292
         if (isset($options[PCLZIP_OPT_REMOVE_PATH])
294 293
             && !isset($options[PCLZIP_OPT_REMOVE_ALL_PATH]))
295
-            $filters[] = function (&$key, &$value) use ($options) {
294
+            $filters[] = function(&$key, &$value) use ($options) {
296 295
                 $key = str_replace($key, null, $key);
297 296
             };
298 297
         if (isset($options[PCLZIP_OPT_REMOVE_ALL_PATH]))
299
-            $filters[] = function (&$key, &$value) { $key = basename($key); };
298
+            $filters[] = function(&$key, &$value) { $key = basename($key); };
300 299
         if (isset($options[PCLZIP_OPT_ADD_PATH]))
301
-            $filters[] = function (&$key, &$value) use ($options) {
300
+            $filters[] = function(&$key, &$value) use ($options) {
302 301
                 $key = rtrim($options[PCLZIP_OPT_ADD_PATH], '/').'/'.
303 302
                     ltrim($key, '/');
304 303
             };
@@ -306,16 +305,16 @@  discard block
 block discarded – undo
306 305
         if (isset($options[PCLZIP_CB_PRE_EXTRACT])
307 306
             && is_callable($options[PCLZIP_CB_PRE_EXTRACT]))
308 307
             $preExtractCallback = $options[PCLZIP_CB_PRE_EXTRACT];
309
-        else $preExtractCallback = function () { return 1; };
308
+        else $preExtractCallback = function() { return 1; };
310 309
 
311 310
         if (isset($options[PCLZIP_CB_POST_EXTRACT])
312 311
             && is_callable($options[PCLZIP_CB_POST_EXTRACT]))
313 312
             $postExtractCallback = $options[PCLZIP_CB_POST_EXTRACT];
314
-        else $postExtractCallback = function () { return 1; };
313
+        else $postExtractCallback = function() { return 1; };
315 314
 
316 315
         // exact matching
317 316
         if (isset($options[PCLZIP_OPT_BY_NAME]))
318
-            $selectFilter = function ($key, $value) use ($options) {
317
+            $selectFilter = function($key, $value) use ($options) {
319 318
                 $allowedNames = is_array($options[PCLZIP_OPT_BY_NAME])
320 319
                     ? $options[PCLZIP_OPT_BY_NAME]
321 320
                     : explode(',', $options[PCLZIP_OPT_BY_NAME]);
@@ -340,21 +339,21 @@  discard block
 block discarded – undo
340 339
             };
341 340
         // <ereg> rule
342 341
         else if (isset($options[PCLZIP_OPT_BY_EREG]) && function_exists('ereg'))
343
-            $selectFilter = function ($key, $value) use ($options) {
342
+            $selectFilter = function($key, $value) use ($options) {
344 343
                 return (ereg($options[PCLZIP_OPT_BY_EREG], $key) !== false)
345 344
                     ? self::SELECT_FILTER_PASS
346 345
                     : self::SELECT_FILTER_REFUSE;
347 346
             };
348 347
         // <preg_match> rule
349 348
         else if (isset($options[PCLZIP_OPT_BY_PREG]))
350
-            $selectFilter = function ($key, $value) use ($options) {
349
+            $selectFilter = function($key, $value) use ($options) {
351 350
                 return preg_match($options[PCLZIP_OPT_BY_PREG], $key)
352 351
                     ? self::SELECT_FILTER_PASS
353 352
                     : self::SELECT_FILTER_REFUSE;
354 353
             };
355 354
         // index rule
356 355
         else if (isset($options[PCLZIP_OPT_BY_INDEX]))
357
-            $selectFilter = function ($key, $value, $index) use ($options) {
356
+            $selectFilter = function($key, $value, $index) use ($options) {
358 357
                 $allowedIndexes = array();
359 358
                 foreach ($options[PCLZIP_OPT_BY_INDEX] as $rule) {
360 359
                     $parts = explode('-', $rule);
@@ -368,7 +367,7 @@  discard block
 block discarded – undo
368 367
             };
369 368
         // no rule
370 369
         else
371
-            $selectFilter = function () { return self::SELECT_FILTER_PASS; };
370
+            $selectFilter = function() { return self::SELECT_FILTER_PASS; };
372 371
 
373 372
         if (isset($options[PCLZIP_OPT_EXTRACT_AS_STRING]))
374 373
             $anotherOutputFormat = PCLZIP_OPT_EXTRACT_AS_STRING;
@@ -560,8 +559,8 @@  discard block
 block discarded – undo
560 559
             }
561 560
         } else {
562 561
             $options = array_combine(
563
-                array_filter($options, function ($v) {return (bool) $v&2;}),
564
-                array_filter($options, function ($v) {return (bool) ($v-1)&2;})
562
+                array_filter($options, function($v) {return (bool) $v & 2; }),
563
+                array_filter($options, function($v) {return (bool) ($v - 1) & 2; })
565 564
             );
566 565
         }
567 566
 
@@ -569,13 +568,13 @@  discard block
 block discarded – undo
569 568
         $filters = array();
570 569
         if (isset($options[PCLZIP_OPT_REMOVE_PATH])
571 570
             && !isset($options[PCLZIP_OPT_REMOVE_ALL_PATH]))
572
-            $filters[] = function (&$key, &$value) use ($options) {
571
+            $filters[] = function(&$key, &$value) use ($options) {
573 572
                 $key = str_replace($key, null, $key);
574 573
             };
575 574
         if (isset($options[PCLZIP_OPT_REMOVE_ALL_PATH]))
576
-            $filters[] = function (&$key, &$value) { $key = basename($key); };
575
+            $filters[] = function(&$key, &$value) { $key = basename($key); };
577 576
         if (isset($options[PCLZIP_OPT_ADD_PATH]))
578
-            $filters[] = function (&$key, &$value) use ($options) {
577
+            $filters[] = function(&$key, &$value) use ($options) {
579 578
                 $key = rtrim($options[PCLZIP_OPT_ADD_PATH], '/').'/'.
580 579
                     ltrim($key, '/');
581 580
             };
@@ -583,12 +582,12 @@  discard block
 block discarded – undo
583 582
         if (isset($options[PCLZIP_CB_PRE_ADD])
584 583
             && is_callable($options[PCLZIP_CB_PRE_ADD]))
585 584
             $preAddCallback = $options[PCLZIP_CB_PRE_ADD];
586
-        else $preAddCallback = function () { return 1; };
585
+        else $preAddCallback = function() { return 1; };
587 586
 
588 587
         if (isset($options[PCLZIP_CB_POST_ADD])
589 588
             && is_callable($options[PCLZIP_CB_POST_ADD]))
590 589
             $postAddCallback = $options[PCLZIP_CB_POST_ADD];
591
-        else $postAddCallback = function () { return 1; };
590
+        else $postAddCallback = function() { return 1; };
592 591
 
593 592
         if (isset($options[PCLZIP_OPT_COMMENT]))
594 593
             $this->archive->setArchiveComment($options[PCLZIP_OPT_COMMENT]);
@@ -597,14 +596,14 @@  discard block
 block discarded – undo
597 596
                 ($comment = $this->archive->getArchiveComment() !== false)
598 597
                     ? $comment : null;
599 598
             $this->archive->setArchiveComment(
600
-                $comment . $options[PCLZIP_OPT_ADD_COMMENT]);
599
+                $comment.$options[PCLZIP_OPT_ADD_COMMENT]);
601 600
         }
602 601
         if (isset($options[PCLZIP_OPT_PREPEND_COMMENT])) {
603 602
             $comment =
604 603
                 ($comment = $this->archive->getArchiveComment() !== false)
605 604
                     ? $comment : null;
606 605
             $this->archive->setArchiveComment(
607
-                $options[PCLZIP_OPT_PREPEND_COMMENT] . $comment);
606
+                $options[PCLZIP_OPT_PREPEND_COMMENT].$comment);
608 607
         }
609 608
 
610 609
 
@@ -640,13 +639,13 @@  discard block
 block discarded – undo
640 639
         $report = array();
641 640
         $options = func_get_args();
642 641
         $options = array_combine(
643
-            array_filter($options, function ($v) {return (bool) $v&2;}),
644
-            array_filter($options, function ($v) {return (bool) ($v-1)&2;})
642
+            array_filter($options, function($v) {return (bool) $v & 2; }),
643
+            array_filter($options, function($v) {return (bool) ($v - 1) & 2; })
645 644
         );
646 645
 
647 646
         // exact matching
648 647
         if (isset($options[PCLZIP_OPT_BY_NAME]))
649
-            $selectFilter = function ($key, $value) use ($options) {
648
+            $selectFilter = function($key, $value) use ($options) {
650 649
                 $allowedNames = is_array($options[PCLZIP_OPT_BY_NAME])
651 650
                     ? $options[PCLZIP_OPT_BY_NAME]
652 651
                     : explode(',', $options[PCLZIP_OPT_BY_NAME]);
@@ -671,21 +670,21 @@  discard block
 block discarded – undo
671 670
             };
672 671
         // <ereg> rule
673 672
         else if (isset($options[PCLZIP_OPT_BY_EREG]) && function_exists('ereg'))
674
-            $selectFilter = function ($key, $value) use ($options) {
673
+            $selectFilter = function($key, $value) use ($options) {
675 674
                 return (ereg($options[PCLZIP_OPT_BY_EREG], $key) !== false)
676 675
                     ? self::SELECT_FILTER_PASS
677 676
                     : self::SELECT_FILTER_REFUSE;
678 677
             };
679 678
         // <preg_match> rule
680 679
         else if (isset($options[PCLZIP_OPT_BY_PREG]))
681
-            $selectFilter = function ($key, $value) use ($options) {
680
+            $selectFilter = function($key, $value) use ($options) {
682 681
                 return preg_match($options[PCLZIP_OPT_BY_PREG], $key)
683 682
                     ? self::SELECT_FILTER_PASS
684 683
                     : self::SELECT_FILTER_REFUSE;
685 684
             };
686 685
         // index rule
687 686
         else if (isset($options[PCLZIP_OPT_BY_INDEX]))
688
-            $selectFilter = function ($key, $value, $index) use ($options) {
687
+            $selectFilter = function($key, $value, $index) use ($options) {
689 688
                 $allowedIndexes = array();
690 689
                 foreach ($options[PCLZIP_OPT_BY_INDEX] as $rule) {
691 690
                     $parts = explode('-', $rule);
@@ -700,7 +699,7 @@  discard block
 block discarded – undo
700 699
             };
701 700
         // no rule
702 701
         else
703
-            $selectFilter = function () { return self::SELECT_FILTER_PASS; };
702
+            $selectFilter = function() { return self::SELECT_FILTER_PASS; };
704 703
 
705 704
         foreach ($this->listContent() as $file_header) {
706 705
             // select by select rule
@@ -780,7 +779,7 @@  discard block
 block discarded – undo
780 779
             }
781 780
         }
782 781
 
783
-        call_user_func(function ($directory) {
782
+        call_user_func(function($directory) {
784 783
             foreach (glob($directory.'/*') as $f) {
785 784
                 if (is_dir($f)) call_user_func(__FUNCTION__, $f);
786 785
                 else unlink($f);
Please login to merge, or discard this patch.
Braces   +173 added lines, -96 removed lines patch added patch discarded remove patch
@@ -132,8 +132,11 @@  discard block
 block discarded – undo
132 132
      */
133 133
     public function create($content)
134 134
     {
135
-        if (is_array($content)) $paths_list = $content;
136
-        else $paths_list = explode(',', $content);
135
+        if (is_array($content)) {
136
+         $paths_list = $content;
137
+        } else {
138
+         $paths_list = explode(',', $content);
139
+        }
137 140
         $report = array();
138 141
 
139 142
         $options = func_get_args();
@@ -155,29 +158,41 @@  discard block
 block discarded – undo
155 158
         // filters initiation
156 159
         $filters = array();
157 160
         if (isset($options[PCLZIP_OPT_REMOVE_PATH])
158
-            && !isset($options[PCLZIP_OPT_REMOVE_ALL_PATH]))
159
-            $filters[] = function (&$key, &$value) use ($options) {
160
-                $key = str_replace($key, null, $key); };
161
-        if (isset($options[PCLZIP_OPT_REMOVE_ALL_PATH]))
162
-            $filters[] = function (&$key, &$value) { $key = basename($key); };
163
-        if (isset($options[PCLZIP_OPT_ADD_PATH]))
164
-            $filters[] = function (&$key, &$value) use ($options) {
161
+            && !isset($options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
162
+                    $filters[] = function (&$key, &$value) use ($options) {
163
+                $key = str_replace($key, null, $key);
164
+        }
165
+        };
166
+        if (isset($options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
167
+                    $filters[] = function (&$key, &$value) { $key = basename($key);
168
+        }
169
+        };
170
+        if (isset($options[PCLZIP_OPT_ADD_PATH])) {
171
+                    $filters[] = function (&$key, &$value) use ($options) {
165 172
                 $key = rtrim($options[PCLZIP_OPT_ADD_PATH], '/').'/'.
166 173
                     ltrim($key, '/');
174
+        }
167 175
             };
168 176
 
169 177
         if (isset($options[PCLZIP_CB_PRE_ADD])
170
-            && is_callable($options[PCLZIP_CB_PRE_ADD]))
171
-            $preAddCallback = $options[PCLZIP_CB_PRE_ADD];
172
-        else $preAddCallback = function () { return 1; };
178
+            && is_callable($options[PCLZIP_CB_PRE_ADD])) {
179
+                    $preAddCallback = $options[PCLZIP_CB_PRE_ADD];
180
+        } else {
181
+         $preAddCallback = function () { return 1;
182
+        }
183
+        };
173 184
 
174 185
         if (isset($options[PCLZIP_CB_POST_ADD])
175
-            && is_callable($options[PCLZIP_CB_POST_ADD]))
176
-            $postAddCallback = $options[PCLZIP_CB_POST_ADD];
177
-        else $postAddCallback = function () { return 1; };
186
+            && is_callable($options[PCLZIP_CB_POST_ADD])) {
187
+                    $postAddCallback = $options[PCLZIP_CB_POST_ADD];
188
+        } else {
189
+         $postAddCallback = function () { return 1;
190
+        }
191
+        };
178 192
 
179
-        if (isset($options[PCLZIP_OPT_COMMENT]))
180
-            $this->archive->setArchiveComment($options[PCLZIP_OPT_COMMENT]);
193
+        if (isset($options[PCLZIP_OPT_COMMENT])) {
194
+                    $this->archive->setArchiveComment($options[PCLZIP_OPT_COMMENT]);
195
+        }
181 196
 
182 197
         // scan filesystem for files list
183 198
         $files_list = array();
@@ -208,20 +223,23 @@  discard block
 block discarded – undo
208 223
             // apply filters to a file
209 224
             $localname = $file_to_add;
210 225
             $filename = $file_to_add;
211
-            foreach ($filters as $filter)
212
-                call_user_func($filter, $localname, $filename);
226
+            foreach ($filters as $filter) {
227
+                            call_user_func($filter, $localname, $filename);
228
+            }
213 229
             $file_header = $this->createFileHeader($localname, $filename);
214 230
             if (call_user_func($preAddCallback, $file_header) == 1) {
215 231
                 //
216 232
                 // Check for max length > 255
217 233
                 //
218
-                if (strlen(basename($file_header->stored_filename)) > 255)
219
-                    $file_header->status = 'filename_too_long';
220
-                if (is_file($filename))
221
-                    $this->archive->addFile($file_header->filename,
234
+                if (strlen(basename($file_header->stored_filename)) > 255) {
235
+                                    $file_header->status = 'filename_too_long';
236
+                }
237
+                if (is_file($filename)) {
238
+                                    $this->archive->addFile($file_header->filename,
222 239
                         $file_header->stored_filename);
223
-                else if (is_dir($filename))
224
-                    $this->archive->addEmptyDir($file_header->stored_filename);
240
+                } else if (is_dir($filename)) {
241
+                                    $this->archive->addEmptyDir($file_header->stored_filename);
242
+                }
225 243
             } else {
226 244
                 //
227 245
                 // File was skipped
@@ -285,40 +303,53 @@  discard block
 block discarded – undo
285 303
         }
286 304
 
287 305
         // filters initiation
288
-        if (isset($options[PCLZIP_OPT_PATH]))
289
-            $extractPath = rtrim($options[PCLZIP_OPT_PATH], '/');
290
-        else $extractPath = rtrim(getcwd(), '/');
306
+        if (isset($options[PCLZIP_OPT_PATH])) {
307
+                    $extractPath = rtrim($options[PCLZIP_OPT_PATH], '/');
308
+        } else {
309
+         $extractPath = rtrim(getcwd(), '/');
310
+        }
291 311
 
292 312
         $filters = array();
293 313
         if (isset($options[PCLZIP_OPT_REMOVE_PATH])
294
-            && !isset($options[PCLZIP_OPT_REMOVE_ALL_PATH]))
295
-            $filters[] = function (&$key, &$value) use ($options) {
314
+            && !isset($options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
315
+                    $filters[] = function (&$key, &$value) use ($options) {
296 316
                 $key = str_replace($key, null, $key);
317
+        }
297 318
             };
298
-        if (isset($options[PCLZIP_OPT_REMOVE_ALL_PATH]))
299
-            $filters[] = function (&$key, &$value) { $key = basename($key); };
300
-        if (isset($options[PCLZIP_OPT_ADD_PATH]))
301
-            $filters[] = function (&$key, &$value) use ($options) {
319
+        if (isset($options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
320
+                    $filters[] = function (&$key, &$value) { $key = basename($key);
321
+        }
322
+        };
323
+        if (isset($options[PCLZIP_OPT_ADD_PATH])) {
324
+                    $filters[] = function (&$key, &$value) use ($options) {
302 325
                 $key = rtrim($options[PCLZIP_OPT_ADD_PATH], '/').'/'.
303 326
                     ltrim($key, '/');
327
+        }
304 328
             };
305 329
 
306 330
         if (isset($options[PCLZIP_CB_PRE_EXTRACT])
307
-            && is_callable($options[PCLZIP_CB_PRE_EXTRACT]))
308
-            $preExtractCallback = $options[PCLZIP_CB_PRE_EXTRACT];
309
-        else $preExtractCallback = function () { return 1; };
331
+            && is_callable($options[PCLZIP_CB_PRE_EXTRACT])) {
332
+                    $preExtractCallback = $options[PCLZIP_CB_PRE_EXTRACT];
333
+        } else {
334
+         $preExtractCallback = function () { return 1;
335
+        }
336
+        };
310 337
 
311 338
         if (isset($options[PCLZIP_CB_POST_EXTRACT])
312
-            && is_callable($options[PCLZIP_CB_POST_EXTRACT]))
313
-            $postExtractCallback = $options[PCLZIP_CB_POST_EXTRACT];
314
-        else $postExtractCallback = function () { return 1; };
339
+            && is_callable($options[PCLZIP_CB_POST_EXTRACT])) {
340
+                    $postExtractCallback = $options[PCLZIP_CB_POST_EXTRACT];
341
+        } else {
342
+         $postExtractCallback = function () { return 1;
343
+        }
344
+        };
315 345
 
316 346
         // exact matching
317
-        if (isset($options[PCLZIP_OPT_BY_NAME]))
318
-            $selectFilter = function ($key, $value) use ($options) {
347
+        if (isset($options[PCLZIP_OPT_BY_NAME])) {
348
+                    $selectFilter = function ($key, $value) use ($options) {
319 349
                 $allowedNames = is_array($options[PCLZIP_OPT_BY_NAME])
320 350
                     ? $options[PCLZIP_OPT_BY_NAME]
321 351
                     : explode(',', $options[PCLZIP_OPT_BY_NAME]);
352
+        }
322 353
                 foreach ($allowedNames as $name) {
323 354
                     // select directory with nested files
324 355
                     if (in_array(substr($name, -1), array('/', '\\'))) {
@@ -339,50 +370,64 @@  discard block
 block discarded – undo
339 370
                 return self::SELECT_FILTER_REFUSE;
340 371
             };
341 372
         // <ereg> rule
342
-        else if (isset($options[PCLZIP_OPT_BY_EREG]) && function_exists('ereg'))
343
-            $selectFilter = function ($key, $value) use ($options) {
373
+        else if (isset($options[PCLZIP_OPT_BY_EREG]) && function_exists('ereg')) {
374
+                    $selectFilter = function ($key, $value) use ($options) {
344 375
                 return (ereg($options[PCLZIP_OPT_BY_EREG], $key) !== false)
345 376
                     ? self::SELECT_FILTER_PASS
346 377
                     : self::SELECT_FILTER_REFUSE;
378
+        }
347 379
             };
348 380
         // <preg_match> rule
349
-        else if (isset($options[PCLZIP_OPT_BY_PREG]))
350
-            $selectFilter = function ($key, $value) use ($options) {
381
+        else if (isset($options[PCLZIP_OPT_BY_PREG])) {
382
+                    $selectFilter = function ($key, $value) use ($options) {
351 383
                 return preg_match($options[PCLZIP_OPT_BY_PREG], $key)
352 384
                     ? self::SELECT_FILTER_PASS
353 385
                     : self::SELECT_FILTER_REFUSE;
386
+        }
354 387
             };
355 388
         // index rule
356
-        else if (isset($options[PCLZIP_OPT_BY_INDEX]))
357
-            $selectFilter = function ($key, $value, $index) use ($options) {
389
+        else if (isset($options[PCLZIP_OPT_BY_INDEX])) {
390
+                    $selectFilter = function ($key, $value, $index) use ($options) {
358 391
                 $allowedIndexes = array();
392
+        }
359 393
                 foreach ($options[PCLZIP_OPT_BY_INDEX] as $rule) {
360 394
                     $parts = explode('-', $rule);
361
-                    if (count($parts) == 1) $allowedIndexes[] = $rule;
362
-                    else $allowedIndexes = array_merge(
395
+                    if (count($parts) == 1) {
396
+                     $allowedIndexes[] = $rule;
397
+                    } else {
398
+                     $allowedIndexes = array_merge(
363 399
                         range($parts[0], $parts[1]), $allowedIndexes);
400
+                    }
364 401
                 }
365 402
 
366 403
                 return in_array($index, $allowedIndexes) ? self::SELECT_FILTER_PASS
367 404
                     : self::SELECT_FILTER_REFUSE;
368 405
             };
369 406
         // no rule
370
-        else
371
-            $selectFilter = function () { return self::SELECT_FILTER_PASS; };
407
+        else {
408
+                    $selectFilter = function () { return self::SELECT_FILTER_PASS;
409
+        }
410
+        };
372 411
 
373
-        if (isset($options[PCLZIP_OPT_EXTRACT_AS_STRING]))
374
-            $anotherOutputFormat = PCLZIP_OPT_EXTRACT_AS_STRING;
375
-        else if (isset($options[PCLZIP_OPT_EXTRACT_IN_OUTPUT]))
376
-            $anotherOutputFormat = PCLZIP_OPT_EXTRACT_IN_OUTPUT;
377
-        else $anotherOutputFormat = false;
412
+        if (isset($options[PCLZIP_OPT_EXTRACT_AS_STRING])) {
413
+                    $anotherOutputFormat = PCLZIP_OPT_EXTRACT_AS_STRING;
414
+        } else if (isset($options[PCLZIP_OPT_EXTRACT_IN_OUTPUT])) {
415
+                    $anotherOutputFormat = PCLZIP_OPT_EXTRACT_IN_OUTPUT;
416
+        } else {
417
+         $anotherOutputFormat = false;
418
+        }
378 419
 
379
-        if (isset($options[PCLZIP_OPT_REPLACE_NEWER]))
380
-            $doNotReplaceNewer = false;
381
-        else $doNotReplaceNewer = true;
420
+        if (isset($options[PCLZIP_OPT_REPLACE_NEWER])) {
421
+                    $doNotReplaceNewer = false;
422
+        } else {
423
+         $doNotReplaceNewer = true;
424
+        }
382 425
 
383
-        if (isset($options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION]))
384
-            $restrictExtractDir = $options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION];
385
-        else $restrictExtractDir = false;
426
+        if (isset($options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION])) {
427
+                    $restrictExtractDir = $options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION];
428
+        } else {
429
+         $restrictExtractDir = false;
430
+        }
386 431
 
387 432
         $report = array();
388 433
         foreach ($this->listContent() as $file_header) {
@@ -452,8 +497,10 @@  discard block
 block discarded – undo
452 497
             // extract content
453 498
             else if ($anotherOutputFormat === false) {
454 499
                 // apply path filters
455
-                foreach ($filters as $filter) call_user_func($filter,
500
+                foreach ($filters as $filter) {
501
+                 call_user_func($filter,
456 502
                     $file_header->stored_filename, $file_header->filename);
503
+                }
457 504
                 // dir extraction process
458 505
                 if ($file_header->folder) {
459 506
                     // if dir doesn't exist
@@ -545,8 +592,11 @@  discard block
 block discarded – undo
545 592
      */
546 593
     public function add($content)
547 594
     {
548
-        if (is_array($content)) $paths_list = $content;
549
-        else $paths_list = array_map(explode(',', $content));
595
+        if (is_array($content)) {
596
+         $paths_list = $content;
597
+        } else {
598
+         $paths_list = array_map(explode(',', $content));
599
+        }
550 600
         $report = array();
551 601
 
552 602
         $options = func_get_args();
@@ -568,30 +618,41 @@  discard block
 block discarded – undo
568 618
         // filters initiation
569 619
         $filters = array();
570 620
         if (isset($options[PCLZIP_OPT_REMOVE_PATH])
571
-            && !isset($options[PCLZIP_OPT_REMOVE_ALL_PATH]))
572
-            $filters[] = function (&$key, &$value) use ($options) {
621
+            && !isset($options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
622
+                    $filters[] = function (&$key, &$value) use ($options) {
573 623
                 $key = str_replace($key, null, $key);
624
+        }
574 625
             };
575
-        if (isset($options[PCLZIP_OPT_REMOVE_ALL_PATH]))
576
-            $filters[] = function (&$key, &$value) { $key = basename($key); };
577
-        if (isset($options[PCLZIP_OPT_ADD_PATH]))
578
-            $filters[] = function (&$key, &$value) use ($options) {
626
+        if (isset($options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
627
+                    $filters[] = function (&$key, &$value) { $key = basename($key);
628
+        }
629
+        };
630
+        if (isset($options[PCLZIP_OPT_ADD_PATH])) {
631
+                    $filters[] = function (&$key, &$value) use ($options) {
579 632
                 $key = rtrim($options[PCLZIP_OPT_ADD_PATH], '/').'/'.
580 633
                     ltrim($key, '/');
634
+        }
581 635
             };
582 636
 
583 637
         if (isset($options[PCLZIP_CB_PRE_ADD])
584
-            && is_callable($options[PCLZIP_CB_PRE_ADD]))
585
-            $preAddCallback = $options[PCLZIP_CB_PRE_ADD];
586
-        else $preAddCallback = function () { return 1; };
638
+            && is_callable($options[PCLZIP_CB_PRE_ADD])) {
639
+                    $preAddCallback = $options[PCLZIP_CB_PRE_ADD];
640
+        } else {
641
+         $preAddCallback = function () { return 1;
642
+        }
643
+        };
587 644
 
588 645
         if (isset($options[PCLZIP_CB_POST_ADD])
589
-            && is_callable($options[PCLZIP_CB_POST_ADD]))
590
-            $postAddCallback = $options[PCLZIP_CB_POST_ADD];
591
-        else $postAddCallback = function () { return 1; };
646
+            && is_callable($options[PCLZIP_CB_POST_ADD])) {
647
+                    $postAddCallback = $options[PCLZIP_CB_POST_ADD];
648
+        } else {
649
+         $postAddCallback = function () { return 1;
650
+        }
651
+        };
592 652
 
593
-        if (isset($options[PCLZIP_OPT_COMMENT]))
594
-            $this->archive->setArchiveComment($options[PCLZIP_OPT_COMMENT]);
653
+        if (isset($options[PCLZIP_OPT_COMMENT])) {
654
+                    $this->archive->setArchiveComment($options[PCLZIP_OPT_COMMENT]);
655
+        }
595 656
         if (isset($options[PCLZIP_OPT_ADD_COMMENT])) {
596 657
             $comment =
597 658
                 ($comment = $this->archive->getArchiveComment() !== false)
@@ -645,11 +706,12 @@  discard block
 block discarded – undo
645 706
         );
646 707
 
647 708
         // exact matching
648
-        if (isset($options[PCLZIP_OPT_BY_NAME]))
649
-            $selectFilter = function ($key, $value) use ($options) {
709
+        if (isset($options[PCLZIP_OPT_BY_NAME])) {
710
+                    $selectFilter = function ($key, $value) use ($options) {
650 711
                 $allowedNames = is_array($options[PCLZIP_OPT_BY_NAME])
651 712
                     ? $options[PCLZIP_OPT_BY_NAME]
652 713
                     : explode(',', $options[PCLZIP_OPT_BY_NAME]);
714
+        }
653 715
                 foreach ($allowedNames as $name) {
654 716
                     // select directory with nested files
655 717
                     if (in_array(substr($name, -1), array('/', '\\'))) {
@@ -670,28 +732,34 @@  discard block
 block discarded – undo
670 732
                 return self::SELECT_FILTER_REFUSE;
671 733
             };
672 734
         // <ereg> rule
673
-        else if (isset($options[PCLZIP_OPT_BY_EREG]) && function_exists('ereg'))
674
-            $selectFilter = function ($key, $value) use ($options) {
735
+        else if (isset($options[PCLZIP_OPT_BY_EREG]) && function_exists('ereg')) {
736
+                    $selectFilter = function ($key, $value) use ($options) {
675 737
                 return (ereg($options[PCLZIP_OPT_BY_EREG], $key) !== false)
676 738
                     ? self::SELECT_FILTER_PASS
677 739
                     : self::SELECT_FILTER_REFUSE;
740
+        }
678 741
             };
679 742
         // <preg_match> rule
680
-        else if (isset($options[PCLZIP_OPT_BY_PREG]))
681
-            $selectFilter = function ($key, $value) use ($options) {
743
+        else if (isset($options[PCLZIP_OPT_BY_PREG])) {
744
+                    $selectFilter = function ($key, $value) use ($options) {
682 745
                 return preg_match($options[PCLZIP_OPT_BY_PREG], $key)
683 746
                     ? self::SELECT_FILTER_PASS
684 747
                     : self::SELECT_FILTER_REFUSE;
748
+        }
685 749
             };
686 750
         // index rule
687
-        else if (isset($options[PCLZIP_OPT_BY_INDEX]))
688
-            $selectFilter = function ($key, $value, $index) use ($options) {
751
+        else if (isset($options[PCLZIP_OPT_BY_INDEX])) {
752
+                    $selectFilter = function ($key, $value, $index) use ($options) {
689 753
                 $allowedIndexes = array();
754
+        }
690 755
                 foreach ($options[PCLZIP_OPT_BY_INDEX] as $rule) {
691 756
                     $parts = explode('-', $rule);
692
-                    if (count($parts) == 1) $allowedIndexes[] = $rule;
693
-                    else $allowedIndexes = array_merge(
757
+                    if (count($parts) == 1) {
758
+                     $allowedIndexes[] = $rule;
759
+                    } else {
760
+                     $allowedIndexes = array_merge(
694 761
                         range($parts[0], $parts[1]), $allowedIndexes);
762
+                    }
695 763
                 }
696 764
 
697 765
                 return in_array($index, $allowedIndexes)
@@ -699,8 +767,10 @@  discard block
 block discarded – undo
699 767
                     : self::SELECT_FILTER_REFUSE;
700 768
             };
701 769
         // no rule
702
-        else
703
-            $selectFilter = function () { return self::SELECT_FILTER_PASS; };
770
+        else {
771
+                    $selectFilter = function () { return self::SELECT_FILTER_PASS;
772
+        }
773
+        };
704 774
 
705 775
         foreach ($this->listContent() as $file_header) {
706 776
             // select by select rule
@@ -752,8 +822,12 @@  discard block
 block discarded – undo
752 822
         }
753 823
 
754 824
         $tempDir = tempnam(PCLZIP_TEMPORARY_DIR, 'merging');
755
-        if (file_exists($tempDir)) unlink($tempDir);
756
-        if (!mkdir($tempDir)) return 0;
825
+        if (file_exists($tempDir)) {
826
+         unlink($tempDir);
827
+        }
828
+        if (!mkdir($tempDir)) {
829
+         return 0;
830
+        }
757 831
 
758 832
         // go through archive content list and copy all files
759 833
         foreach ($a->getFileNames() as $filename) {
@@ -782,8 +856,11 @@  discard block
 block discarded – undo
782 856
 
783 857
         call_user_func(function ($directory) {
784 858
             foreach (glob($directory.'/*') as $f) {
785
-                if (is_dir($f)) call_user_func(__FUNCTION__, $f);
786
-                else unlink($f);
859
+                if (is_dir($f)) {
860
+                 call_user_func(__FUNCTION__, $f);
861
+                } else {
862
+                 unlink($f);
863
+                }
787 864
             }
788 865
         }, $tempDir);
789 866
 
Please login to merge, or discard this patch.
src/Formats/Iso.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -79,11 +79,11 @@  discard block
 block discarded – undo
79 79
                     $this->files[$file->Location] = $directory.$file->strd_FileId;
80 80
                     $this->filesSize += $file->DataLen;
81 81
 
82
-                    $this->filesData[$directory . $file->strd_FileId] =
82
+                    $this->filesData[$directory.$file->strd_FileId] =
83 83
                         [
84 84
                             'size' => $file->DataLen,
85 85
                             'mtime' =>
86
-                                strtotime((string)$file->isoRecDate),
86
+                                strtotime((string) $file->isoRecDate),
87 87
                         ];
88 88
                 }
89 89
             }
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
             return false;
132 132
 
133 133
         return new ArchiveEntry($fileName, $this->filesData[$fileName]['size'],
134
-            $this->filesData[$fileName]['size'], $this->filesData[$fileName]['mtime'],false);
134
+            $this->filesData[$fileName]['size'], $this->filesData[$fileName]['mtime'], false);
135 135
     }
136 136
 
137 137
     /**
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
      * @return false|int
224 224
      * @throws UnsupportedOperationException
225 225
      */
226
-    public static function createArchive(array $files, $archiveFileName){
226
+    public static function createArchive(array $files, $archiveFileName) {
227 227
         throw new UnsupportedOperationException();
228 228
     }
229 229
 }
230 230
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +21 added lines, -12 removed lines patch added patch discarded remove patch
@@ -52,8 +52,9 @@  discard block
 block discarded – undo
52 52
 
53 53
         /** @var \CVolumeDescriptor $usedDesc */
54 54
         $usedDesc = $this->iso->GetDescriptor(SUPPLEMENTARY_VOLUME_DESC);
55
-        if (!$usedDesc)
56
-            $usedDesc = $this->iso->GetDescriptor(PRIMARY_VOLUME_DESC);
55
+        if (!$usedDesc) {
56
+                    $usedDesc = $this->iso->GetDescriptor(PRIMARY_VOLUME_DESC);
57
+        }
57 58
         $this->blockSize = $usedDesc->iBlockSize;
58 59
         $directories = $usedDesc->LoadMPathTable($this->iso);
59 60
         // iterate over all directories
@@ -74,8 +75,9 @@  discard block
 block discarded – undo
74 75
             if ($files) {
75 76
                 /** @var \CFileDirDescriptors $file */
76 77
                 foreach ($files as $file) {
77
-                    if (in_array($file->strd_FileId, ['.', '..']) || $file->IsDirectory())
78
-                        continue;
78
+                    if (in_array($file->strd_FileId, ['.', '..']) || $file->IsDirectory()) {
79
+                                            continue;
80
+                    }
79 81
                     $this->files[$file->Location] = $directory.$file->strd_FileId;
80 82
                     $this->filesSize += $file->DataLen;
81 83
 
@@ -127,8 +129,9 @@  discard block
 block discarded – undo
127 129
      */
128 130
     public function getFileData($fileName)
129 131
     {
130
-        if (!isset($this->filesData[$fileName]))
131
-            return false;
132
+        if (!isset($this->filesData[$fileName])) {
133
+                    return false;
134
+        }
132 135
 
133 136
         return new ArchiveEntry($fileName, $this->filesData[$fileName]['size'],
134 137
             $this->filesData[$fileName]['size'], $this->filesData[$fileName]['mtime'],false);
@@ -142,11 +145,14 @@  discard block
 block discarded – undo
142 145
     public function getFileContent($fileName)
143 146
     {
144 147
         $Location = array_search($fileName, $this->files, true);
145
-        if (!isset($this->filesData[$fileName])) return false;
148
+        if (!isset($this->filesData[$fileName])) {
149
+         return false;
150
+        }
146 151
         $data = $this->filesData[$fileName];
147 152
         $Location_Real = $Location * $this->blockSize;
148
-        if ($this->iso->Seek($Location_Real, SEEK_SET) === false)
149
-            return false;
153
+        if ($this->iso->Seek($Location_Real, SEEK_SET) === false) {
154
+                    return false;
155
+        }
150 156
 
151 157
         return $this->iso->Read($data['size']);
152 158
     }
@@ -159,11 +165,14 @@  discard block
 block discarded – undo
159 165
     public function getFileResource($fileName)
160 166
     {
161 167
         $Location = array_search($fileName, $this->files, true);
162
-        if (!isset($this->filesData[$fileName])) return false;
168
+        if (!isset($this->filesData[$fileName])) {
169
+         return false;
170
+        }
163 171
         $data = $this->filesData[$fileName];
164 172
         $Location_Real = $Location * $this->blockSize;
165
-        if ($this->iso->Seek($Location_Real, SEEK_SET) === false)
166
-            return false;
173
+        if ($this->iso->Seek($Location_Real, SEEK_SET) === false) {
174
+                    return false;
175
+        }
167 176
 
168 177
         $resource = fopen('php://temp', 'r+');
169 178
         fwrite($resource, $this->iso->Read($data['size']));
Please login to merge, or discard this patch.
src/UnifiedArchive.php 1 patch
Braces   +76 added lines, -50 removed lines patch added patch discarded remove patch
@@ -87,8 +87,9 @@  discard block
 block discarded – undo
87 87
     {
88 88
         self::checkRequirements();
89 89
 
90
-        if (!file_exists($fileName) || !is_readable($fileName))
91
-            throw new Exception('Could not open file: '.$fileName);
90
+        if (!file_exists($fileName) || !is_readable($fileName)) {
91
+                    throw new Exception('Could not open file: '.$fileName);
92
+        }
92 93
 
93 94
         $type = self::detectArchiveType($fileName);
94 95
         if (!self::canOpenType($type)) {
@@ -227,8 +228,9 @@  discard block
 block discarded – undo
227 228
         $this->type = $type;
228 229
         $this->archiveSize = filesize($fileName);
229 230
 
230
-        if (!isset(static::$formatHandlers[$type]))
231
-            throw new Exception('Unsupported archive type: '.$type.' of archive '.$fileName);
231
+        if (!isset(static::$formatHandlers[$type])) {
232
+                    throw new Exception('Unsupported archive type: '.$type.' of archive '.$fileName);
233
+        }
232 234
 
233 235
         $handler_class = static::$formatHandlers[$type];
234 236
 
@@ -265,8 +267,9 @@  discard block
 block discarded – undo
265 267
      */
266 268
     public function getPclZipInterface()
267 269
     {
268
-        if ($this->type !== self::ZIP)
269
-            throw new UnsupportedOperationException('Format '.$this->type.' does not support PclZip-interface');
270
+        if ($this->type !== self::ZIP) {
271
+                    throw new UnsupportedOperationException('Format '.$this->type.' does not support PclZip-interface');
272
+        }
270 273
 
271 274
         return new $this->archive->getPclZip();
272 275
     }
@@ -350,8 +353,9 @@  discard block
 block discarded – undo
350 353
      */
351 354
     public function getFileData($fileName)
352 355
     {
353
-        if (!in_array($fileName, $this->files, true))
354
-            return false;
356
+        if (!in_array($fileName, $this->files, true)) {
357
+                    return false;
358
+        }
355 359
 
356 360
         return $this->archive->getFileData($fileName);
357 361
     }
@@ -365,8 +369,9 @@  discard block
 block discarded – undo
365 369
      */
366 370
     public function getFileContent($fileName)
367 371
     {
368
-        if (!in_array($fileName, $this->files, true))
369
-            return false;
372
+        if (!in_array($fileName, $this->files, true)) {
373
+                    return false;
374
+        }
370 375
 
371 376
         return $this->archive->getFileContent($fileName);
372 377
     }
@@ -379,8 +384,9 @@  discard block
 block discarded – undo
379 384
      */
380 385
     public function getFileResource($fileName)
381 386
     {
382
-        if (!in_array($fileName, $this->files, true))
383
-            return false;
387
+        if (!in_array($fileName, $this->files, true)) {
388
+                    return false;
389
+        }
384 390
 
385 391
         return $this->archive->getFileResource($fileName);
386 392
     }
@@ -397,10 +403,13 @@  discard block
 block discarded – undo
397 403
     public function extractFiles($outputFolder, $files = null, $expandFilesList = false)
398 404
     {
399 405
         if ($files !== null) {
400
-            if (is_string($files)) $files = [$files];
406
+            if (is_string($files)) {
407
+             $files = [$files];
408
+            }
401 409
 
402
-            if ($expandFilesList)
403
-                $files = self::expandFileList($this->files, $files);
410
+            if ($expandFilesList) {
411
+                            $files = self::expandFileList($this->files, $files);
412
+            }
404 413
 
405 414
             return $this->archive->extractFiles($outputFolder, $files);
406 415
         } else {
@@ -422,8 +431,9 @@  discard block
 block discarded – undo
422 431
     {
423 432
         $fileOrFiles = is_string($fileOrFiles) ? [$fileOrFiles] : $fileOrFiles;
424 433
 
425
-        if ($expandFilesList && $fileOrFiles !== null)
426
-            $fileOrFiles = self::expandFileList($this->files, $fileOrFiles);
434
+        if ($expandFilesList && $fileOrFiles !== null) {
435
+                    $fileOrFiles = self::expandFileList($this->files, $fileOrFiles);
436
+        }
427 437
 
428 438
         $result = $this->archive->deleteFiles($fileOrFiles);
429 439
         $this->scanArchive();
@@ -440,8 +450,9 @@  discard block
 block discarded – undo
440 450
     public function addFiles($fileOrFiles)
441 451
     {
442 452
         $files_list = self::createFilesList($fileOrFiles);
443
-        if (empty($files_list))
444
-            throw new InvalidArgumentException('Files list is empty!');
453
+        if (empty($files_list)) {
454
+                    throw new InvalidArgumentException('Files list is empty!');
455
+        }
445 456
         $result = $this->archive->addFiles($files_list);
446 457
         $this->scanArchive();
447 458
         return $result;
@@ -457,8 +468,9 @@  discard block
 block discarded – undo
457 468
      */
458 469
     public function addFile($file, $inArchiveName = null)
459 470
     {
460
-        if (!is_file($file))
461
-            throw new InvalidArgumentException($file.' is not a valid file to add in archive');
471
+        if (!is_file($file)) {
472
+                    throw new InvalidArgumentException($file.' is not a valid file to add in archive');
473
+        }
462 474
 
463 475
         return ($inArchiveName !== null
464 476
                 ? $this->addFiles([$file => $inArchiveName])
@@ -475,8 +487,9 @@  discard block
 block discarded – undo
475 487
      */
476 488
     public function addDirectory($directory, $inArchivePath = null)
477 489
     {
478
-        if (!is_dir($directory) || !is_readable($directory))
479
-            throw new InvalidArgumentException($directory.' is not a valid directory to add in archive');
490
+        if (!is_dir($directory) || !is_readable($directory)) {
491
+                    throw new InvalidArgumentException($directory.' is not a valid directory to add in archive');
492
+        }
480 493
 
481 494
         return ($inArchivePath !== null
482 495
                 ? $this->addFiles([$directory => $inArchivePath])
@@ -512,25 +525,30 @@  discard block
 block discarded – undo
512 525
      */
513 526
     public static function archiveFiles($fileOrFiles, $archiveName, $emulate = false)
514 527
     {
515
-        if (file_exists($archiveName))
516
-            throw new Exception('Archive '.$archiveName.' already exists!');
528
+        if (file_exists($archiveName)) {
529
+                    throw new Exception('Archive '.$archiveName.' already exists!');
530
+        }
517 531
 
518 532
         self::checkRequirements();
519 533
 
520 534
         $archiveType = self::detectArchiveType($archiveName, false);
521 535
         //        if (in_array($archiveType, [TarArchive::TAR, TarArchive::TAR_GZIP, TarArchive::TAR_BZIP, TarArchive::TAR_LZMA, TarArchive::TAR_LZW], true))
522 536
         //            return TarArchive::archiveFiles($fileOrFiles, $archiveName, $emulate);
523
-        if ($archiveType === false)
524
-            return false;
537
+        if ($archiveType === false) {
538
+                    return false;
539
+        }
525 540
 
526 541
         $files_list = self::createFilesList($fileOrFiles);
527
-        if (empty($files_list))
528
-            throw new InvalidArgumentException('Files list is empty!');
542
+        if (empty($files_list)) {
543
+                    throw new InvalidArgumentException('Files list is empty!');
544
+        }
529 545
 
530 546
         // fake creation: return archive data
531 547
         if ($emulate) {
532 548
             $totalSize = 0;
533
-            foreach ($files_list as $fn) $totalSize += filesize($fn);
549
+            foreach ($files_list as $fn) {
550
+             $totalSize += filesize($fn);
551
+            }
534 552
 
535 553
             return array(
536 554
                 'totalSize' => $totalSize,
@@ -540,8 +558,9 @@  discard block
 block discarded – undo
540 558
             );
541 559
         }
542 560
 
543
-        if (!isset(static::$formatHandlers[$archiveType]))
544
-            throw new Exception('Unsupported archive type: '.$archiveType.' of archive '.$archiveName);
561
+        if (!isset(static::$formatHandlers[$archiveType])) {
562
+                    throw new Exception('Unsupported archive type: '.$archiveType.' of archive '.$archiveName);
563
+        }
545 564
 
546 565
         $handler_class = static::$formatHandlers[$archiveType];
547 566
 
@@ -558,8 +577,9 @@  discard block
 block discarded – undo
558 577
      */
559 578
     public static function archiveFile($file, $archiveName)
560 579
     {
561
-        if (!is_file($file))
562
-            throw new InvalidArgumentException($file.' is not a valid file to archive');
580
+        if (!is_file($file)) {
581
+                    throw new InvalidArgumentException($file.' is not a valid file to archive');
582
+        }
563 583
 
564 584
         return static::archiveFiles($file, $archiveName) === 1;
565 585
     }
@@ -574,8 +594,9 @@  discard block
 block discarded – undo
574 594
      */
575 595
     public static function archiveDirectory($directory, $archiveName)
576 596
     {
577
-        if (!is_dir($directory) || !is_readable($directory))
578
-            throw new InvalidArgumentException($directory.' is not a valid directory to archive');
597
+        if (!is_dir($directory) || !is_readable($directory)) {
598
+                    throw new InvalidArgumentException($directory.' is not a valid directory to archive');
599
+        }
579 600
 
580 601
         return static::archiveFiles($directory, $archiveName) > 0;
581 602
     }
@@ -644,8 +665,9 @@  discard block
 block discarded – undo
644 665
         $newFiles = [];
645 666
         foreach ($files as $file) {
646 667
             foreach ($archiveFiles as $archiveFile) {
647
-                if (fnmatch($file.'*', $archiveFile))
648
-                    $newFiles[] = $archiveFile;
668
+                if (fnmatch($file.'*', $archiveFile)) {
669
+                                    $newFiles[] = $archiveFile;
670
+                }
649 671
             }
650 672
         }
651 673
         return $newFiles;
@@ -662,26 +684,29 @@  discard block
 block discarded – undo
662 684
         // passed an extended list
663 685
         if (is_array($nodes)) {
664 686
             foreach ($nodes as $source => $destination) {
665
-                if (is_numeric($source))
666
-                    $source = $destination;
687
+                if (is_numeric($source)) {
688
+                                    $source = $destination;
689
+                }
667 690
 
668 691
                 $destination = rtrim($destination, '/\\*');
669 692
 
670 693
                 // if is directory
671
-                if (is_dir($source))
672
-                    self::importFilesFromDir(rtrim($source, '/\\*').'/*',
694
+                if (is_dir($source)) {
695
+                                    self::importFilesFromDir(rtrim($source, '/\\*').'/*',
673 696
                         !empty($destination) ? $destination.'/' : null, true, $files);
674
-                else if (is_file($source))
675
-                    $files[$destination] = $source;
697
+                } else if (is_file($source)) {
698
+                                    $files[$destination] = $source;
699
+                }
676 700
             }
677 701
 
678 702
         } else if (is_string($nodes)) { // passed one file or directory
679 703
             // if is directory
680
-            if (is_dir($nodes))
681
-                self::importFilesFromDir(rtrim($nodes, '/\\*').'/*', null, true,
704
+            if (is_dir($nodes)) {
705
+                            self::importFilesFromDir(rtrim($nodes, '/\\*').'/*', null, true,
682 706
                     $files);
683
-            else if (is_file($nodes))
684
-                $files[basename($nodes)] = $nodes;
707
+            } else if (is_file($nodes)) {
708
+                            $files[basename($nodes)] = $nodes;
709
+            }
685 710
         }
686 711
 
687 712
         return $files;
@@ -698,8 +723,9 @@  discard block
 block discarded – undo
698 723
         // $map[$destination] = rtrim($source, '/*');
699 724
         // do not map root archive folder
700 725
 
701
-        if ($destination !== null)
702
-            $map[$destination] = null;
726
+        if ($destination !== null) {
727
+                    $map[$destination] = null;
728
+        }
703 729
 
704 730
         foreach (glob($source, GLOB_MARK) as $node) {
705 731
             if (in_array(substr($node, -1), ['/', '\\'], true) && $recursive) {
Please login to merge, or discard this patch.
src/Formats/Archive7z.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@
 block discarded – undo
14 14
         $binary = static::makeBinary7z();
15 15
         $process = new Process(escapeshellarg(str_replace('\\', '/', $binary)));
16 16
         $result = $process->mustRun()->getOutput();
17
-        if (!preg_match('~7-Zip (\d+\.\d+)~i', $result, $version))
18
-            return false;
17
+        if (!preg_match('~7-Zip (\d+\.\d+)~i', $result, $version)) {
18
+                    return false;
19
+        }
19 20
 
20 21
         return $version[1];
21 22
     }
Please login to merge, or discard this patch.