Test Failed
Pull Request — master (#6)
by Laurens
02:27
created

ManifestGenerator   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 87.5%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 0
dl 0
loc 20
ccs 7
cts 8
cp 0.875
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A hash() 0 4 1
A generate() 0 10 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace LauLamanApps\ApplePassbook\Build;
6
7
use LauLamanApps\ApplePassbook\Passbook;
8
9
class ManifestGenerator
10
{
11
    public const FILENAME = 'manifest.json';
12
13 1
    public function generate(Passbook $passbook, string $temporaryDirectory): void
14
    {
15 1
        $manifest = [Compiler::PASS_DATA_FILE => $this->hash((string) json_encode($passbook->getData()))];
16
17 1
        foreach ($passbook->getImages() as $file) {
18
            $manifest[$file->getFilename()] = $this->hash($file->getContents());
19
        }
20
21 1
        file_put_contents($temporaryDirectory . '/' . self::FILENAME, json_encode($manifest));
22 1
    }
23
24 1
    private function hash(string $data): string
25
    {
26 1
        return sha1($data);
27
    }
28
}
29