@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | |
33 | 33 | public const ERROR_OPENING_ZIP_FILE = 338003; |
34 | 34 | |
35 | - public const ERROR_CANNOT_SAVE_FILE_TO_DISK =338004; |
|
35 | + public const ERROR_CANNOT_SAVE_FILE_TO_DISK = 338004; |
|
36 | 36 | |
37 | 37 | /** |
38 | 38 | * @var array<string,mixed> |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | * |
86 | 86 | * @see FileHelper::ERROR_SOURCE_FILE_DOES_NOT_EXIST |
87 | 87 | */ |
88 | - public function addFile(string $filePath, ?string $zipPath=null) : bool |
|
88 | + public function addFile(string $filePath, ?string $zipPath = null) : bool |
|
89 | 89 | { |
90 | 90 | $this->open(); |
91 | 91 | |
@@ -138,16 +138,16 @@ discard block |
||
138 | 138 | */ |
139 | 139 | protected function open() : void |
140 | 140 | { |
141 | - if($this->open) { |
|
141 | + if ($this->open) { |
|
142 | 142 | return; |
143 | 143 | } |
144 | 144 | |
145 | - if(!isset($this->zip)) { |
|
145 | + if (!isset($this->zip)) { |
|
146 | 146 | $this->zip = new ZipArchive(); |
147 | 147 | } |
148 | 148 | |
149 | 149 | $flag = null; |
150 | - if(!file_exists($this->file)) { |
|
150 | + if (!file_exists($this->file)) { |
|
151 | 151 | $flag = ZipArchive::CREATE; |
152 | 152 | } |
153 | 153 | |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | { |
191 | 191 | $this->fileTracker++; |
192 | 192 | |
193 | - if($this->options['WriteThreshold'] < 1) { |
|
193 | + if ($this->options['WriteThreshold'] < 1) { |
|
194 | 194 | return; |
195 | 195 | } |
196 | 196 | |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | |
204 | 204 | protected function close() : void |
205 | 205 | { |
206 | - if(!$this->open) { |
|
206 | + if (!$this->open) { |
|
207 | 207 | return; |
208 | 208 | } |
209 | 209 | |
@@ -212,8 +212,8 @@ discard block |
||
212 | 212 | throw new ZIPHelper_Exception( |
213 | 213 | 'Could not save ZIP file to disk', |
214 | 214 | sprintf( |
215 | - 'Tried saving the ZIP file [%1$s], but the write failed. This can have several causes, ' . |
|
216 | - 'including adding files that do not exist on disk, trying to create an empty zip, ' . |
|
215 | + 'Tried saving the ZIP file [%1$s], but the write failed. This can have several causes, '. |
|
216 | + 'including adding files that do not exist on disk, trying to create an empty zip, '. |
|
217 | 217 | 'or trying to save to a directory that does not exist.', |
218 | 218 | $this->file |
219 | 219 | ), |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | { |
229 | 229 | $this->open(); |
230 | 230 | |
231 | - if($this->countFiles() < 1) |
|
231 | + if ($this->countFiles() < 1) |
|
232 | 232 | { |
233 | 233 | throw new ZIPHelper_Exception( |
234 | 234 | 'No files in the zip file', |
@@ -254,18 +254,18 @@ discard block |
||
254 | 254 | * @throws ZIPHelper_Exception |
255 | 255 | * @return string The file name that was sent (useful in case none was specified). |
256 | 256 | */ |
257 | - public function download(?string $fileName=null) : string |
|
257 | + public function download(?string $fileName = null) : string |
|
258 | 258 | { |
259 | 259 | $this->save(); |
260 | 260 | |
261 | - if(empty($fileName)) |
|
261 | + if (empty($fileName)) |
|
262 | 262 | { |
263 | 263 | $fileName = basename($this->file); |
264 | 264 | } |
265 | 265 | |
266 | 266 | header('Content-type: application/zip'); |
267 | - header('Content-Disposition: attachment; filename=' . $fileName); |
|
268 | - header('Content-length: ' . filesize($this->file)); |
|
267 | + header('Content-Disposition: attachment; filename='.$fileName); |
|
268 | + header('Content-length: '.filesize($this->file)); |
|
269 | 269 | header('Pragma: no-cache'); |
270 | 270 | header('Expires: 0'); |
271 | 271 | readfile($this->file); |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | * @throws ZIPHelper_Exception |
284 | 284 | * @see ZIPHelper::download() |
285 | 285 | */ |
286 | - public function downloadAndDelete(?string $fileName=null) : ZIPHelper |
|
286 | + public function downloadAndDelete(?string $fileName = null) : ZIPHelper |
|
287 | 287 | { |
288 | 288 | $this->download($fileName); |
289 | 289 | |
@@ -300,9 +300,9 @@ discard block |
||
300 | 300 | * @param string|NULL $outputFolder If no folder is specified, uses the target file's folder. |
301 | 301 | * @return boolean |
302 | 302 | */ |
303 | - public function extractAll(?string $outputFolder=null) : bool |
|
303 | + public function extractAll(?string $outputFolder = null) : bool |
|
304 | 304 | { |
305 | - if(empty($outputFolder)) { |
|
305 | + if (empty($outputFolder)) { |
|
306 | 306 | $outputFolder = dirname($this->file); |
307 | 307 | } |
308 | 308 |
@@ -18,15 +18,15 @@ |
||
18 | 18 | * @param int $level |
19 | 19 | * @return array<mixed> |
20 | 20 | */ |
21 | - protected function traverseArray(array $array, int $level=0) : array |
|
21 | + protected function traverseArray(array $array, int $level = 0) : array |
|
22 | 22 | { |
23 | 23 | $result = array(); |
24 | 24 | |
25 | - foreach($array as $key => $val) |
|
25 | + foreach ($array as $key => $val) |
|
26 | 26 | { |
27 | - if(is_array($val)) |
|
27 | + if (is_array($val)) |
|
28 | 28 | { |
29 | - $result[$key] = $this->traverseArray($val, ($level+1)); |
|
29 | + $result[$key] = $this->traverseArray($val, ($level + 1)); |
|
30 | 30 | } |
31 | 31 | else |
32 | 32 | { |