Conditions | 3 |
Paths | 3 |
Total Lines | 20 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
7 | public static function compress(string $inputFile): string |
||
8 | { |
||
9 | if (! file_exists($inputFile)) { |
||
10 | throw new \InvalidArgumentException("Inputfile `{$inputFile}` does not exist."); |
||
11 | } |
||
12 | |||
13 | $inputHandle = fopen($inputFile, 'rb'); |
||
14 | |||
15 | $outputFile = $inputFile . '.gz'; |
||
16 | $outputHandle = gzopen($outputFile, 'w9'); |
||
17 | |||
18 | while (!feof($inputHandle)) { |
||
19 | gzwrite($outputHandle, fread($inputHandle, 1024 * 512)); |
||
20 | } |
||
21 | |||
22 | fclose($inputHandle); |
||
23 | gzclose($outputHandle); |
||
24 | |||
25 | return $outputFile; |
||
26 | } |
||
27 | } |
||
28 |