Passed
Push — 0.1.x ( 72f342...82f677 )
by f
01:42
created
src/TarArchive2.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.