ManifestReader::getManifest()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 1
dl 0
loc 12
rs 9.8666
c 0
b 0
f 0
1
<?php
2
3
4
namespace ExoUNX\Vasri;
5
6
7
use Illuminate\Support\Facades\File;
8
use Exception;
9
10
/**
11
 * Class ManifestReader
12
 *
13
 * @package ExoUNX\Vasri
14
 * @author  Gaige Lama <[email protected]>
15
 * @license MIT License
16
 * @link    https://github.com/ExoUNX/Vasri
17
 */
18
class ManifestReader
19
{
20
21
    /**
22
     * Loads the Manifest json file and decodes it into an array
23
     *
24
     * @param  string  $file
25
     *
26
     * @return array
27
     * @throws Exception
28
     */
29
    public function getManifest(string $file): array
30
    {
31
        if (File::exists($file)) {
32
33
            return json_decode(file_get_contents($file), true);
34
35
        } else {
36
37
            throw new Exception("Incorrect file path or file does not exist for $file");
38
39
        }
40
    }
41
42
}
43