Completed
Push — master ( 7b4929...cefe8d )
by Andrii
01:50
created

Config   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 4
c 2
b 0
f 1
lcom 1
cbo 3
dl 0
loc 29
ccs 0
cts 16
cp 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A bootstrap() 0 8 2
A setName() 0 4 1
A getName() 0 4 1
1
<?php
2
/**
3
 * Changelog keeper
4
 *
5
 * @link      https://github.com/hiqdev/chkipper
6
 * @package   chkipper
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2016, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hiqdev\chkipper\components;
12
13
use hiqdev\chkipper\history\ConfigInterface;
14
use yii\base\BootstrapInterface;
15
use yii\base\Component;
16
use yii\helpers\Json;
17
use Yii;
18
19
/**
20
 * Config class.
21
 * Loads and holds configuration.
22
 *
23
 * @author Andrii Vasyliev <[email protected]>
24
 */
25
class Config extends Component implements BootstrapInterface, ConfigInterface
26
{
27
    protected $_name;
28
29
    public $configFile = 'chkipper.json';
30
31
    public $historyFile = 'history.md';
32
33
    public $changelogFile = 'CHANGELOG.md';
34
35
    public function bootstrap($app)
36
    {
37
        if (is_file($this->configFile)) {
38
            $json = file_get_contents($this->configFile);
39
            $data = Json::decode($json);
40
            Yii::configure($this, $data);
41
        }
42
    }
43
44
    public function setName($name)
45
    {
46
        $this->_name = $name;
47
    }
48
49
    public function getName()
50
    {
51
        return $this->_name;
52
    }
53
}
54