Conditions | 5 |
Paths | 39 |
Total Lines | 32 |
Code Lines | 19 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
28 | protected function compress() |
||
29 | { |
||
30 | $gzipPath = $this->originalFilePath.'.gz'; |
||
31 | |||
32 | $gzipOut = false; |
||
33 | $gzipIn = false; |
||
34 | |||
35 | try { |
||
36 | $gzipOut = gzopen($gzipPath, 'w9'); |
||
37 | $gzipIn = fopen($this->originalFilePath, 'rb'); |
||
38 | |||
39 | while (! feof($gzipIn)) { |
||
40 | gzwrite($gzipOut, fread($gzipIn, 1024 * 512)); |
||
41 | } |
||
42 | |||
43 | fclose($gzipIn); |
||
44 | gzclose($gzipOut); |
||
45 | } catch (\Exception $exception) { |
||
46 | if (is_resource($gzipOut)) { |
||
47 | gzclose($gzipOut); |
||
48 | unlink($gzipPath); |
||
49 | } |
||
50 | |||
51 | if (is_resource($gzipIn)) { |
||
52 | fclose($gzipIn); |
||
53 | } |
||
54 | |||
55 | return $this->originalFilePath; |
||
56 | } |
||
57 | |||
58 | return $gzipPath; |
||
59 | } |
||
60 | |||
77 |