Conditions | 3 |
Paths | 3 |
Total Lines | 18 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 3 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
26 | public function compress(Passbook $passbook, string $temporaryDirectory): void |
||
27 | { |
||
28 | 2 | $file = $temporaryDirectory . self::FILENAME; |
|
29 | |||
30 | 2 | if (($errorCode = $this->zipArchive->open($file, ZipArchive::CREATE)) !== true) { |
|
31 | throw ZipException::canNotOpenZip($file, $errorCode); |
||
32 | 2 | } |
|
33 | 1 | ||
34 | $this->zipArchive->addFile($temporaryDirectory . Signer::FILENAME, Signer::FILENAME); |
||
35 | $this->zipArchive->addFile($temporaryDirectory . ManifestGenerator::FILENAME, ManifestGenerator::FILENAME); |
||
36 | 1 | $this->zipArchive->addFromString(Compiler::PASS_DATA_FILE, (string) json_encode($passbook->getData())); |
|
37 | 1 | ||
38 | 1 | foreach ($passbook->getImages() as $image) { |
|
39 | /** @var Image $image */ |
||
40 | 1 | $this->zipArchive->addFile($image->getPath(), $image->getFilename()); |
|
41 | 1 | } |
|
42 | |||
43 | $this->zipArchive->close(); |
||
44 | 1 | } |
|
46 |