Passed
Push — master ( dcfe7d...ba3494 )
by f
13:35
created
src/Drivers/Zip.php 1 patch
Braces   +36 added lines, -24 removed lines patch added patch discarded remove patch
@@ -66,8 +66,9 @@  discard block
 block discarded – undo
66 66
     public function __construct($archiveFileName, $format, $password = null)
67 67
     {
68 68
         $this->open($archiveFileName);
69
-        if ($password !== null)
70
-            $this->zip->setPassword($password);
69
+        if ($password !== null) {
70
+                    $this->zip->setPassword($password);
71
+        }
71 72
     }
72 73
 
73 74
     /**
@@ -101,8 +102,9 @@  discard block
 block discarded – undo
101 102
         for ($i = 0; $i < $this->zip->numFiles; $i++) {
102 103
             $file = $this->zip->statIndex($i);
103 104
             // skip directories
104
-            if (in_array(substr($file['name'], -1), ['/', '\\'], true))
105
-                continue;
105
+            if (in_array(substr($file['name'], -1), ['/', '\\'], true)) {
106
+                            continue;
107
+            }
106 108
             $this->pureFilesNumber++;
107 109
             $information->files[$i] = $file['name'];
108 110
             $information->compressedFilesSize += $file['comp_size'];
@@ -137,8 +139,9 @@  discard block
 block discarded – undo
137 139
         for ($i = 0; $i < $this->zip->numFiles; $i++) {
138 140
             $file_name = $this->zip->getNameIndex($i);
139 141
             // skip directories
140
-            if (in_array(substr($file_name, -1), ['/', '\\'], true))
141
-                continue;
142
+            if (in_array(substr($file_name, -1), ['/', '\\'], true)) {
143
+                            continue;
144
+            }
142 145
             $files[] = $file_name;
143 146
         }
144 147
         return $files;
@@ -175,8 +178,9 @@  discard block
 block discarded – undo
175 178
     public function getFileContent($fileName)
176 179
     {
177 180
         $result = $this->zip->getFromName($fileName);
178
-        if ($result === false)
179
-            throw new Exception('Could not get file information: '.$result.'. May use password?');
181
+        if ($result === false) {
182
+                    throw new Exception('Could not get file information: '.$result.'. May use password?');
183
+        }
180 184
         return $result;
181 185
     }
182 186
 
@@ -197,8 +201,9 @@  discard block
 block discarded – undo
197 201
      */
198 202
     public function extractFiles($outputFolder, array $files)
199 203
     {
200
-        if ($this->zip->extractTo($outputFolder, $files) === false)
201
-            throw new ArchiveExtractionException($this->zip->getStatusString(), $this->zip->status);
204
+        if ($this->zip->extractTo($outputFolder, $files) === false) {
205
+                    throw new ArchiveExtractionException($this->zip->getStatusString(), $this->zip->status);
206
+        }
202 207
 
203 208
         return count($files);
204 209
     }
@@ -210,8 +215,9 @@  discard block
 block discarded – undo
210 215
      */
211 216
     public function extractArchive($outputFolder)
212 217
     {
213
-        if ($this->zip->extractTo($outputFolder) === false)
214
-            throw new ArchiveExtractionException($this->zip->getStatusString(), $this->zip->status);
218
+        if ($this->zip->extractTo($outputFolder) === false) {
219
+                    throw new ArchiveExtractionException($this->zip->getStatusString(), $this->zip->status);
220
+        }
215 221
 
216 222
         return $this->pureFilesNumber;
217 223
     }
@@ -226,8 +232,9 @@  discard block
 block discarded – undo
226 232
     {
227 233
         $count = 0;
228 234
         foreach ($files as $file) {
229
-            if ($this->zip->deleteName($file) === false)
230
-                throw new ArchiveModificationException($this->zip->getStatusString(), $this->zip->status);
235
+            if ($this->zip->deleteName($file) === false) {
236
+                            throw new ArchiveModificationException($this->zip->getStatusString(), $this->zip->status);
237
+            }
231 238
             $count++;
232 239
         }
233 240
 
@@ -250,11 +257,13 @@  discard block
 block discarded – undo
250 257
         $added_files = 0;
251 258
         foreach ($files as $localName => $fileName) {
252 259
             if (is_null($fileName)) {
253
-                if ($this->zip->addEmptyDir($localName) === false)
254
-                    throw new ArchiveModificationException($this->zip->getStatusString(), $this->zip->status);
260
+                if ($this->zip->addEmptyDir($localName) === false) {
261
+                                    throw new ArchiveModificationException($this->zip->getStatusString(), $this->zip->status);
262
+                }
255 263
             } else {
256
-                if ($this->zip->addFile($fileName, $localName) === false)
257
-                    throw new ArchiveModificationException($this->zip->getStatusString(), $this->zip->status);
264
+                if ($this->zip->addFile($fileName, $localName) === false) {
265
+                                    throw new ArchiveModificationException($this->zip->getStatusString(), $this->zip->status);
266
+                }
258 267
                 $added_files++;
259 268
             }
260 269
         }
@@ -307,8 +316,9 @@  discard block
 block discarded – undo
307 316
         $zip = new ZipArchive();
308 317
         $result = $zip->open($archiveFileName, ZipArchive::CREATE);
309 318
 
310
-        if ($result !== true)
311
-            throw new ArchiveCreationException('ZipArchive error: '.$result);
319
+        if ($result !== true) {
320
+                    throw new ArchiveCreationException('ZipArchive error: '.$result);
321
+        }
312 322
 
313 323
         $can_set_compression_level = method_exists($zip, 'setCompressionName');
314 324
         $can_encrypt = static::canEncrypt(Formats::ZIP);
@@ -326,11 +336,13 @@  discard block
 block discarded – undo
326 336
 
327 337
         foreach ($files as $localName => $fileName) {
328 338
             if ($fileName === null) {
329
-                if ($zip->addEmptyDir($localName) === false)
330
-                    throw new ArchiveCreationException('Could not archive directory "'.$localName.'": '.$zip->getStatusString(), $zip->status);
339
+                if ($zip->addEmptyDir($localName) === false) {
340
+                                    throw new ArchiveCreationException('Could not archive directory "'.$localName.'": '.$zip->getStatusString(), $zip->status);
341
+                }
331 342
             } else {
332
-                if ($zip->addFile($fileName, $localName) === false)
333
-                    throw new ArchiveCreationException('Could not archive file "'.$fileName.'": '.$zip->getStatusString(), $zip->status);
343
+                if ($zip->addFile($fileName, $localName) === false) {
344
+                                    throw new ArchiveCreationException('Could not archive file "'.$fileName.'": '.$zip->getStatusString(), $zip->status);
345
+                }
334 346
                 if ($can_set_compression_level) {
335 347
                     $zip->setCompressionName($localName, $compressionLevelMap[$compressionLevel]);
336 348
                 }
Please login to merge, or discard this patch.