Passed
Push — master ( bf93db...a9da14 )
by Pol
02:24
created

JsonConfigLoader::load()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 18
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 8
nc 2
nop 1
dl 0
loc 18
ccs 0
cts 9
cp 0
crap 6
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace PhpTaskman\Core\Config\Loader;
6
7
use Consolidation\Config\Loader\ConfigLoader;
8
9
class JsonConfigLoader extends ConfigLoader
10
{
11
    public function load($path)
12
    {
13
        $this->setSourceName($path);
14
15
        // We silently skip any nonexistent config files, so that
16
        // clients may simply `load` all of their candidates.
17
        if (!\file_exists($path)) {
18
            $this->config = [];
19
20
            return $this;
21
        }
22
23
        $this->config = (array) \json_decode(
24
            \file_get_contents($path),
25
            true
26
        );
27
28
        return $this;
29
    }
30
}
31