Passed
Push — master ( 196a37...9e483f )
by Pol
05:12
created

JsonConfigLoader   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 91.67%

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 26
ccs 11
cts 12
cp 0.9167
rs 10
c 0
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A load() 0 24 3
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 1
    public function load($path)
12
    {
13 1
        $this->setSourceName($path);
14
15
        // We silently skip any nonexistent config files, so that
16
        // clients may simply `load` all of their candidates.
17 1
        if (!\file_exists($path)) {
18 1
            $this->config = [];
19
20 1
            return $this;
21
        }
22
23 1
        $content = \file_get_contents($path);
24
25 1
        if (false === $content) {
26
            return $this;
27
        }
28
29 1
        $this->config = (array) \json_decode(
30 1
            $content,
31 1
            true
32
        );
33
34 1
        return $this;
35
    }
36
}
37