• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

tito10047 / migration-backup / 23041623296

13 Mar 2026 07:58AM UTC coverage: 86.131% (+19.5%) from 66.667%
23041623296

push

github

web-flow
Merge pull request #2 from tito10047/comporessor

add multi-format compression support (gzip, bzip2, zstd, zip, lz4, no…

92 of 111 new or added lines in 8 files covered. (82.88%)

236 of 274 relevant lines covered (86.13%)

57.79 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

80.0
/src/Compressor/Bzip2Compressor.php
1
<?php
2

3
namespace Tito10047\MigrationBackup\Compressor;
4

5
use Symfony\Component\Filesystem\Filesystem;
6
use RuntimeException;
7

8
class GzipCompressor implements CompressorInterface {
9
        public function __construct(
10
                private readonly Filesystem $fs
11
        ) {}
126✔
12

13
        public function compress(string $path): string {
14
                if (!$this->isAvailable()) {
84✔
NEW
15
                        throw new RuntimeException('Gzip compression is not available (zlib extension missing).');
×
16
                }
17

18
                $gzPath = $path . '.gz';
84✔
19
                $fp     = gzopen($gzPath, 'w9');
84✔
20
                if (!$fp) {
84✔
NEW
21
                        throw new RuntimeException('Could not open file for compression: ' . $gzPath);
×
22
                }
23

24
                $handle = fopen($path, 'rb');
84✔
25
                if (!$handle) {
84✔
NEW
26
                        gzclose($fp);
×
NEW
27
                        throw new RuntimeException('Could not open file for reading: ' . $path);
×
28
                }
29

30
                while (!feof($handle)) {
84✔
31
                        gzwrite($fp, fread($handle, 1024 * 512));
84✔
32
                }
33

34
                fclose($handle);
84✔
35
                gzclose($fp);
84✔
36

37
                $this->fs->remove($path);
84✔
38
                $this->fs->rename($gzPath, $path);
84✔
39

40
                return $path;
84✔
41
        }
42

43
        public function getExtension(): string {
44
                return '.gz';
84✔
45
        }
46

47
        public function isAvailable(): bool {
48
                return function_exists('gzopen');
105✔
49
        }
50
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc