JsonConfig::__construct()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 2
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 4
rs 10
1
<?php
2
3
/**
4
 * This file is part of the Cervo package.
5
 *
6
 * Copyright (c) 2010-2019 Nevraxe inc. & Marc André Audet <[email protected]>.
7
 *
8
 * @package   Cervo
9
 * @author    Marc André Audet <[email protected]>
10
 * @copyright 2010 - 2019 Nevraxe inc. & Marc André Audet
11
 * @license   See LICENSE.md  MIT
12
 * @link      https://github.com/Nevraxe/Cervo
13
 * @since     5.0.0
14
 */
15
16
declare(strict_types=1);
17
18
namespace Cervo\Config;
19
20
/**
21
 * Configuration manager for Cervo.
22
 *
23
 * @author Marc André Audet <[email protected]>
24
 */
25
class JsonConfig extends BaseConfig
26
{
27
    /**
28
     * JsonConfig constructor.
29
     *
30
     * @param null|string $jsonFilePath The path to the JSON file to use as configuration source.
31
     */
32
    public function __construct(?string $jsonFilePath = null)
33
    {
34
        if ($jsonFilePath !== null && file_exists($jsonFilePath)) {
35
            $this->setFromArrayRecursive(json_decode(file_get_contents($jsonFilePath), true));
36
        }
37
    }
38
}
39