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

Config::setName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 2
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