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

tito10047 / migration-backup / 23040798973

13 Mar 2026 07:29AM UTC coverage: 76.277% (+9.6%) from 66.667%
23040798973

Pull #2

github

tito10047
add multi-format compression support (gzip, bzip2, zstd, zip, lz4, none) with implementation and configuration options
Pull Request #2: add multi-format compression support (gzip, bzip2, zstd, zip, lz4, no…

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

209 of 274 relevant lines covered (76.28%)

40.93 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 Bzip2Compressor implements CompressorInterface {
9
        public function __construct(
10
                private readonly Filesystem $fs
11
        ) {}
63✔
12

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

18
                $bzPath = $path . '.bz2';
21✔
19
                $fp     = bzopen($bzPath, 'w');
21✔
20
                if (!$fp) {
21✔
NEW
21
                        throw new RuntimeException('Could not open file for compression: ' . $bzPath);
×
22
                }
23

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

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

34
                fclose($handle);
21✔
35
                bzclose($fp);
21✔
36

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

40
                return $path;
21✔
41
        }
42

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

47
        public function isAvailable(): bool {
48
                return function_exists('bzopen');
42✔
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