PackageManifester   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 0
cbo 1
dl 0
loc 24
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A createManifest() 0 15 2
1
<?php
2
3
namespace JWage\APNS\Safari;
4
5
class PackageManifester
6
{
7
    /**
8
     * Generates a manifest JSON file and returns the path.
9
     *
10
     * @param \JWage\APNS\Safari\Package $package
11
     * @return string $manifestJsonPath
12
     */
13
    public function createManifest(Package $package)
14
    {
15
        $manifestData = array();
16
        foreach (Package::$packageFiles as $rawFile) {
17
            $filePath = sprintf('%s/%s', $package->getPackageDir(), $rawFile);
18
            $manifestData[$rawFile] = sha1(file_get_contents($filePath));
19
        }
20
21
        $manifestJsonPath = sprintf('%s/manifest.json', $package->getPackageDir());
22
        $manifestJson = json_encode((object) $manifestData);
23
24
        file_put_contents($manifestJsonPath, $manifestJson);
25
26
        return $manifestJsonPath;
27
    }
28
}
29