Passed
Pull Request — master (#99)
by Evgeniy
12:56
created

FileJSON::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 5
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 8
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Cekta\DI\Provider;
6
7
use InvalidArgumentException;
8
9
class FileJSON extends KeyValue
10
{
11
    public function __construct(string $path)
12
    {
13
        if (!file_exists($path)) {
14
            throw new InvalidArgumentException("invalid path: `$path`");
15
        }
16
        $content = file_get_contents($path);
17
        assert(is_string($content));
18
        parent::__construct(json_decode($content, true));
19
    }
20
}
21