Passed
Push — master ( abee1f...edc958 )
by Kirill
03:08
created

JsonLoader   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 6
dl 0
loc 15
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A loadFile() 0 10 2
1
<?php
2
3
/**
4
 * Spiral Framework.
5
 *
6
 * @license   MIT
7
 * @author    Anton Titov (Wolfy-J)
8
 */
9
10
declare(strict_types=1);
11
12
namespace Spiral\Config\Loader;
13
14
use Spiral\Config\Exception\LoaderException;
15
16
final class JsonLoader implements FileLoaderInterface
17
{
18
    /**
19
     * @inheritdoc
20
     */
21
    public function loadFile(string $section, string $filename): array
22
    {
23
        $content = file_get_contents($filename);
24
        $data = json_decode($content, true);
25
26
        if (is_null($data)) {
27
            throw new LoaderException(json_last_error_msg(), json_last_error());
28
        }
29
30
        return $data;
31
    }
32
}
33