Completed
Push — master ( c612e7...f3e1c8 )
by Christian
06:23
created

SourceJson   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 45
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A get() 0 4 1
A has() 0 4 1
A set() 0 6 1
1
<?php
2
3
/**
4
 * This file is part of tenside/core.
5
 *
6
 * (c) Christian Schiffler <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 *
11
 * This project is provided in good faith and hope to be usable by anyone.
12
 *
13
 * @package    tenside/core
14
 * @author     Christian Schiffler <[email protected]>
15
 * @copyright  2015 Christian Schiffler <[email protected]>
16
 * @license    https://github.com/tenside/core/blob/master/LICENSE MIT
17
 * @link       https://github.com/tenside/core
18
 * @filesource
19
 */
20
21
namespace Tenside\Core\Config;
22
23
use Tenside\Core\Util\JsonFile;
24
25
/**
26
 * JSON based config.
27
 */
28
class SourceJson implements SourceInterface
29
{
30
    /**
31
     * The JsonFile.
32
     *
33
     * @var JsonFile
34
     */
35
    protected $jsonFile;
36
37
    /**
38
     * Create a new instance.
39
     *
40
     * @param string $filename The filename.
41
     */
42
    public function __construct($filename)
43
    {
44
        $this->jsonFile = new JsonFile($filename);
45
    }
46
47
    /**
48
     * {@inheritDoc}
49
     */
50
    public function get($path, $forceArray = false)
51
    {
52
        return $this->jsonFile->get($path, $forceArray);
53
    }
54
55
    /**
56
     * {@inheritDoc}
57
     */
58
    public function has($path)
59
    {
60
        return $this->jsonFile->has($path);
61
    }
62
63
    /**
64
     * {@inheritDoc}
65
     */
66
    public function set($path, $value)
67
    {
68
        $this->jsonFile->set($path, $value);
69
70
        return $this;
71
    }
72
}
73