Passed
Branch 0.1.x (480082)
by f
02:52
created
src/TarArchive.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -449,7 +449,7 @@  discard block
 block discarded – undo
449 449
                     $compression = 'lzma2';
450 450
                     break;
451 451
                 case 'z':
452
-                    $tar_aname = 'compress.lzw://' . $archiveName;
452
+                    $tar_aname = 'compress.lzw://'.$archiveName;
453 453
                     break;
454 454
             }
455 455
 
@@ -634,7 +634,7 @@  discard block
 block discarded – undo
634 634
                 if (!self::$enabledPharData) {
635 635
                     throw new Exception('Archive_Tar not available');
636 636
                 }
637
-                $this->tar = new Archive_Tar('compress.lzw://' . $this->path);
637
+                $this->tar = new Archive_Tar('compress.lzw://'.$this->path);
638 638
                 break;
639 639
 
640 640
             default:
Please login to merge, or discard this patch.
Braces   +66 added lines, -44 removed lines patch added patch discarded remove patch
@@ -57,8 +57,9 @@  discard block
 block discarded – undo
57 57
     {
58 58
         self::checkRequirements();
59 59
 
60
-        if (!file_exists($fileName) || !is_readable($fileName))
61
-            throw new Exception('Count not open file: '.$fileName);
60
+        if (!file_exists($fileName) || !is_readable($fileName)) {
61
+                    throw new Exception('Count not open file: '.$fileName);
62
+        }
62 63
 
63 64
         $type = self::detectArchiveType($fileName);
64 65
         if (!self::canOpenType($type)) {
@@ -168,8 +169,9 @@  discard block
 block discarded – undo
168 169
 
169 170
         $this->path = realpath($fileName);
170 171
 
171
-        if (!self::$enabledPharData && !self::$enabledPearTar)
172
-            throw new Exception('Archive_Tar nor PharData not available');
172
+        if (!self::$enabledPharData && !self::$enabledPearTar) {
173
+                    throw new Exception('Archive_Tar nor PharData not available');
174
+        }
173 175
 
174 176
         $this->openArchive($type);
175 177
         $this->scanArchive();
@@ -199,8 +201,9 @@  discard block
 block discarded – undo
199 201
      */
200 202
     public function getFileData($fileName)
201 203
     {
202
-        if (!in_array($fileName, $this->files, true))
203
-            return false;
204
+        if (!in_array($fileName, $this->files, true)) {
205
+                    return false;
206
+        }
204 207
 
205 208
         if ($this->tar instanceof Archive_Tar) {
206 209
             $index = array_search($fileName, $this->files, true);
@@ -226,12 +229,14 @@  discard block
 block discarded – undo
226 229
      */
227 230
     public function getFileContent($fileName)
228 231
     {
229
-        if (!in_array($fileName, $this->files, true))
230
-            return false;
231
-        if ($this->tar instanceof Archive_Tar)
232
-            return $this->tar->extractInString($fileName);
233
-        else
234
-            return $this->tar[$fileName]->getContent();
232
+        if (!in_array($fileName, $this->files, true)) {
233
+                    return false;
234
+        }
235
+        if ($this->tar instanceof Archive_Tar) {
236
+                    return $this->tar->extractInString($fileName);
237
+        } else {
238
+                    return $this->tar[$fileName]->getContent();
239
+        }
235 240
     }
236 241
 
237 242
     /**
@@ -241,8 +246,9 @@  discard block
 block discarded – undo
241 246
     {
242 247
         $tree = array(DIRECTORY_SEPARATOR);
243 248
         foreach ($this->files as $filename) {
244
-            if (in_array(substr($filename, -1), array('/', '\\')))
245
-                $tree[] = DIRECTORY_SEPARATOR.$filename;
249
+            if (in_array(substr($filename, -1), array('/', '\\'))) {
250
+                            $tree[] = DIRECTORY_SEPARATOR.$filename;
251
+            }
246 252
         }
247 253
 
248 254
         return $tree;
@@ -257,8 +263,9 @@  discard block
 block discarded – undo
257 263
      */
258 264
     public function extractFiles($outputFolder, $files = null, $expandFilesList = false)
259 265
     {
260
-        if ($expandFilesList && $files !== null)
261
-            $files = self::expandFileList($this->files, $files);
266
+        if ($expandFilesList && $files !== null) {
267
+                    $files = self::expandFileList($this->files, $files);
268
+        }
262 269
 
263 270
         $list = array();
264 271
         if ($files === null) {
@@ -292,21 +299,25 @@  discard block
 block discarded – undo
292 299
      */
293 300
     public function deleteFiles($fileOrFiles, $expandFilesList = false)
294 301
     {
295
-        if ($this->tar instanceof Archive_Tar)
296
-            return false;
302
+        if ($this->tar instanceof Archive_Tar) {
303
+                    return false;
304
+        }
297 305
 
298
-        if ($expandFilesList && $fileOrFiles !== null)
299
-            $fileOrFiles = self::expandFileList($this->files, $fileOrFiles);
306
+        if ($expandFilesList && $fileOrFiles !== null) {
307
+                    $fileOrFiles = self::expandFileList($this->files, $fileOrFiles);
308
+        }
300 309
 
301 310
         $files = is_string($fileOrFiles) ? array($fileOrFiles) : $fileOrFiles;
302 311
         $deleted = 0;
303 312
 
304 313
         foreach ($files as $i => $file) {
305
-            if (!in_array($file, $this->files, true))
306
-                continue;
314
+            if (!in_array($file, $this->files, true)) {
315
+                            continue;
316
+            }
307 317
 
308
-            if ($this->tar->delete($file))
309
-                $deleted++;
318
+            if ($this->tar->delete($file)) {
319
+                            $deleted++;
320
+            }
310 321
         }
311 322
 
312 323
         $this->tar = null;
@@ -333,11 +344,13 @@  discard block
 block discarded – undo
333 344
                 $remove_dir = dirname($filename);
334 345
                 $add_dir = dirname($localname);
335 346
                 if (is_null($filename)) {
336
-                    if ($this->tar->addString($localname, "") === false)
337
-                        return false;
347
+                    if ($this->tar->addString($localname, "") === false) {
348
+                                            return false;
349
+                    }
338 350
                 } else {
339
-                    if ($this->tar->addModify($filename, $add_dir, $remove_dir) === false)
340
-                        return false;
351
+                    if ($this->tar->addModify($filename, $add_dir, $remove_dir) === false) {
352
+                                            return false;
353
+                    }
341 354
                     $added_files++;
342 355
                 }
343 356
             }
@@ -416,15 +429,18 @@  discard block
 block discarded – undo
416 429
     {
417 430
         self::checkRequirements();
418 431
 
419
-        if (file_exists($archiveName))
420
-            throw new Exception('Archive '.$archiveName.' already exists!');
432
+        if (file_exists($archiveName)) {
433
+                    throw new Exception('Archive '.$archiveName.' already exists!');
434
+        }
421 435
 
422 436
         $fileOrFiles = self::createFilesList($fileOrFiles);
423 437
 
424 438
         // fake creation: return archive data
425 439
         if ($emulate) {
426 440
             $totalSize = 0;
427
-            foreach ($fileOrFiles as $fn) $totalSize += filesize($fn);
441
+            foreach ($fileOrFiles as $fn) {
442
+             $totalSize += filesize($fn);
443
+            }
428 444
 
429 445
             return array(
430 446
                 'totalSize' => $totalSize,
@@ -453,21 +469,25 @@  discard block
 block discarded – undo
453 469
                     break;
454 470
             }
455 471
 
456
-            if (isset($tar_aname))
457
-                $tar = new Archive_Tar($tar_aname, $compression);
458
-            else
459
-                $tar = new Archive_Tar($archiveName, $compression);
472
+            if (isset($tar_aname)) {
473
+                            $tar = new Archive_Tar($tar_aname, $compression);
474
+            } else {
475
+                            $tar = new Archive_Tar($archiveName, $compression);
476
+            }
460 477
 
461 478
             foreach ($fileOrFiles as $localname => $filename) {
462 479
                 $remove_dir = dirname($filename);
463 480
                 $add_dir = dirname($localname);
464 481
 
465 482
                 if (is_null($filename)) {
466
-                    if ($tar->addString($localname, "") === false)
467
-                        return false;
483
+                    if ($tar->addString($localname, "") === false) {
484
+                                            return false;
485
+                    }
468 486
                 } else {
469 487
                     if ($tar->addModify($filename, $add_dir, $remove_dir)
470
-                        === false) return false;
488
+                        === false) {
489
+                     return false;
490
+                    }
471 491
                 }
472 492
             }
473 493
             $tar = null;
@@ -578,14 +598,16 @@  discard block
 block discarded – undo
578 598
      */
579 599
     public function getFileResource($fileName)
580 600
     {
581
-        if (!in_array($fileName, $this->files, true))
582
-            return false;
601
+        if (!in_array($fileName, $this->files, true)) {
602
+                    return false;
603
+        }
583 604
 
584 605
         $resource = fopen('php://temp', 'r+');
585
-        if ($this->tar instanceof Archive_Tar)
586
-            fwrite($resource, $this->tar->extractInString($fileName));
587
-        else
588
-            fwrite($resource, $this->tar[$fileName]->getContent());
606
+        if ($this->tar instanceof Archive_Tar) {
607
+                    fwrite($resource, $this->tar->extractInString($fileName));
608
+        } else {
609
+                    fwrite($resource, $this->tar[$fileName]->getContent());
610
+        }
589 611
 
590 612
         rewind($resource);
591 613
         return $resource;
Please login to merge, or discard this patch.
src/PclZipLikeZipArchiveInterface.php 2 patches
Spacing   +37 added lines, -38 removed lines patch added patch discarded remove patch
@@ -57,8 +57,8 @@  discard block
 block discarded – undo
57 57
             }
58 58
         } else {
59 59
             $options = array_combine(
60
-                array_filter($options, function ($v) {return (bool) $v&2;}),
61
-                array_filter($options, function ($v) {return (bool) ($v-1)&2;})
60
+                array_filter($options, function($v) {return (bool) $v & 2; }),
61
+                array_filter($options, function($v) {return (bool) ($v - 1) & 2; })
62 62
             );
63 63
         }
64 64
 
@@ -66,12 +66,12 @@  discard block
 block discarded – undo
66 66
         $filters = array();
67 67
         if (isset($options[PCLZIP_OPT_REMOVE_PATH])
68 68
             && !isset($options[PCLZIP_OPT_REMOVE_ALL_PATH]))
69
-            $filters[] = function (&$key, &$value) use ($options) {
69
+            $filters[] = function(&$key, &$value) use ($options) {
70 70
                 $key = str_replace($key, null, $key); };
71 71
         if (isset($options[PCLZIP_OPT_REMOVE_ALL_PATH]))
72
-            $filters[] = function (&$key, &$value) { $key = basename($key); };
72
+            $filters[] = function(&$key, &$value) { $key = basename($key); };
73 73
         if (isset($options[PCLZIP_OPT_ADD_PATH]))
74
-            $filters[] = function (&$key, &$value) use ($options) {
74
+            $filters[] = function(&$key, &$value) use ($options) {
75 75
                 $key = rtrim($options[PCLZIP_OPT_ADD_PATH], '/').'/'.
76 76
                 ltrim($key, '/');
77 77
             };
@@ -79,12 +79,12 @@  discard block
 block discarded – undo
79 79
         if (isset($options[PCLZIP_CB_PRE_ADD])
80 80
             && is_callable($options[PCLZIP_CB_PRE_ADD]))
81 81
             $preAddCallback = $options[PCLZIP_CB_PRE_ADD];
82
-        else $preAddCallback = function () { return 1; };
82
+        else $preAddCallback = function() { return 1; };
83 83
 
84 84
         if (isset($options[PCLZIP_CB_POST_ADD])
85 85
             && is_callable($options[PCLZIP_CB_POST_ADD]))
86 86
             $postAddCallback = $options[PCLZIP_CB_POST_ADD];
87
-        else $postAddCallback = function () { return 1; };
87
+        else $postAddCallback = function() { return 1; };
88 88
 
89 89
         if (isset($options[PCLZIP_OPT_COMMENT]))
90 90
             $this->archive->setArchiveComment($options[PCLZIP_OPT_COMMENT]);
@@ -158,8 +158,7 @@  discard block
 block discarded – undo
158 158
                 'size' => $statIndex['size'],
159 159
                 'compressed_size' => $statIndex['comp_size'],
160 160
                 'mtime' => $statIndex,
161
-                'comment' => ($comment = $this->archive->getCommentIndex
162
-                    ($statIndex['index']) !== false) ? $comment : null,
161
+                'comment' => ($comment = $this->archive->getCommentIndex($statIndex['index']) !== false) ? $comment : null,
163 162
                 'folder' => in_array(substr($statIndex['name'], -1),
164 163
                     array('/', '\\')),
165 164
                 'index' => $statIndex['index'],
@@ -189,8 +188,8 @@  discard block
 block discarded – undo
189 188
             }
190 189
         } else {
191 190
             $options = array_combine(
192
-                array_filter($options, function ($v) {return (bool) $v&2;}),
193
-                array_filter($options, function ($v) {return (bool) ($v-1)&2;})
191
+                array_filter($options, function($v) {return (bool) $v & 2; }),
192
+                array_filter($options, function($v) {return (bool) ($v - 1) & 2; })
194 193
             );
195 194
         }
196 195
 
@@ -202,13 +201,13 @@  discard block
 block discarded – undo
202 201
         $filters = array();
203 202
         if (isset($options[PCLZIP_OPT_REMOVE_PATH])
204 203
             && !isset($options[PCLZIP_OPT_REMOVE_ALL_PATH]))
205
-            $filters[] = function (&$key, &$value) use ($options) {
204
+            $filters[] = function(&$key, &$value) use ($options) {
206 205
              $key = str_replace($key, null, $key);
207 206
          };
208 207
         if (isset($options[PCLZIP_OPT_REMOVE_ALL_PATH]))
209
-            $filters[] = function (&$key, &$value) { $key = basename($key); };
208
+            $filters[] = function(&$key, &$value) { $key = basename($key); };
210 209
         if (isset($options[PCLZIP_OPT_ADD_PATH]))
211
-            $filters[] = function (&$key, &$value) use ($options) {
210
+            $filters[] = function(&$key, &$value) use ($options) {
212 211
              $key = rtrim($options[PCLZIP_OPT_ADD_PATH], '/').'/'.
213 212
                 ltrim($key, '/');
214 213
         };
@@ -216,16 +215,16 @@  discard block
 block discarded – undo
216 215
         if (isset($options[PCLZIP_CB_PRE_EXTRACT])
217 216
             && is_callable($options[PCLZIP_CB_PRE_EXTRACT]))
218 217
             $preExtractCallback = $options[PCLZIP_CB_PRE_EXTRACT];
219
-        else $preExtractCallback = function () { return 1; };
218
+        else $preExtractCallback = function() { return 1; };
220 219
 
221 220
         if (isset($options[PCLZIP_CB_POST_EXTRACT])
222 221
             && is_callable($options[PCLZIP_CB_POST_EXTRACT]))
223 222
             $postExtractCallback = $options[PCLZIP_CB_POST_EXTRACT];
224
-        else $postExtractCallback = function () { return 1; };
223
+        else $postExtractCallback = function() { return 1; };
225 224
 
226 225
         // exact matching
227 226
         if (isset($options[PCLZIP_OPT_BY_NAME]))
228
-            $selectFilter = function ($key, $value) use ($options) {
227
+            $selectFilter = function($key, $value) use ($options) {
229 228
             $allowedNames = is_array($options[PCLZIP_OPT_BY_NAME])
230 229
                 ? $options[PCLZIP_OPT_BY_NAME]
231 230
                 : explode(',', $options[PCLZIP_OPT_BY_NAME]);
@@ -250,21 +249,21 @@  discard block
 block discarded – undo
250 249
         };
251 250
         // <ereg> rule
252 251
         else if (isset($options[PCLZIP_OPT_BY_EREG]) && function_exists('ereg'))
253
-            $selectFilter = function ($key, $value) use ($options) {
252
+            $selectFilter = function($key, $value) use ($options) {
254 253
                 return (ereg($options[PCLZIP_OPT_BY_EREG], $key) !== false)
255 254
                     ? self::SELECT_FILTER_PASS
256 255
                     : self::SELECT_FILTER_REFUSE;
257 256
             };
258 257
         // <preg_match> rule
259 258
         else if (isset($options[PCLZIP_OPT_BY_PREG]))
260
-            $selectFilter = function ($key, $value) use ($options) {
259
+            $selectFilter = function($key, $value) use ($options) {
261 260
                 return preg_match($options[PCLZIP_OPT_BY_PREG], $key)
262 261
                     ? self::SELECT_FILTER_PASS
263 262
                     : self::SELECT_FILTER_REFUSE;
264 263
             };
265 264
         // index rule
266 265
         else if (isset($options[PCLZIP_OPT_BY_INDEX]))
267
-            $selectFilter = function ($key, $value, $index) use ($options) {
266
+            $selectFilter = function($key, $value, $index) use ($options) {
268 267
                 $allowedIndexes = array();
269 268
                 foreach ($options[PCLZIP_OPT_BY_INDEX] as $rule) {
270 269
                     $parts = explode('-', $rule);
@@ -278,7 +277,7 @@  discard block
 block discarded – undo
278 277
         };
279 278
         // no rule
280 279
         else
281
-            $selectFilter = function () { return self::SELECT_FILTER_PASS; };
280
+            $selectFilter = function() { return self::SELECT_FILTER_PASS; };
282 281
 
283 282
         if (isset($options[PCLZIP_OPT_EXTRACT_AS_STRING]))
284 283
             $anotherOutputFormat = PCLZIP_OPT_EXTRACT_AS_STRING;
@@ -470,8 +469,8 @@  discard block
 block discarded – undo
470 469
             }
471 470
         } else {
472 471
             $options = array_combine(
473
-                array_filter($options, function ($v) {return (bool) $v&2;}),
474
-                array_filter($options, function ($v) {return (bool) ($v-1)&2;})
472
+                array_filter($options, function($v) {return (bool) $v & 2; }),
473
+                array_filter($options, function($v) {return (bool) ($v - 1) & 2; })
475 474
             );
476 475
         }
477 476
 
@@ -479,13 +478,13 @@  discard block
 block discarded – undo
479 478
         $filters = array();
480 479
         if (isset($options[PCLZIP_OPT_REMOVE_PATH])
481 480
             && !isset($options[PCLZIP_OPT_REMOVE_ALL_PATH]))
482
-            $filters[] = function (&$key, &$value) use ($options) {
481
+            $filters[] = function(&$key, &$value) use ($options) {
483 482
                 $key = str_replace($key, null, $key);
484 483
             };
485 484
         if (isset($options[PCLZIP_OPT_REMOVE_ALL_PATH]))
486
-            $filters[] = function (&$key, &$value) { $key = basename($key); };
485
+            $filters[] = function(&$key, &$value) { $key = basename($key); };
487 486
         if (isset($options[PCLZIP_OPT_ADD_PATH]))
488
-            $filters[] = function (&$key, &$value) use ($options) {
487
+            $filters[] = function(&$key, &$value) use ($options) {
489 488
                 $key = rtrim($options[PCLZIP_OPT_ADD_PATH], '/').'/'.
490 489
                 ltrim($key, '/');
491 490
             };
@@ -493,12 +492,12 @@  discard block
 block discarded – undo
493 492
         if (isset($options[PCLZIP_CB_PRE_ADD])
494 493
             && is_callable($options[PCLZIP_CB_PRE_ADD]))
495 494
             $preAddCallback = $options[PCLZIP_CB_PRE_ADD];
496
-        else $preAddCallback = function () { return 1; };
495
+        else $preAddCallback = function() { return 1; };
497 496
 
498 497
         if (isset($options[PCLZIP_CB_POST_ADD])
499 498
             && is_callable($options[PCLZIP_CB_POST_ADD]))
500 499
             $postAddCallback = $options[PCLZIP_CB_POST_ADD];
501
-        else $postAddCallback = function () { return 1; };
500
+        else $postAddCallback = function() { return 1; };
502 501
 
503 502
         if (isset($options[PCLZIP_OPT_COMMENT]))
504 503
             $this->archive->setArchiveComment($options[PCLZIP_OPT_COMMENT]);
@@ -507,14 +506,14 @@  discard block
 block discarded – undo
507 506
             ($comment = $this->archive->getArchiveComment() !== false)
508 507
                 ? $comment : null;
509 508
             $this->archive->setArchiveComment(
510
-                $comment . $options[PCLZIP_OPT_ADD_COMMENT]);
509
+                $comment.$options[PCLZIP_OPT_ADD_COMMENT]);
511 510
         }
512 511
         if (isset($options[PCLZIP_OPT_PREPEND_COMMENT])) {
513 512
             $comment =
514 513
             ($comment = $this->archive->getArchiveComment() !== false)
515 514
                 ? $comment : null;
516 515
             $this->archive->setArchiveComment(
517
-                $options[PCLZIP_OPT_PREPEND_COMMENT] . $comment);
516
+                $options[PCLZIP_OPT_PREPEND_COMMENT].$comment);
518 517
         }
519 518
 
520 519
 
@@ -550,13 +549,13 @@  discard block
 block discarded – undo
550 549
         $report = array();
551 550
         $options = func_get_args();
552 551
         $options = array_combine(
553
-            array_filter($options, function ($v) {return (bool) $v&2;}),
554
-            array_filter($options, function ($v) {return (bool) ($v-1)&2;})
552
+            array_filter($options, function($v) {return (bool) $v & 2; }),
553
+            array_filter($options, function($v) {return (bool) ($v - 1) & 2; })
555 554
         );
556 555
 
557 556
         // exact matching
558 557
         if (isset($options[PCLZIP_OPT_BY_NAME]))
559
-            $selectFilter = function ($key, $value) use ($options) {
558
+            $selectFilter = function($key, $value) use ($options) {
560 559
                 $allowedNames = is_array($options[PCLZIP_OPT_BY_NAME])
561 560
                     ? $options[PCLZIP_OPT_BY_NAME]
562 561
                     : explode(',', $options[PCLZIP_OPT_BY_NAME]);
@@ -581,21 +580,21 @@  discard block
 block discarded – undo
581 580
             };
582 581
         // <ereg> rule
583 582
         else if (isset($options[PCLZIP_OPT_BY_EREG]) && function_exists('ereg'))
584
-            $selectFilter = function ($key, $value) use ($options) {
583
+            $selectFilter = function($key, $value) use ($options) {
585 584
                 return (ereg($options[PCLZIP_OPT_BY_EREG], $key) !== false)
586 585
                 ? self::SELECT_FILTER_PASS
587 586
                 : self::SELECT_FILTER_REFUSE;
588 587
             };
589 588
         // <preg_match> rule
590 589
         else if (isset($options[PCLZIP_OPT_BY_PREG]))
591
-            $selectFilter = function ($key, $value) use ($options) {
590
+            $selectFilter = function($key, $value) use ($options) {
592 591
                 return preg_match($options[PCLZIP_OPT_BY_PREG], $key)
593 592
                 ? self::SELECT_FILTER_PASS
594 593
                 : self::SELECT_FILTER_REFUSE;
595 594
             };
596 595
         // index rule
597 596
         else if (isset($options[PCLZIP_OPT_BY_INDEX]))
598
-            $selectFilter = function ($key, $value, $index) use ($options) {
597
+            $selectFilter = function($key, $value, $index) use ($options) {
599 598
                 $allowedIndexes = array();
600 599
                 foreach ($options[PCLZIP_OPT_BY_INDEX] as $rule) {
601 600
                     $parts = explode('-', $rule);
@@ -610,7 +609,7 @@  discard block
 block discarded – undo
610 609
             };
611 610
         // no rule
612 611
         else
613
-            $selectFilter = function () { return self::SELECT_FILTER_PASS; };
612
+            $selectFilter = function() { return self::SELECT_FILTER_PASS; };
614 613
 
615 614
         foreach ($this->listContent() as $file_header) {
616 615
             // select by select rule
@@ -690,7 +689,7 @@  discard block
 block discarded – undo
690 689
             }
691 690
         }
692 691
 
693
-        call_user_func(function ($directory) {
692
+        call_user_func(function($directory) {
694 693
             foreach (glob($directory.'/*') as $f) {
695 694
                 if (is_dir($f)) call_user_func(__FUNCTION__, $f);
696 695
                 else unlink($f);
Please login to merge, or discard this patch.
Braces   +173 added lines, -96 removed lines patch added patch discarded remove patch
@@ -42,8 +42,11 @@  discard block
 block discarded – undo
42 42
      */
43 43
     public function create($content)
44 44
     {
45
-        if (is_array($content)) $paths_list = $content;
46
-        else $paths_list = array_map(explode(',', $content));
45
+        if (is_array($content)) {
46
+         $paths_list = $content;
47
+        } else {
48
+         $paths_list = array_map(explode(',', $content));
49
+        }
47 50
         $report = array();
48 51
 
49 52
         $options = func_get_args();
@@ -65,29 +68,41 @@  discard block
 block discarded – undo
65 68
         // filters initiation
66 69
         $filters = array();
67 70
         if (isset($options[PCLZIP_OPT_REMOVE_PATH])
68
-            && !isset($options[PCLZIP_OPT_REMOVE_ALL_PATH]))
69
-            $filters[] = function (&$key, &$value) use ($options) {
70
-                $key = str_replace($key, null, $key); };
71
-        if (isset($options[PCLZIP_OPT_REMOVE_ALL_PATH]))
72
-            $filters[] = function (&$key, &$value) { $key = basename($key); };
73
-        if (isset($options[PCLZIP_OPT_ADD_PATH]))
74
-            $filters[] = function (&$key, &$value) use ($options) {
71
+            && !isset($options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
72
+                    $filters[] = function (&$key, &$value) use ($options) {
73
+                $key = str_replace($key, null, $key);
74
+        }
75
+        };
76
+        if (isset($options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
77
+                    $filters[] = function (&$key, &$value) { $key = basename($key);
78
+        }
79
+        };
80
+        if (isset($options[PCLZIP_OPT_ADD_PATH])) {
81
+                    $filters[] = function (&$key, &$value) use ($options) {
75 82
                 $key = rtrim($options[PCLZIP_OPT_ADD_PATH], '/').'/'.
76 83
                 ltrim($key, '/');
84
+        }
77 85
             };
78 86
 
79 87
         if (isset($options[PCLZIP_CB_PRE_ADD])
80
-            && is_callable($options[PCLZIP_CB_PRE_ADD]))
81
-            $preAddCallback = $options[PCLZIP_CB_PRE_ADD];
82
-        else $preAddCallback = function () { return 1; };
88
+            && is_callable($options[PCLZIP_CB_PRE_ADD])) {
89
+                    $preAddCallback = $options[PCLZIP_CB_PRE_ADD];
90
+        } else {
91
+         $preAddCallback = function () { return 1;
92
+        }
93
+        };
83 94
 
84 95
         if (isset($options[PCLZIP_CB_POST_ADD])
85
-            && is_callable($options[PCLZIP_CB_POST_ADD]))
86
-            $postAddCallback = $options[PCLZIP_CB_POST_ADD];
87
-        else $postAddCallback = function () { return 1; };
96
+            && is_callable($options[PCLZIP_CB_POST_ADD])) {
97
+                    $postAddCallback = $options[PCLZIP_CB_POST_ADD];
98
+        } else {
99
+         $postAddCallback = function () { return 1;
100
+        }
101
+        };
88 102
 
89
-        if (isset($options[PCLZIP_OPT_COMMENT]))
90
-            $this->archive->setArchiveComment($options[PCLZIP_OPT_COMMENT]);
103
+        if (isset($options[PCLZIP_OPT_COMMENT])) {
104
+                    $this->archive->setArchiveComment($options[PCLZIP_OPT_COMMENT]);
105
+        }
91 106
 
92 107
         // scan filesystem for files list
93 108
         $files_list = array();
@@ -118,20 +133,23 @@  discard block
 block discarded – undo
118 133
             // apply filters to a file
119 134
             $localname = $file_to_add;
120 135
             $filename = $file_to_add;
121
-            foreach ($filters as $filter)
122
-                call_user_func($filter, $localname, $filename);
136
+            foreach ($filters as $filter) {
137
+                            call_user_func($filter, $localname, $filename);
138
+            }
123 139
             $file_header = $this->createFileHeader($localname, $filename);
124 140
             if (call_user_func($preAddCallback, $file_header) == 1) {
125 141
                 //
126 142
                 // Check for max length > 255
127 143
                 //
128
-                if (strlen(basename($file_header->stored_filename)) > 255)
129
-                    $file_header->status = 'filename_too_long';
130
-                if (is_file($filename))
131
-                    $this->archive->addFile($file_header->filename,
144
+                if (strlen(basename($file_header->stored_filename)) > 255) {
145
+                                    $file_header->status = 'filename_too_long';
146
+                }
147
+                if (is_file($filename)) {
148
+                                    $this->archive->addFile($file_header->filename,
132 149
                         $file_header->stored_filename);
133
-                else if (is_dir($filename))
134
-                    $this->archive->addEmptyDir($file_header->stored_filename);
150
+                } else if (is_dir($filename)) {
151
+                                    $this->archive->addEmptyDir($file_header->stored_filename);
152
+                }
135 153
             } else {
136 154
                 //
137 155
                 // File was skipped
@@ -195,40 +213,53 @@  discard block
 block discarded – undo
195 213
         }
196 214
 
197 215
         // filters initiation
198
-        if (isset($options[PCLZIP_OPT_PATH]))
199
-            $extractPath = rtrim($options[PCLZIP_OPT_PATH], '/');
200
-        else $extractPath = rtrim(getcwd(), '/');
216
+        if (isset($options[PCLZIP_OPT_PATH])) {
217
+                    $extractPath = rtrim($options[PCLZIP_OPT_PATH], '/');
218
+        } else {
219
+         $extractPath = rtrim(getcwd(), '/');
220
+        }
201 221
 
202 222
         $filters = array();
203 223
         if (isset($options[PCLZIP_OPT_REMOVE_PATH])
204
-            && !isset($options[PCLZIP_OPT_REMOVE_ALL_PATH]))
205
-            $filters[] = function (&$key, &$value) use ($options) {
224
+            && !isset($options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
225
+                    $filters[] = function (&$key, &$value) use ($options) {
206 226
              $key = str_replace($key, null, $key);
227
+        }
207 228
          };
208
-        if (isset($options[PCLZIP_OPT_REMOVE_ALL_PATH]))
209
-            $filters[] = function (&$key, &$value) { $key = basename($key); };
210
-        if (isset($options[PCLZIP_OPT_ADD_PATH]))
211
-            $filters[] = function (&$key, &$value) use ($options) {
229
+        if (isset($options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
230
+                    $filters[] = function (&$key, &$value) { $key = basename($key);
231
+        }
232
+        };
233
+        if (isset($options[PCLZIP_OPT_ADD_PATH])) {
234
+                    $filters[] = function (&$key, &$value) use ($options) {
212 235
              $key = rtrim($options[PCLZIP_OPT_ADD_PATH], '/').'/'.
213 236
                 ltrim($key, '/');
237
+        }
214 238
         };
215 239
 
216 240
         if (isset($options[PCLZIP_CB_PRE_EXTRACT])
217
-            && is_callable($options[PCLZIP_CB_PRE_EXTRACT]))
218
-            $preExtractCallback = $options[PCLZIP_CB_PRE_EXTRACT];
219
-        else $preExtractCallback = function () { return 1; };
241
+            && is_callable($options[PCLZIP_CB_PRE_EXTRACT])) {
242
+                    $preExtractCallback = $options[PCLZIP_CB_PRE_EXTRACT];
243
+        } else {
244
+         $preExtractCallback = function () { return 1;
245
+        }
246
+        };
220 247
 
221 248
         if (isset($options[PCLZIP_CB_POST_EXTRACT])
222
-            && is_callable($options[PCLZIP_CB_POST_EXTRACT]))
223
-            $postExtractCallback = $options[PCLZIP_CB_POST_EXTRACT];
224
-        else $postExtractCallback = function () { return 1; };
249
+            && is_callable($options[PCLZIP_CB_POST_EXTRACT])) {
250
+                    $postExtractCallback = $options[PCLZIP_CB_POST_EXTRACT];
251
+        } else {
252
+         $postExtractCallback = function () { return 1;
253
+        }
254
+        };
225 255
 
226 256
         // exact matching
227
-        if (isset($options[PCLZIP_OPT_BY_NAME]))
228
-            $selectFilter = function ($key, $value) use ($options) {
257
+        if (isset($options[PCLZIP_OPT_BY_NAME])) {
258
+                    $selectFilter = function ($key, $value) use ($options) {
229 259
             $allowedNames = is_array($options[PCLZIP_OPT_BY_NAME])
230 260
                 ? $options[PCLZIP_OPT_BY_NAME]
231 261
                 : explode(',', $options[PCLZIP_OPT_BY_NAME]);
262
+        }
232 263
             foreach ($allowedNames as $name) {
233 264
                 // select directory with nested files
234 265
                 if (in_array(substr($name, -1), array('/', '\\'))) {
@@ -249,50 +280,64 @@  discard block
 block discarded – undo
249 280
             return self::SELECT_FILTER_REFUSE;
250 281
         };
251 282
         // <ereg> rule
252
-        else if (isset($options[PCLZIP_OPT_BY_EREG]) && function_exists('ereg'))
253
-            $selectFilter = function ($key, $value) use ($options) {
283
+        else if (isset($options[PCLZIP_OPT_BY_EREG]) && function_exists('ereg')) {
284
+                    $selectFilter = function ($key, $value) use ($options) {
254 285
                 return (ereg($options[PCLZIP_OPT_BY_EREG], $key) !== false)
255 286
                     ? self::SELECT_FILTER_PASS
256 287
                     : self::SELECT_FILTER_REFUSE;
288
+        }
257 289
             };
258 290
         // <preg_match> rule
259
-        else if (isset($options[PCLZIP_OPT_BY_PREG]))
260
-            $selectFilter = function ($key, $value) use ($options) {
291
+        else if (isset($options[PCLZIP_OPT_BY_PREG])) {
292
+                    $selectFilter = function ($key, $value) use ($options) {
261 293
                 return preg_match($options[PCLZIP_OPT_BY_PREG], $key)
262 294
                     ? self::SELECT_FILTER_PASS
263 295
                     : self::SELECT_FILTER_REFUSE;
296
+        }
264 297
             };
265 298
         // index rule
266
-        else if (isset($options[PCLZIP_OPT_BY_INDEX]))
267
-            $selectFilter = function ($key, $value, $index) use ($options) {
299
+        else if (isset($options[PCLZIP_OPT_BY_INDEX])) {
300
+                    $selectFilter = function ($key, $value, $index) use ($options) {
268 301
                 $allowedIndexes = array();
302
+        }
269 303
                 foreach ($options[PCLZIP_OPT_BY_INDEX] as $rule) {
270 304
                     $parts = explode('-', $rule);
271
-                    if (count($parts) == 1) $allowedIndexes[] = $rule;
272
-                    else $allowedIndexes = array_merge(
305
+                    if (count($parts) == 1) {
306
+                     $allowedIndexes[] = $rule;
307
+                    } else {
308
+                     $allowedIndexes = array_merge(
273 309
                         range($parts[0], $parts[1]), $allowedIndexes);
310
+                    }
274 311
                 }
275 312
 
276 313
             return in_array($index, $allowedIndexes) ? self::SELECT_FILTER_PASS
277 314
                 : self::SELECT_FILTER_REFUSE;
278 315
         };
279 316
         // no rule
280
-        else
281
-            $selectFilter = function () { return self::SELECT_FILTER_PASS; };
317
+        else {
318
+                    $selectFilter = function () { return self::SELECT_FILTER_PASS;
319
+        }
320
+        };
282 321
 
283
-        if (isset($options[PCLZIP_OPT_EXTRACT_AS_STRING]))
284
-            $anotherOutputFormat = PCLZIP_OPT_EXTRACT_AS_STRING;
285
-        else if (isset($options[PCLZIP_OPT_EXTRACT_IN_OUTPUT]))
286
-            $anotherOutputFormat = PCLZIP_OPT_EXTRACT_IN_OUTPUT;
287
-        else $anotherOutputFormat = false;
322
+        if (isset($options[PCLZIP_OPT_EXTRACT_AS_STRING])) {
323
+                    $anotherOutputFormat = PCLZIP_OPT_EXTRACT_AS_STRING;
324
+        } else if (isset($options[PCLZIP_OPT_EXTRACT_IN_OUTPUT])) {
325
+                    $anotherOutputFormat = PCLZIP_OPT_EXTRACT_IN_OUTPUT;
326
+        } else {
327
+         $anotherOutputFormat = false;
328
+        }
288 329
 
289
-        if (isset($options[PCLZIP_OPT_REPLACE_NEWER]))
290
-            $doNotReplaceNewer = false;
291
-        else $doNotReplaceNewer = true;
330
+        if (isset($options[PCLZIP_OPT_REPLACE_NEWER])) {
331
+                    $doNotReplaceNewer = false;
332
+        } else {
333
+         $doNotReplaceNewer = true;
334
+        }
292 335
 
293
-        if (isset($options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION]))
294
-            $restrictExtractDir = $options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION];
295
-        else $restrictExtractDir = false;
336
+        if (isset($options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION])) {
337
+                    $restrictExtractDir = $options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION];
338
+        } else {
339
+         $restrictExtractDir = false;
340
+        }
296 341
 
297 342
         $report = array();
298 343
         foreach ($this->listContent() as $file_header) {
@@ -362,8 +407,10 @@  discard block
 block discarded – undo
362 407
             // extract content
363 408
             else if ($anotherOutputFormat === false) {
364 409
                 // apply path filters
365
-                foreach ($filters as $filter) call_user_func($filter,
410
+                foreach ($filters as $filter) {
411
+                 call_user_func($filter,
366 412
                     $file_header->stored_filename, $file_header->filename);
413
+                }
367 414
                 // dir extraction process
368 415
                 if ($file_header->folder) {
369 416
                     // if dir doesn't exist
@@ -455,8 +502,11 @@  discard block
 block discarded – undo
455 502
      */
456 503
     public function add($content)
457 504
     {
458
-        if (is_array($content)) $paths_list = $content;
459
-        else $paths_list = array_map(explode(',', $content));
505
+        if (is_array($content)) {
506
+         $paths_list = $content;
507
+        } else {
508
+         $paths_list = array_map(explode(',', $content));
509
+        }
460 510
         $report = array();
461 511
 
462 512
         $options = func_get_args();
@@ -478,30 +528,41 @@  discard block
 block discarded – undo
478 528
         // filters initiation
479 529
         $filters = array();
480 530
         if (isset($options[PCLZIP_OPT_REMOVE_PATH])
481
-            && !isset($options[PCLZIP_OPT_REMOVE_ALL_PATH]))
482
-            $filters[] = function (&$key, &$value) use ($options) {
531
+            && !isset($options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
532
+                    $filters[] = function (&$key, &$value) use ($options) {
483 533
                 $key = str_replace($key, null, $key);
534
+        }
484 535
             };
485
-        if (isset($options[PCLZIP_OPT_REMOVE_ALL_PATH]))
486
-            $filters[] = function (&$key, &$value) { $key = basename($key); };
487
-        if (isset($options[PCLZIP_OPT_ADD_PATH]))
488
-            $filters[] = function (&$key, &$value) use ($options) {
536
+        if (isset($options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
537
+                    $filters[] = function (&$key, &$value) { $key = basename($key);
538
+        }
539
+        };
540
+        if (isset($options[PCLZIP_OPT_ADD_PATH])) {
541
+                    $filters[] = function (&$key, &$value) use ($options) {
489 542
                 $key = rtrim($options[PCLZIP_OPT_ADD_PATH], '/').'/'.
490 543
                 ltrim($key, '/');
544
+        }
491 545
             };
492 546
 
493 547
         if (isset($options[PCLZIP_CB_PRE_ADD])
494
-            && is_callable($options[PCLZIP_CB_PRE_ADD]))
495
-            $preAddCallback = $options[PCLZIP_CB_PRE_ADD];
496
-        else $preAddCallback = function () { return 1; };
548
+            && is_callable($options[PCLZIP_CB_PRE_ADD])) {
549
+                    $preAddCallback = $options[PCLZIP_CB_PRE_ADD];
550
+        } else {
551
+         $preAddCallback = function () { return 1;
552
+        }
553
+        };
497 554
 
498 555
         if (isset($options[PCLZIP_CB_POST_ADD])
499
-            && is_callable($options[PCLZIP_CB_POST_ADD]))
500
-            $postAddCallback = $options[PCLZIP_CB_POST_ADD];
501
-        else $postAddCallback = function () { return 1; };
556
+            && is_callable($options[PCLZIP_CB_POST_ADD])) {
557
+                    $postAddCallback = $options[PCLZIP_CB_POST_ADD];
558
+        } else {
559
+         $postAddCallback = function () { return 1;
560
+        }
561
+        };
502 562
 
503
-        if (isset($options[PCLZIP_OPT_COMMENT]))
504
-            $this->archive->setArchiveComment($options[PCLZIP_OPT_COMMENT]);
563
+        if (isset($options[PCLZIP_OPT_COMMENT])) {
564
+                    $this->archive->setArchiveComment($options[PCLZIP_OPT_COMMENT]);
565
+        }
505 566
         if (isset($options[PCLZIP_OPT_ADD_COMMENT])) {
506 567
             $comment =
507 568
             ($comment = $this->archive->getArchiveComment() !== false)
@@ -555,11 +616,12 @@  discard block
 block discarded – undo
555 616
         );
556 617
 
557 618
         // exact matching
558
-        if (isset($options[PCLZIP_OPT_BY_NAME]))
559
-            $selectFilter = function ($key, $value) use ($options) {
619
+        if (isset($options[PCLZIP_OPT_BY_NAME])) {
620
+                    $selectFilter = function ($key, $value) use ($options) {
560 621
                 $allowedNames = is_array($options[PCLZIP_OPT_BY_NAME])
561 622
                     ? $options[PCLZIP_OPT_BY_NAME]
562 623
                     : explode(',', $options[PCLZIP_OPT_BY_NAME]);
624
+        }
563 625
                 foreach ($allowedNames as $name) {
564 626
                     // select directory with nested files
565 627
                     if (in_array(substr($name, -1), array('/', '\\'))) {
@@ -580,28 +642,34 @@  discard block
 block discarded – undo
580 642
                 return self::SELECT_FILTER_REFUSE;
581 643
             };
582 644
         // <ereg> rule
583
-        else if (isset($options[PCLZIP_OPT_BY_EREG]) && function_exists('ereg'))
584
-            $selectFilter = function ($key, $value) use ($options) {
645
+        else if (isset($options[PCLZIP_OPT_BY_EREG]) && function_exists('ereg')) {
646
+                    $selectFilter = function ($key, $value) use ($options) {
585 647
                 return (ereg($options[PCLZIP_OPT_BY_EREG], $key) !== false)
586 648
                 ? self::SELECT_FILTER_PASS
587 649
                 : self::SELECT_FILTER_REFUSE;
650
+        }
588 651
             };
589 652
         // <preg_match> rule
590
-        else if (isset($options[PCLZIP_OPT_BY_PREG]))
591
-            $selectFilter = function ($key, $value) use ($options) {
653
+        else if (isset($options[PCLZIP_OPT_BY_PREG])) {
654
+                    $selectFilter = function ($key, $value) use ($options) {
592 655
                 return preg_match($options[PCLZIP_OPT_BY_PREG], $key)
593 656
                 ? self::SELECT_FILTER_PASS
594 657
                 : self::SELECT_FILTER_REFUSE;
658
+        }
595 659
             };
596 660
         // index rule
597
-        else if (isset($options[PCLZIP_OPT_BY_INDEX]))
598
-            $selectFilter = function ($key, $value, $index) use ($options) {
661
+        else if (isset($options[PCLZIP_OPT_BY_INDEX])) {
662
+                    $selectFilter = function ($key, $value, $index) use ($options) {
599 663
                 $allowedIndexes = array();
664
+        }
600 665
                 foreach ($options[PCLZIP_OPT_BY_INDEX] as $rule) {
601 666
                     $parts = explode('-', $rule);
602
-                    if (count($parts) == 1) $allowedIndexes[] = $rule;
603
-                    else $allowedIndexes = array_merge(
667
+                    if (count($parts) == 1) {
668
+                     $allowedIndexes[] = $rule;
669
+                    } else {
670
+                     $allowedIndexes = array_merge(
604 671
                         range($parts[0], $parts[1]), $allowedIndexes);
672
+                    }
605 673
                 }
606 674
 
607 675
                 return in_array($index, $allowedIndexes)
@@ -609,8 +677,10 @@  discard block
 block discarded – undo
609 677
                 : self::SELECT_FILTER_REFUSE;
610 678
             };
611 679
         // no rule
612
-        else
613
-            $selectFilter = function () { return self::SELECT_FILTER_PASS; };
680
+        else {
681
+                    $selectFilter = function () { return self::SELECT_FILTER_PASS;
682
+        }
683
+        };
614 684
 
615 685
         foreach ($this->listContent() as $file_header) {
616 686
             // select by select rule
@@ -662,8 +732,12 @@  discard block
 block discarded – undo
662 732
         }
663 733
 
664 734
         $tempDir = tempnam(PCLZIP_TEMPORARY_DIR, 'merging');
665
-        if (file_exists($tempDir)) unlink($tempDir);
666
-        if (!mkdir($tempDir)) return 0;
735
+        if (file_exists($tempDir)) {
736
+         unlink($tempDir);
737
+        }
738
+        if (!mkdir($tempDir)) {
739
+         return 0;
740
+        }
667 741
 
668 742
         // go through archive content list and copy all files
669 743
         foreach ($a->getFileNames() as $filename) {
@@ -692,8 +766,11 @@  discard block
 block discarded – undo
692 766
 
693 767
         call_user_func(function ($directory) {
694 768
             foreach (glob($directory.'/*') as $f) {
695
-                if (is_dir($f)) call_user_func(__FUNCTION__, $f);
696
-                else unlink($f);
769
+                if (is_dir($f)) {
770
+                 call_user_func(__FUNCTION__, $f);
771
+                } else {
772
+                 unlink($f);
773
+                }
697 774
             }
698 775
         }, $tempDir);
699 776
 
Please login to merge, or discard this patch.
src/LzwStreamWrapper.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@
 block discarded – undo
17 17
     private static $AVERAGE_COMPRESSION_RATIO = 2;
18 18
     public static $forceTmpFile = false;
19 19
     /** High limit. unit: MBytes.
20
-    */
20
+     */
21 21
     public static $highLimit = 512;
22 22
 
23 23
     private $mode;
Please login to merge, or discard this patch.
Braces   +29 added lines, -19 removed lines patch added patch discarded remove patch
@@ -8,8 +8,9 @@  discard block
 block discarded – undo
8 8
 
9 9
     public static function registerWrapper()
10 10
     {
11
-        if (!self::$registered)
12
-            stream_wrapper_register('compress.lzw', __CLASS__);
11
+        if (!self::$registered) {
12
+                    stream_wrapper_register('compress.lzw', __CLASS__);
13
+        }
13 14
         self::$registered = true;
14 15
     }
15 16
 
@@ -40,12 +41,14 @@  discard block
 block discarded – undo
40 41
     {
41 42
         // check for compress & uncompress utility
42 43
         $this->checkBinary();
43
-        if (self::$installed === false)
44
-            throw new \Exception('compress and uncompress commands are required');
44
+        if (self::$installed === false) {
45
+                    throw new \Exception('compress and uncompress commands are required');
46
+        }
45 47
 
46 48
         $schema = 'compress.lzw://';
47
-        if (strncasecmp($schema, $path, strlen($schema)) == 0)
48
-            $path = substr($path, strlen($schema));
49
+        if (strncasecmp($schema, $path, strlen($schema)) == 0) {
50
+                    $path = substr($path, strlen($schema));
51
+        }
49 52
 
50 53
         if (file_exists($path)) {
51 54
             $this->path = realpath($path);
@@ -59,14 +62,16 @@  discard block
 block discarded – undo
59 62
                 $this->read();
60 63
             } else {
61 64
                 $prefix = basename(__FILE__, '.php');
62
-                if (($tmp = tempnam(sys_get_temp_dir(), $prefix)) === false)
63
-                    throw new \Exception(__CLASS__.', line '.__LINE__.
65
+                if (($tmp = tempnam(sys_get_temp_dir(), $prefix)) === false) {
66
+                                    throw new \Exception(__CLASS__.', line '.__LINE__.
64 67
                         ': Could not create temporary file in '.
65 68
                         sys_get_temp_dir());
66
-                if (($tmp2 = tempnam(sys_get_temp_dir(), $prefix)) === false)
67
-                    throw new \Exception(__CLASS__.', line '.__LINE__.
69
+                }
70
+                if (($tmp2 = tempnam(sys_get_temp_dir(), $prefix)) === false) {
71
+                                    throw new \Exception(__CLASS__.', line '.__LINE__.
68 72
                         ': Could not create temporary file in '.
69 73
                         sys_get_temp_dir());
74
+                }
70 75
                 $this->tmp = $tmp;
71 76
                 $this->tmp2 = $tmp2;
72 77
                 $this->read();
@@ -75,14 +80,16 @@  discard block
 block discarded – undo
75 80
             $this->path = $path;
76 81
             if (self::$forceTmpFile) {
77 82
                 $prefix = basename(__FILE__, '.php');
78
-                if (($tmp = tempnam(sys_get_temp_dir(), $prefix)) === false)
79
-                    throw new \Exception(__CLASS__.', line '.__LINE__.
83
+                if (($tmp = tempnam(sys_get_temp_dir(), $prefix)) === false) {
84
+                                    throw new \Exception(__CLASS__.', line '.__LINE__.
80 85
                         ': Could not create temporary file in '.
81 86
                         sys_get_temp_dir());
82
-                if (($tmp2 = tempnam(sys_get_temp_dir(), $prefix)) === false)
83
-                    throw new \Exception(__CLASS__.', line '.__LINE__.
87
+                }
88
+                if (($tmp2 = tempnam(sys_get_temp_dir(), $prefix)) === false) {
89
+                                    throw new \Exception(__CLASS__.', line '.__LINE__.
84 90
                         ': Could not create temporary file in '.
85 91
                         sys_get_temp_dir());
92
+                }
86 93
                 $this->tmp = $tmp;
87 94
                 $this->tmp2 = $tmp2;
88 95
                 $this->pointer = 0;
@@ -263,7 +270,9 @@  discard block
 block discarded – undo
263 270
         }
264 271
         if ($this->tmp !== null) {
265 272
             unlink($this->tmp);
266
-            if (file_exists($this->tmp2)) unlink($this->tmp2);
273
+            if (file_exists($this->tmp2)) {
274
+             unlink($this->tmp2);
275
+            }
267 276
         } else {
268 277
             $this->data = null;
269 278
         }
@@ -407,10 +416,11 @@  discard block
 block discarded – undo
407 416
                 self::$installed = false;
408 417
             } else {
409 418
                 self::exec('command -v uncompress', $output);
410
-                if (empty($output))
411
-                    self::$installed = false;
412
-                else
413
-                    self::$installed = true;
419
+                if (empty($output)) {
420
+                                    self::$installed = false;
421
+                } else {
422
+                                    self::$installed = true;
423
+                }
414 424
             }
415 425
         }
416 426
     }
Please login to merge, or discard this patch.
src/function.gzip_stat.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@
 block discarded – undo
7 7
 {
8 8
     $fp = fopen($file, 'rb');
9 9
     if (filesize($file) < 18 || strcmp(fread($fp, 2), "\x1f\x8b")) {
10
-        return false;  // Not GZIP format (See RFC 1952)
10
+        return false; // Not GZIP format (See RFC 1952)
11 11
     }
12 12
     $method = fread($fp, 1);
13 13
     $flags = fread($fp, 1);
Please login to merge, or discard this patch.
src/UnifiedArchive.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -310,14 +310,14 @@  discard block
 block discarded – undo
310 310
                             if (in_array($file->strd_FileId, ['.', '..']))
311 311
                                 continue;
312 312
                             $this->files[$file->Location]
313
-                                = $directory . $file->strd_FileId;
313
+                                = $directory.$file->strd_FileId;
314 314
                             $size += $file->DataLen;
315 315
 
316
-                            $this->isoFilesData[$directory . $file->strd_FileId] =
316
+                            $this->isoFilesData[$directory.$file->strd_FileId] =
317 317
                                 [
318 318
                                     'size' => $file->DataLen,
319 319
                                     'mtime' =>
320
-                                        strtotime((string)$file->isoRecDate),
320
+                                        strtotime((string) $file->isoRecDate),
321 321
                                 ];
322 322
                         }
323 323
                     }
@@ -906,8 +906,8 @@  discard block
 block discarded – undo
906 906
                 $this->files = [];
907 907
                 foreach ($this->seven_zip->getEntries() as $entry) {
908 908
                     $this->files[] = $entry->getPath();
909
-                    $this->compressedFilesSize += (int)$entry->getPackedSize();
910
-                    $this->uncompressedFilesSize += (int)$entry->getSize();
909
+                    $this->compressedFilesSize += (int) $entry->getPackedSize();
910
+                    $this->uncompressedFilesSize += (int) $entry->getSize();
911 911
                 }
912 912
                 $this->seven_zip->numFiles = count($this->files);
913 913
                 break;
Please login to merge, or discard this patch.
Braces   +150 added lines, -85 removed lines patch added patch discarded remove patch
@@ -86,8 +86,9 @@  discard block
 block discarded – undo
86 86
     {
87 87
         self::checkRequirements();
88 88
 
89
-        if (!file_exists($fileName) || !is_readable($fileName))
90
-            throw new Exception('Could not open file: '.$fileName);
89
+        if (!file_exists($fileName) || !is_readable($fileName)) {
90
+                    throw new Exception('Could not open file: '.$fileName);
91
+        }
91 92
 
92 93
         $type = self::detectArchiveType($fileName);
93 94
         if (!self::canOpenType($type, true)) {
@@ -194,8 +195,9 @@  discard block
 block discarded – undo
194 195
                     return self::CAB;
195 196
             }
196 197
 
197
-            if ($type = TarArchive::detectArchiveType($fileName))
198
-                return $type;
198
+            if ($type = TarArchive::detectArchiveType($fileName)) {
199
+                            return $type;
200
+            }
199 201
         }
200 202
 
201 203
         return false;
@@ -289,8 +291,9 @@  discard block
 block discarded – undo
289 291
 
290 292
                 $usedDesc =
291 293
                     $this->iso->GetDescriptor(SUPPLEMENTARY_VOLUME_DESC);
292
-                if (!$usedDesc)
293
-                    $usedDesc = $this->iso->GetDescriptor(PRIMARY_VOLUME_DESC);
294
+                if (!$usedDesc) {
295
+                                    $usedDesc = $this->iso->GetDescriptor(PRIMARY_VOLUME_DESC);
296
+                }
294 297
                 $this->isoBlockSize = $usedDesc->iBlockSize;
295 298
                 $directories = $usedDesc->LoadMPathTable($this->iso);
296 299
                 foreach ($directories as $Directory) {
@@ -307,8 +310,9 @@  discard block
 block discarded – undo
307 310
                         $usedDesc->iBlockSize, true);
308 311
                     if ($files) {
309 312
                         foreach ($files as $file) {
310
-                            if (in_array($file->strd_FileId, ['.', '..']))
311
-                                continue;
313
+                            if (in_array($file->strd_FileId, ['.', '..'])) {
314
+                                                            continue;
315
+                            }
312 316
                             $this->files[$file->Location]
313 317
                                 = $directory . $file->strd_FileId;
314 318
                             $size += $file->DataLen;
@@ -485,8 +489,9 @@  discard block
 block discarded – undo
485 489
      */
486 490
     public function getFileData($fileName)
487 491
     {
488
-        if (!in_array($fileName, $this->files, true))
489
-            return false;
492
+        if (!in_array($fileName, $this->files, true)) {
493
+                    return false;
494
+        }
490 495
 
491 496
         switch ($this->type) {
492 497
             case self::ZIP:
@@ -517,8 +522,9 @@  discard block
 block discarded – undo
517 522
                     true);
518 523
 
519 524
             case self::ISO:
520
-                if (!isset($this->isoFilesData[$fileName]))
521
-                    return false;
525
+                if (!isset($this->isoFilesData[$fileName])) {
526
+                                    return false;
527
+                }
522 528
                 $data = $this->isoFilesData[$fileName];
523 529
 
524 530
                 return new ArchiveEntry($fileName, $data['size'], $data['size'], $data['mtime'], false);
@@ -544,8 +550,9 @@  discard block
 block discarded – undo
544 550
      */
545 551
     public function getFileContent($fileName)
546 552
     {
547
-        if (!in_array($fileName, $this->files, true))
548
-            return false;
553
+        if (!in_array($fileName, $this->files, true)) {
554
+                    return false;
555
+        }
549 556
 
550 557
         switch ($this->type) {
551 558
             case self::ZIP:
@@ -560,7 +567,9 @@  discard block
 block discarded – undo
560 567
 
561 568
             case self::RAR:
562 569
                 $entry = $this->rar->getEntry($fileName);
563
-                if ($entry->isDirectory()) return false;
570
+                if ($entry->isDirectory()) {
571
+                 return false;
572
+                }
564 573
                 return stream_get_contents($entry->getStream());
565 574
 
566 575
             case self::GZIP:
@@ -574,11 +583,14 @@  discard block
 block discarded – undo
574 583
 
575 584
             case self::ISO:
576 585
                 $Location = array_search($fileName, $this->files, true);
577
-                if (!isset($this->isoFilesData[$fileName])) return false;
586
+                if (!isset($this->isoFilesData[$fileName])) {
587
+                 return false;
588
+                }
578 589
                 $data = $this->isoFilesData[$fileName];
579 590
                 $Location_Real = $Location * $this->isoBlockSize;
580
-                if ($this->iso->Seek($Location_Real, SEEK_SET) === false)
581
-                    return false;
591
+                if ($this->iso->Seek($Location_Real, SEEK_SET) === false) {
592
+                                    return false;
593
+                }
582 594
 
583 595
                 return $this->iso->Read($data['size']);
584 596
 
@@ -598,8 +610,9 @@  discard block
 block discarded – undo
598 610
      */
599 611
     public function getFileResource($fileName)
600 612
     {
601
-        if (!in_array($fileName, $this->files, true))
602
-            return false;
613
+        if (!in_array($fileName, $this->files, true)) {
614
+                    return false;
615
+        }
603 616
 
604 617
         switch ($this->type) {
605 618
             case self::ZIP:
@@ -615,7 +628,9 @@  discard block
 block discarded – undo
615 628
 
616 629
             case self::RAR:
617 630
                 $entry = $this->rar->getEntry($fileName);
618
-                if ($entry->isDirectory()) return false;
631
+                if ($entry->isDirectory()) {
632
+                 return false;
633
+                }
619 634
                 return $entry->getStream();
620 635
 
621 636
             case self::GZIP:
@@ -629,11 +644,14 @@  discard block
 block discarded – undo
629 644
 
630 645
             case self::ISO:
631 646
                 $Location = array_search($fileName, $this->files, true);
632
-                if (!isset($this->isoFilesData[$fileName])) return false;
647
+                if (!isset($this->isoFilesData[$fileName])) {
648
+                 return false;
649
+                }
633 650
                 $data = $this->isoFilesData[$fileName];
634 651
                 $Location_Real = $Location * $this->isoBlockSize;
635
-                if ($this->iso->Seek($Location_Real, SEEK_SET) === false)
636
-                    return false;
652
+                if ($this->iso->Seek($Location_Real, SEEK_SET) === false) {
653
+                                    return false;
654
+                }
637 655
 
638 656
                 $resource = fopen('php://temp', 'r+');
639 657
                 fwrite($resource, $this->iso->Read($data['size']));
@@ -659,8 +677,9 @@  discard block
 block discarded – undo
659 677
     {
660 678
         $tree = array(DIRECTORY_SEPARATOR);
661 679
         foreach ($this->files as $filename) {
662
-            if (in_array(substr($filename, -1), array('/', '\\')))
663
-                $tree[] = DIRECTORY_SEPARATOR.$filename;
680
+            if (in_array(substr($filename, -1), array('/', '\\'))) {
681
+                            $tree[] = DIRECTORY_SEPARATOR.$filename;
682
+            }
664 683
         }
665 684
 
666 685
         return $tree;
@@ -677,10 +696,13 @@  discard block
 block discarded – undo
677 696
     public function extractFiles($outputFolder, $files = null, $expandFilesList = false)
678 697
     {
679 698
         if ($files !== null) {
680
-            if (is_string($files)) $files = [$files];
699
+            if (is_string($files)) {
700
+             $files = [$files];
701
+            }
681 702
 
682
-            if ($expandFilesList)
683
-                $files = self::expandFileList($this->files, $files);
703
+            if ($expandFilesList) {
704
+                            $files = self::expandFileList($this->files, $files);
705
+            }
684 706
         } else {
685 707
             $files = array_values($this->files);
686 708
         }
@@ -688,19 +710,22 @@  discard block
 block discarded – undo
688 710
         switch ($this->type) {
689 711
             case self::ZIP:
690 712
                 if (count($files) === count($this->files)) {
691
-                    if ($this->zip->extractTo($outputFolder) === false)
692
-                        throw new Exception($this->zip->getStatusString(), $this->zip->status);
713
+                    if ($this->zip->extractTo($outputFolder) === false) {
714
+                                            throw new Exception($this->zip->getStatusString(), $this->zip->status);
715
+                    }
693 716
                     return $this->zip->numFiles;
694 717
                 } else {
695
-                    if ($this->zip->extractTo($outputFolder, $files) === false)
696
-                        throw new Exception($this->zip->getStatusString(), $this->zip->status);
718
+                    if ($this->zip->extractTo($outputFolder, $files) === false) {
719
+                                            throw new Exception($this->zip->getStatusString(), $this->zip->status);
720
+                    }
697 721
 
698 722
                     return count($files);
699 723
                 }
700 724
 
701 725
             case self::SEVEN_ZIP:
702
-                if (!is_dir($outputFolder))
703
-                    mkdir($outputFolder);
726
+                if (!is_dir($outputFolder)) {
727
+                                    mkdir($outputFolder);
728
+                }
704 729
 
705 730
                 $this->seven_zip->setOutputDirectory($outputFolder);
706 731
                 $count = 0;
@@ -710,8 +735,9 @@  discard block
 block discarded – undo
710 735
                         return $this->seven_zip->numFiles;
711 736
                     } else {
712 737
                         foreach ($files as $file) {
713
-                            if ($this->seven_zip->extractEntry($file))
714
-                                $count++;
738
+                            if ($this->seven_zip->extractEntry($file)) {
739
+                                                            $count++;
740
+                            }
715 741
                         }
716 742
                         return $count;
717 743
                     }
@@ -732,28 +758,33 @@  discard block
 block discarded – undo
732 758
             case self::GZIP:
733 759
             case self::BZIP:
734 760
             case self::LZMA:
735
-                if ($files !== null && $files !== $this->files)
736
-                    return 0;
761
+                if ($files !== null && $files !== $this->files) {
762
+                                    return 0;
763
+                }
737 764
 
738 765
                 $dir = rtrim($outputFolder, '/').'/';
739
-                if (!is_dir($dir) && !mkdir($dir))
740
-                    return false;
766
+                if (!is_dir($dir) && !mkdir($dir)) {
767
+                                    return false;
768
+                }
741 769
 
742 770
                 switch ($this->type) {
743 771
                     case self::GZIP:
744 772
                         $data = gzdecode(file_get_contents($this->gzipFilename));
745
-                        if ($data === false)
746
-                            throw new Exception('Could not extract archive');
773
+                        if ($data === false) {
774
+                                                    throw new Exception('Could not extract archive');
775
+                        }
747 776
                         break;
748 777
                     case self::BZIP:
749 778
                         $data = bzdecompress(file_get_contents($this->bzipFilename));
750
-                        if (is_integer($data))
751
-                            throw new Exception('Could not extract archive', $data);
779
+                        if (is_integer($data)) {
780
+                                                    throw new Exception('Could not extract archive', $data);
781
+                        }
752 782
                         break;
753 783
                     case self::LZMA:
754 784
                         $fp = xzopen($this->lzmaFilename, 'r');
755
-                        if ($fp === false)
756
-                            throw new Exception('Could not extract archive');
785
+                        if ($fp === false) {
786
+                                                    throw new Exception('Could not extract archive');
787
+                        }
757 788
                         ob_start();
758 789
                         xzpassthru($fp);
759 790
                         $data = ob_get_flush();
@@ -761,8 +792,9 @@  discard block
 block discarded – undo
761 792
                         break;
762 793
                 }
763 794
 
764
-                if (file_put_contents($dir.$this->files[0], $data) !== false)
765
-                    return 1;
795
+                if (file_put_contents($dir.$this->files[0], $data) !== false) {
796
+                                    return 1;
797
+                }
766 798
 
767 799
                 return false;
768 800
 
@@ -782,12 +814,15 @@  discard block
 block discarded – undo
782 814
      */
783 815
     public function deleteFiles($fileOrFiles, $expandFilesList = false)
784 816
     {
785
-        if ($expandFilesList && $fileOrFiles !== null)
786
-            $fileOrFiles = self::expandFileList($this->files, is_string($fileOrFiles) ? [$fileOrFiles] : $fileOrFiles);
817
+        if ($expandFilesList && $fileOrFiles !== null) {
818
+                    $fileOrFiles = self::expandFileList($this->files, is_string($fileOrFiles) ? [$fileOrFiles] : $fileOrFiles);
819
+        }
787 820
 
788 821
         $files = is_string($fileOrFiles) ? array($fileOrFiles) : $fileOrFiles;
789 822
         foreach ($files as $i => $file) {
790
-            if (!in_array($file, $this->files, true)) unset($files[$i]);
823
+            if (!in_array($file, $this->files, true)) {
824
+             unset($files[$i]);
825
+            }
791 826
         }
792 827
 
793 828
         $count = 0;
@@ -797,8 +832,9 @@  discard block
 block discarded – undo
797 832
                 $count = 0;
798 833
                 foreach ($files as $file) {
799 834
                     $index = array_search($file, $this->files, true);
800
-                    if ($this->zip->deleteIndex($index) === false)
801
-                        throw new Exception($this->zip->getStatusString(), $this->zip->status);
835
+                    if ($this->zip->deleteIndex($index) === false) {
836
+                                            throw new Exception($this->zip->getStatusString(), $this->zip->status);
837
+                    }
802 838
                     $count++;
803 839
                 }
804 840
             break;
@@ -843,11 +879,13 @@  discard block
 block discarded – undo
843 879
             case self::ZIP:
844 880
                 foreach ($files_list as $localname => $filename) {
845 881
                     if (is_null($filename)) {
846
-                        if ($this->zip->addEmptyDir($localname) === false)
847
-                            throw new Exception($this->zip->getStatusString(), $this->zip->status);
882
+                        if ($this->zip->addEmptyDir($localname) === false) {
883
+                                                    throw new Exception($this->zip->getStatusString(), $this->zip->status);
884
+                        }
848 885
                     } else {
849
-                        if ($this->zip->addFile($filename, $localname) === false)
850
-                            throw new Exception($this->zip->getStatusString(), $this->zip->status);
886
+                        if ($this->zip->addFile($filename, $localname) === false) {
887
+                                                    throw new Exception($this->zip->getStatusString(), $this->zip->status);
888
+                        }
851 889
                         $added_files++;
852 890
                     }
853 891
                 }
@@ -924,23 +962,28 @@  discard block
 block discarded – undo
924 962
      */
925 963
     public static function archiveFiles($fileOrFiles, $archiveName, $emulate = false)
926 964
     {
927
-        if (file_exists($archiveName))
928
-            throw new Exception('Archive '.$archiveName.' already exists!');
965
+        if (file_exists($archiveName)) {
966
+                    throw new Exception('Archive '.$archiveName.' already exists!');
967
+        }
929 968
 
930 969
         self::checkRequirements();
931 970
 
932 971
         $atype = self::detectArchiveType($archiveName, false);
933
-        if (in_array($atype, [TarArchive::TAR, TarArchive::TAR_GZIP, TarArchive::TAR_BZIP, TarArchive::TAR_LZMA, TarArchive::TAR_LZW], true))
934
-            return TarArchive::archiveFiles($fileOrFiles, $archiveName, $emulate);
935
-        if ($atype === false)
936
-            return false;
972
+        if (in_array($atype, [TarArchive::TAR, TarArchive::TAR_GZIP, TarArchive::TAR_BZIP, TarArchive::TAR_LZMA, TarArchive::TAR_LZW], true)) {
973
+                    return TarArchive::archiveFiles($fileOrFiles, $archiveName, $emulate);
974
+        }
975
+        if ($atype === false) {
976
+                    return false;
977
+        }
937 978
 
938 979
         $files_list = self::createFilesList($fileOrFiles);
939 980
 
940 981
         // fake creation: return archive data
941 982
         if ($emulate) {
942 983
             $totalSize = 0;
943
-            foreach ($files_list as $fn) $totalSize += filesize($fn);
984
+            foreach ($files_list as $fn) {
985
+             $totalSize += filesize($fn);
986
+            }
944 987
 
945 988
             return array(
946 989
                 'totalSize' => $totalSize,
@@ -954,15 +997,18 @@  discard block
 block discarded – undo
954 997
             case self::ZIP:
955 998
                 $zip = new ZipArchive;
956 999
                 $result = $zip->open($archiveName, ZipArchive::CREATE);
957
-                if ($result !== true)
958
-                    throw new Exception('ZipArchive error: '.$result);
1000
+                if ($result !== true) {
1001
+                                    throw new Exception('ZipArchive error: '.$result);
1002
+                }
959 1003
                 foreach ($files_list as $localname => $filename) {
960 1004
                     if ($filename === null) {
961
-                        if ($zip->addEmptyDir($localname) === false)
962
-                            return false;
1005
+                        if ($zip->addEmptyDir($localname) === false) {
1006
+                                                    return false;
1007
+                        }
963 1008
                     } else {
964
-                        if ($zip->addFile($filename, $localname) === false)
965
-                            return false;
1009
+                        if ($zip->addFile($filename, $localname) === false) {
1010
+                                                    return false;
1011
+                        }
966 1012
                     }
967 1013
                 }
968 1014
                 $zip->close();
@@ -986,34 +1032,52 @@  discard block
 block discarded – undo
986 1032
                 return count($files_list);
987 1033
 
988 1034
             case self::GZIP:
989
-                if (count($files_list) > 1) return false;
1035
+                if (count($files_list) > 1) {
1036
+                 return false;
1037
+                }
990 1038
                 $filename = array_shift($files_list);
991
-                if (is_null($filename)) return false; // invalid list
1039
+                if (is_null($filename)) {
1040
+                 return false;
1041
+                }
1042
+                // invalid list
992 1043
                 if (file_put_contents($archiveName,
993
-                        gzencode(file_get_contents($filename))) !== false)
994
-                    return 1;
1044
+                        gzencode(file_get_contents($filename))) !== false) {
1045
+                                    return 1;
1046
+                }
995 1047
 
996 1048
                 return false;
997 1049
 
998 1050
             case self::BZIP:
999
-                if (count($files_list) > 1) return false;
1051
+                if (count($files_list) > 1) {
1052
+                 return false;
1053
+                }
1000 1054
                 $filename = array_shift($files_list);
1001
-                if (is_null($filename)) return false; // invalid list
1055
+                if (is_null($filename)) {
1056
+                 return false;
1057
+                }
1058
+                // invalid list
1002 1059
                 if (file_put_contents($archiveName,
1003
-                        bzcompress(file_get_contents($filename))) !== false)
1004
-                    return 1;
1060
+                        bzcompress(file_get_contents($filename))) !== false) {
1061
+                                    return 1;
1062
+                }
1005 1063
 
1006 1064
                 return false;
1007 1065
 
1008 1066
             case self::LZMA:
1009
-                if (count($files_list) > 1) return false;
1067
+                if (count($files_list) > 1) {
1068
+                 return false;
1069
+                }
1010 1070
                 $filename = array_shift($files_list);
1011
-                if (is_null($filename)) return false; // invalid list
1071
+                if (is_null($filename)) {
1072
+                 return false;
1073
+                }
1074
+                // invalid list
1012 1075
                 $fp = xzopen($archiveName, 'w');
1013 1076
                 $r = xzwrite($fp, file_get_contents($filename));
1014 1077
                 xzclose($fp);
1015
-                if ($r !== false)
1016
-                    return 1;
1078
+                if ($r !== false) {
1079
+                                    return 1;
1080
+                }
1017 1081
 
1018 1082
                 return false;
1019 1083
 
@@ -1037,8 +1101,9 @@  discard block
 block discarded – undo
1037 1101
             self::$enabledTypes[self::ISO] = class_exists('\CISOFile');
1038 1102
             self::$enabledTypes[self::CAB] = class_exists('\CabArchive');
1039 1103
 
1040
-            if (class_exists('\RarException'))
1041
-                \RarException::setUsingExceptions(true);
1104
+            if (class_exists('\RarException')) {
1105
+                            \RarException::setUsingExceptions(true);
1106
+            }
1042 1107
         }
1043 1108
     }
1044 1109
 }
Please login to merge, or discard this patch.
src/CamApplication.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 
60 60
         if (!empty($not_installed)) {
61 61
             echo 'Not supported archive types:'.PHP_EOL;
62
-            array_walk($not_installed, function ($instruction, $extension) {
62
+            array_walk($not_installed, function($instruction, $extension) {
63 63
                 echo '- '.$extension.': '.$instruction.PHP_EOL;
64 64
             });
65 65
         }
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
             if ($archived_files === false)
290 290
                 echo 'Error'.PHP_EOL;
291 291
             else
292
-                echo 'Created archive ' . $args['ARCHIVE'] . ' with ' . $archived_files . ' file(s) of total size ' . implode('', $this->formatSize(filesize($args['ARCHIVE']))) . PHP_EOL;
292
+                echo 'Created archive '.$args['ARCHIVE'].' with '.$archived_files.' file(s) of total size '.implode('', $this->formatSize(filesize($args['ARCHIVE']))).PHP_EOL;
293 293
         }
294 294
     }
295 295
 }
Please login to merge, or discard this patch.
Braces   +51 added lines, -34 removed lines patch added patch discarded remove patch
@@ -12,12 +12,14 @@  discard block
 block discarded – undo
12 12
      */
13 13
     protected function open($file)
14 14
     {
15
-        if (!UnifiedArchive::canOpenArchive($file))
16
-            throw new Exception('Could not open archive '.$file.'. Try installing suggested packages or run `cam -f` to see formats support.');
15
+        if (!UnifiedArchive::canOpenArchive($file)) {
16
+                    throw new Exception('Could not open archive '.$file.'. Try installing suggested packages or run `cam -f` to see formats support.');
17
+        }
17 18
 
18 19
         $archive = UnifiedArchive::open($file);
19
-        if ($archive === null)
20
-            throw new Exception('Could not open archive '.$file);
20
+        if ($archive === null) {
21
+                    throw new Exception('Could not open archive '.$file);
22
+        }
21 23
 
22 24
         return $archive;
23 25
     }
@@ -135,17 +137,18 @@  discard block
 block discarded – undo
135 137
      */
136 138
     public function formatDate($unixtime)
137 139
     {
138
-        if (strtotime('today') < $unixtime)
139
-            return 'Today, '.date('G:m', $unixtime);
140
-        else if (strtotime('yesterday') < $unixtime)
141
-            return 'Yesterday, '.date('G:m', $unixtime);
142
-        else {
140
+        if (strtotime('today') < $unixtime) {
141
+                    return 'Today, '.date('G:m', $unixtime);
142
+        } else if (strtotime('yesterday') < $unixtime) {
143
+                    return 'Yesterday, '.date('G:m', $unixtime);
144
+        } else {
143 145
             $datetime = new \DateTime();
144 146
             $datetime->setTimestamp($unixtime);
145
-            if ($datetime->format('Y') == date('Y'))
146
-                return $datetime->format('d M, G:m');
147
-            else
148
-                return $datetime->format('d M Y, G:m');
147
+            if ($datetime->format('Y') == date('Y')) {
148
+                            return $datetime->format('d M, G:m');
149
+            } else {
150
+                            return $datetime->format('d M Y, G:m');
151
+            }
149 152
         }
150 153
     }
151 154
 
@@ -175,25 +178,36 @@  discard block
 block discarded – undo
175 178
         $archive = $this->open($args['ARCHIVE']);
176 179
         $output = getcwd();
177 180
         if (isset($args['--output'])) {
178
-            if (!is_dir($args['--output']))
179
-                mkdir($args['--output']);
181
+            if (!is_dir($args['--output'])) {
182
+                            mkdir($args['--output']);
183
+            }
180 184
             $output = realpath($args['--output']);
181 185
         }
182 186
 
183 187
         if (empty($args['FILES_IN_ARCHIVE']) || $args['FILES_IN_ARCHIVE'] == array('/') || $args['FILES_IN_ARCHIVE'] == array('*')) {
184 188
             $result = $archive->extractFiles($output);
185
-            if ($result === false) echo 'Error occured'.PHP_EOL;
186
-            else echo 'Extracted '.$result.' file(s) to '.$output.PHP_EOL;
189
+            if ($result === false) {
190
+             echo 'Error occured'.PHP_EOL;
191
+            } else {
192
+             echo 'Extracted '.$result.' file(s) to '.$output.PHP_EOL;
193
+            }
187 194
         } else {
188 195
             $extracted = 0;
189 196
             $errored = [];
190 197
             foreach ($args['FILES_IN_ARCHIVE'] as $file) {
191 198
                 $result = $archive->extractFiles($output, $file);
192
-                if ($result === false) $errored[] = $file;
193
-                else $extracted += $result;
199
+                if ($result === false) {
200
+                 $errored[] = $file;
201
+                } else {
202
+                 $extracted += $result;
203
+                }
204
+            }
205
+            if (!empty($errored)) {
206
+             echo 'Errored: '.implode(', ', $errored).PHP_EOL;
207
+            }
208
+            if ($extracted > 0) {
209
+             echo 'Exctracted '.$extracted.' file(s) to '.$output.PHP_EOL;
194 210
             }
195
-            if (!empty($errored)) echo 'Errored: '.implode(', ', $errored).PHP_EOL;
196
-            if ($extracted > 0) echo 'Exctracted '.$extracted.' file(s) to '.$output.PHP_EOL;
197 211
         }
198 212
     }
199 213
 
@@ -252,8 +266,9 @@  discard block
 block discarded – undo
252 266
                 echo 'File '.$file.' is NOT in archive'.PHP_EOL;
253 267
                 continue;
254 268
             }
255
-            if ($archive->deleteFiles($file) === false)
256
-                echo 'Error file '.$file.PHP_EOL;
269
+            if ($archive->deleteFiles($file) === false) {
270
+                            echo 'Error file '.$file.PHP_EOL;
271
+            }
257 272
         }
258 273
     }
259 274
 
@@ -266,10 +281,11 @@  discard block
 block discarded – undo
266 281
     {
267 282
         $archive = $this->open($args['ARCHIVE']);
268 283
         $added_files = $archive->addFiles($args['FILES_ON_DISK']);
269
-        if ($added_files === false)
270
-            echo 'Error'.PHP_EOL;
271
-        else
272
-            echo 'Added '.$added_files.' file(s)'.PHP_EOL;
284
+        if ($added_files === false) {
285
+                    echo 'Error'.PHP_EOL;
286
+        } else {
287
+                    echo 'Added '.$added_files.' file(s)'.PHP_EOL;
288
+        }
273 289
     }
274 290
 
275 291
     /**
@@ -279,17 +295,18 @@  discard block
 block discarded – undo
279 295
     public function create($args)
280 296
     {
281 297
         if (file_exists($args['ARCHIVE'])) {
282
-            if (is_dir($args['ARCHIVE']))
283
-                echo $args['ARCHIVE'].' is a directory!'.PHP_EOL;
284
-            else {
298
+            if (is_dir($args['ARCHIVE'])) {
299
+                            echo $args['ARCHIVE'].' is a directory!'.PHP_EOL;
300
+            } else {
285 301
                 echo 'File '.$args['ARCHIVE'].' already exists!'.PHP_EOL;
286 302
             }
287 303
         } else {
288 304
             $archived_files = UnifiedArchive::archiveFiles($args['FILES_ON_DISK'], $args['ARCHIVE']);
289
-            if ($archived_files === false)
290
-                echo 'Error'.PHP_EOL;
291
-            else
292
-                echo 'Created archive ' . $args['ARCHIVE'] . ' with ' . $archived_files . ' file(s) of total size ' . implode('', $this->formatSize(filesize($args['ARCHIVE']))) . PHP_EOL;
305
+            if ($archived_files === false) {
306
+                            echo 'Error'.PHP_EOL;
307
+            } else {
308
+                            echo 'Created archive ' . $args['ARCHIVE'] . ' with ' . $archived_files . ' file(s) of total size ' . implode('', $this->formatSize(filesize($args['ARCHIVE']))) . PHP_EOL;
309
+            }
293 310
         }
294 311
     }
295 312
 }
Please login to merge, or discard this patch.
src/PclZipOriginalInterface.php 1 patch
Spacing   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 
4 4
   // ----- Constants
5 5
   if (!defined('PCLZIP_READ_BLOCK_SIZE')) {
6
-    define( 'PCLZIP_READ_BLOCK_SIZE', 2048 );
6
+    define('PCLZIP_READ_BLOCK_SIZE', 2048);
7 7
   }
8 8
 
9 9
   // ----- File list separator
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
   //define( 'PCLZIP_SEPARATOR', ' ' );
18 18
   // Recommanded values for smart separation of filenames.
19 19
   if (!defined('PCLZIP_SEPARATOR')) {
20
-    define( 'PCLZIP_SEPARATOR', ',' );
20
+    define('PCLZIP_SEPARATOR', ',');
21 21
   }
22 22
 
23 23
   // ----- Error configuration
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
   //     you must ensure that you have included PclError library.
27 27
   // [2,...] : reserved for futur use
28 28
   if (!defined('PCLZIP_ERROR_EXTERNAL')) {
29
-    define( 'PCLZIP_ERROR_EXTERNAL', 0 );
29
+    define('PCLZIP_ERROR_EXTERNAL', 0);
30 30
   }
31 31
 
32 32
   // ----- Optional static temporary directory
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
   // define( 'PCLZIP_TEMPORARY_DIR', '/temp/' );
40 40
   // define( 'PCLZIP_TEMPORARY_DIR', 'C:/Temp/' );
41 41
   if (!defined('PCLZIP_TEMPORARY_DIR')) {
42
-    define( 'PCLZIP_TEMPORARY_DIR', sys_get_temp_dir());
42
+    define('PCLZIP_TEMPORARY_DIR', sys_get_temp_dir());
43 43
   }
44 44
 
45 45
   // ----- Optional threshold ratio for use of temporary files
@@ -51,75 +51,75 @@  discard block
 block discarded – undo
51 51
   //       Samples :
52 52
   // define( 'PCLZIP_TEMPORARY_FILE_RATIO', 0.5 );
53 53
   if (!defined('PCLZIP_TEMPORARY_FILE_RATIO')) {
54
-    define( 'PCLZIP_TEMPORARY_FILE_RATIO', 0.47 );
54
+    define('PCLZIP_TEMPORARY_FILE_RATIO', 0.47);
55 55
   }
56 56
 
57
-  define( 'PCLZIP_ERR_USER_ABORTED', 2 );
58
-  define( 'PCLZIP_ERR_NO_ERROR', 0 );
59
-  define( 'PCLZIP_ERR_WRITE_OPEN_FAIL', -1 );
60
-  define( 'PCLZIP_ERR_READ_OPEN_FAIL', -2 );
61
-  define( 'PCLZIP_ERR_INVALID_PARAMETER', -3 );
62
-  define( 'PCLZIP_ERR_MISSING_FILE', -4 );
63
-  define( 'PCLZIP_ERR_FILENAME_TOO_LONG', -5 );
64
-  define( 'PCLZIP_ERR_INVALID_ZIP', -6 );
65
-  define( 'PCLZIP_ERR_BAD_EXTRACTED_FILE', -7 );
66
-  define( 'PCLZIP_ERR_DIR_CREATE_FAIL', -8 );
67
-  define( 'PCLZIP_ERR_BAD_EXTENSION', -9 );
68
-  define( 'PCLZIP_ERR_BAD_FORMAT', -10 );
69
-  define( 'PCLZIP_ERR_DELETE_FILE_FAIL', -11 );
70
-  define( 'PCLZIP_ERR_RENAME_FILE_FAIL', -12 );
71
-  define( 'PCLZIP_ERR_BAD_CHECKSUM', -13 );
72
-  define( 'PCLZIP_ERR_INVALID_ARCHIVE_ZIP', -14 );
73
-  define( 'PCLZIP_ERR_MISSING_OPTION_VALUE', -15 );
74
-  define( 'PCLZIP_ERR_INVALID_OPTION_VALUE', -16 );
75
-  define( 'PCLZIP_ERR_ALREADY_A_DIRECTORY', -17 );
76
-  define( 'PCLZIP_ERR_UNSUPPORTED_COMPRESSION', -18 );
77
-  define( 'PCLZIP_ERR_UNSUPPORTED_ENCRYPTION', -19 );
78
-  define( 'PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE', -20 );
79
-  define( 'PCLZIP_ERR_DIRECTORY_RESTRICTION', -21 );
57
+  define('PCLZIP_ERR_USER_ABORTED', 2);
58
+  define('PCLZIP_ERR_NO_ERROR', 0);
59
+  define('PCLZIP_ERR_WRITE_OPEN_FAIL', -1);
60
+  define('PCLZIP_ERR_READ_OPEN_FAIL', -2);
61
+  define('PCLZIP_ERR_INVALID_PARAMETER', -3);
62
+  define('PCLZIP_ERR_MISSING_FILE', -4);
63
+  define('PCLZIP_ERR_FILENAME_TOO_LONG', -5);
64
+  define('PCLZIP_ERR_INVALID_ZIP', -6);
65
+  define('PCLZIP_ERR_BAD_EXTRACTED_FILE', -7);
66
+  define('PCLZIP_ERR_DIR_CREATE_FAIL', -8);
67
+  define('PCLZIP_ERR_BAD_EXTENSION', -9);
68
+  define('PCLZIP_ERR_BAD_FORMAT', -10);
69
+  define('PCLZIP_ERR_DELETE_FILE_FAIL', -11);
70
+  define('PCLZIP_ERR_RENAME_FILE_FAIL', -12);
71
+  define('PCLZIP_ERR_BAD_CHECKSUM', -13);
72
+  define('PCLZIP_ERR_INVALID_ARCHIVE_ZIP', -14);
73
+  define('PCLZIP_ERR_MISSING_OPTION_VALUE', -15);
74
+  define('PCLZIP_ERR_INVALID_OPTION_VALUE', -16);
75
+  define('PCLZIP_ERR_ALREADY_A_DIRECTORY', -17);
76
+  define('PCLZIP_ERR_UNSUPPORTED_COMPRESSION', -18);
77
+  define('PCLZIP_ERR_UNSUPPORTED_ENCRYPTION', -19);
78
+  define('PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE', -20);
79
+  define('PCLZIP_ERR_DIRECTORY_RESTRICTION', -21);
80 80
 
81 81
   // ----- Options values
82
-  define( 'PCLZIP_OPT_PATH', 77001 );
83
-  define( 'PCLZIP_OPT_ADD_PATH', 77002 );
84
-  define( 'PCLZIP_OPT_REMOVE_PATH', 77003 );
85
-  define( 'PCLZIP_OPT_REMOVE_ALL_PATH', 77004 );
86
-  define( 'PCLZIP_OPT_SET_CHMOD', 77005 );
87
-  define( 'PCLZIP_OPT_EXTRACT_AS_STRING', 77006 );
88
-  define( 'PCLZIP_OPT_NO_COMPRESSION', 77007 );
89
-  define( 'PCLZIP_OPT_BY_NAME', 77008 );
90
-  define( 'PCLZIP_OPT_BY_INDEX', 77009 );
91
-  define( 'PCLZIP_OPT_BY_EREG', 77010 );
92
-  define( 'PCLZIP_OPT_BY_PREG', 77011 );
93
-  define( 'PCLZIP_OPT_COMMENT', 77012 );
94
-  define( 'PCLZIP_OPT_ADD_COMMENT', 77013 );
95
-  define( 'PCLZIP_OPT_PREPEND_COMMENT', 77014 );
96
-  define( 'PCLZIP_OPT_EXTRACT_IN_OUTPUT', 77015 );
97
-  define( 'PCLZIP_OPT_REPLACE_NEWER', 77016 );
98
-  define( 'PCLZIP_OPT_STOP_ON_ERROR', 77017 );
82
+  define('PCLZIP_OPT_PATH', 77001);
83
+  define('PCLZIP_OPT_ADD_PATH', 77002);
84
+  define('PCLZIP_OPT_REMOVE_PATH', 77003);
85
+  define('PCLZIP_OPT_REMOVE_ALL_PATH', 77004);
86
+  define('PCLZIP_OPT_SET_CHMOD', 77005);
87
+  define('PCLZIP_OPT_EXTRACT_AS_STRING', 77006);
88
+  define('PCLZIP_OPT_NO_COMPRESSION', 77007);
89
+  define('PCLZIP_OPT_BY_NAME', 77008);
90
+  define('PCLZIP_OPT_BY_INDEX', 77009);
91
+  define('PCLZIP_OPT_BY_EREG', 77010);
92
+  define('PCLZIP_OPT_BY_PREG', 77011);
93
+  define('PCLZIP_OPT_COMMENT', 77012);
94
+  define('PCLZIP_OPT_ADD_COMMENT', 77013);
95
+  define('PCLZIP_OPT_PREPEND_COMMENT', 77014);
96
+  define('PCLZIP_OPT_EXTRACT_IN_OUTPUT', 77015);
97
+  define('PCLZIP_OPT_REPLACE_NEWER', 77016);
98
+  define('PCLZIP_OPT_STOP_ON_ERROR', 77017);
99 99
   // Having big trouble with crypt. Need to multiply 2 long int
100 100
   // which is not correctly supported by PHP ...
101 101
   //define( 'PCLZIP_OPT_CRYPT', 77018 );
102
-  define( 'PCLZIP_OPT_EXTRACT_DIR_RESTRICTION', 77019 );
103
-  define( 'PCLZIP_OPT_TEMP_FILE_THRESHOLD', 77020 );
104
-  define( 'PCLZIP_OPT_ADD_TEMP_FILE_THRESHOLD', 77020 ); // alias
105
-  define( 'PCLZIP_OPT_TEMP_FILE_ON', 77021 );
106
-  define( 'PCLZIP_OPT_ADD_TEMP_FILE_ON', 77021 ); // alias
107
-  define( 'PCLZIP_OPT_TEMP_FILE_OFF', 77022 );
108
-  define( 'PCLZIP_OPT_ADD_TEMP_FILE_OFF', 77022 ); // alias
102
+  define('PCLZIP_OPT_EXTRACT_DIR_RESTRICTION', 77019);
103
+  define('PCLZIP_OPT_TEMP_FILE_THRESHOLD', 77020);
104
+  define('PCLZIP_OPT_ADD_TEMP_FILE_THRESHOLD', 77020); // alias
105
+  define('PCLZIP_OPT_TEMP_FILE_ON', 77021);
106
+  define('PCLZIP_OPT_ADD_TEMP_FILE_ON', 77021); // alias
107
+  define('PCLZIP_OPT_TEMP_FILE_OFF', 77022);
108
+  define('PCLZIP_OPT_ADD_TEMP_FILE_OFF', 77022); // alias
109 109
 
110 110
   // ----- File description attributes
111
-  define( 'PCLZIP_ATT_FILE_NAME', 79001 );
112
-  define( 'PCLZIP_ATT_FILE_NEW_SHORT_NAME', 79002 );
113
-  define( 'PCLZIP_ATT_FILE_NEW_FULL_NAME', 79003 );
114
-  define( 'PCLZIP_ATT_FILE_MTIME', 79004 );
115
-  define( 'PCLZIP_ATT_FILE_CONTENT', 79005 );
116
-  define( 'PCLZIP_ATT_FILE_COMMENT', 79006 );
111
+  define('PCLZIP_ATT_FILE_NAME', 79001);
112
+  define('PCLZIP_ATT_FILE_NEW_SHORT_NAME', 79002);
113
+  define('PCLZIP_ATT_FILE_NEW_FULL_NAME', 79003);
114
+  define('PCLZIP_ATT_FILE_MTIME', 79004);
115
+  define('PCLZIP_ATT_FILE_CONTENT', 79005);
116
+  define('PCLZIP_ATT_FILE_COMMENT', 79006);
117 117
 
118 118
   // ----- Call backs values
119
-  define( 'PCLZIP_CB_PRE_EXTRACT', 78001 );
120
-  define( 'PCLZIP_CB_POST_EXTRACT', 78002 );
121
-  define( 'PCLZIP_CB_PRE_ADD', 78003 );
122
-  define( 'PCLZIP_CB_POST_ADD', 78004 );
119
+  define('PCLZIP_CB_PRE_EXTRACT', 78001);
120
+  define('PCLZIP_CB_POST_EXTRACT', 78002);
121
+  define('PCLZIP_CB_PRE_ADD', 78003);
122
+  define('PCLZIP_CB_POST_ADD', 78004);
123 123
 
124 124
 interface PclZipOriginalInterface
125 125
 {
Please login to merge, or discard this patch.
src/BasicArchive.php 1 patch
Braces   +31 added lines, -22 removed lines patch added patch discarded remove patch
@@ -38,8 +38,9 @@  discard block
 block discarded – undo
38 38
         $newFiles = [];
39 39
         foreach ($files as $file) {
40 40
             foreach ($archiveFiles as $archiveFile) {
41
-                if (fnmatch($file.'*', $archiveFile))
42
-                    $newFiles[] = $archiveFile;
41
+                if (fnmatch($file.'*', $archiveFile)) {
42
+                                    $newFiles[] = $archiveFile;
43
+                }
43 44
             }
44 45
         }
45 46
         return $newFiles;
@@ -56,26 +57,29 @@  discard block
 block discarded – undo
56 57
         // passed an extended list
57 58
         if (is_array($nodes)) {
58 59
             foreach ($nodes as $source => $destination) {
59
-                if (is_numeric($source))
60
-                    $source = $destination;
60
+                if (is_numeric($source)) {
61
+                                    $source = $destination;
62
+                }
61 63
 
62 64
                 $destination = rtrim($destination, '/\\*');
63 65
 
64 66
                 // if is directory
65
-                if (is_dir($source))
66
-                    self::importFilesFromDir(rtrim($source, '/\\*').'/*',
67
+                if (is_dir($source)) {
68
+                                    self::importFilesFromDir(rtrim($source, '/\\*').'/*',
67 69
                         !empty($destination) ? $destination.'/' : null, true, $files);
68
-                else if (is_file($source))
69
-                    $files[$destination] = $source;
70
+                } else if (is_file($source)) {
71
+                                    $files[$destination] = $source;
72
+                }
70 73
             }
71 74
 
72 75
         } else if (is_string($nodes)) { // passed one file or directory
73 76
             // if is directory
74
-            if (is_dir($nodes))
75
-                self::importFilesFromDir(rtrim($nodes, '/\\*').'/*', null, true,
77
+            if (is_dir($nodes)) {
78
+                            self::importFilesFromDir(rtrim($nodes, '/\\*').'/*', null, true,
76 79
                     $files);
77
-            else if (is_file($nodes))
78
-                $files[basename($nodes)] = $nodes;
80
+            } else if (is_file($nodes)) {
81
+                            $files[basename($nodes)] = $nodes;
82
+            }
79 83
         }
80 84
 
81 85
         return $files;
@@ -92,8 +96,9 @@  discard block
 block discarded – undo
92 96
         // $map[$destination] = rtrim($source, '/*');
93 97
         // do not map root archive folder
94 98
 
95
-        if ($destination !== null)
96
-            $map[$destination] = null;
99
+        if ($destination !== null) {
100
+                    $map[$destination] = null;
101
+        }
97 102
 
98 103
         foreach (glob($source, GLOB_MARK) as $node) {
99 104
             if (in_array(substr($node, -1), ['/', '\\'], true) && $recursive) {
@@ -112,8 +117,9 @@  discard block
 block discarded – undo
112 117
      */
113 118
     static public function archiveFile($file, $archiveName)
114 119
     {
115
-        if (!is_file($file))
116
-            throw new \InvalidArgumentException($file.' is not a valid file to archive');
120
+        if (!is_file($file)) {
121
+                    throw new \InvalidArgumentException($file.' is not a valid file to archive');
122
+        }
117 123
 
118 124
         return static::archiveFiles($file, $archiveName) === 1;
119 125
     }
@@ -125,8 +131,9 @@  discard block
 block discarded – undo
125 131
      */
126 132
     static public function archiveDirectory($directory, $archiveName)
127 133
     {
128
-        if (!is_dir($directory) || !is_readable($directory))
129
-            throw new \InvalidArgumentException($directory.' is not a valid directory to archive');
134
+        if (!is_dir($directory) || !is_readable($directory)) {
135
+                    throw new \InvalidArgumentException($directory.' is not a valid directory to archive');
136
+        }
130 137
 
131 138
         return static::archiveFiles($directory, $archiveName) > 0;
132 139
     }
@@ -138,8 +145,9 @@  discard block
 block discarded – undo
138 145
      */
139 146
     public function addFile($file, $inArchiveName = null)
140 147
     {
141
-        if (!is_file($file))
142
-            throw new \InvalidArgumentException($file.' is not a valid file to add in archive');
148
+        if (!is_file($file)) {
149
+                    throw new \InvalidArgumentException($file.' is not a valid file to add in archive');
150
+        }
143 151
 
144 152
         return ($inArchiveName !== null
145 153
             ? $this->addFiles([$file => $inArchiveName])
@@ -153,8 +161,9 @@  discard block
 block discarded – undo
153 161
      */
154 162
     public function addDirectory($directory, $inArchivePath = null)
155 163
     {
156
-        if (!is_dir($directory) || !is_readable($directory))
157
-            throw new \InvalidArgumentException($directory.' is not a valid directory to add in archive');
164
+        if (!is_dir($directory) || !is_readable($directory)) {
165
+                    throw new \InvalidArgumentException($directory.' is not a valid directory to add in archive');
166
+        }
158 167
 
159 168
         return ($inArchivePath !== null
160 169
                 ? $this->addFiles([$directory => $inArchivePath])
Please login to merge, or discard this patch.