Completed
Push — master ( 90d35b...b28524 )
by Andrii
05:54
created

Config::bootstrap()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 0
loc 8
ccs 0
cts 7
cp 0
rs 9.4285
cc 2
eloc 5
nc 2
nop 1
crap 6
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-2017, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hiqdev\chkipper\components;
12
13
use hiqdev\chkipper\lib\ConfigInterface;
14
use Yii;
15
use yii\base\BootstrapInterface;
16
use yii\base\Component;
17
use yii\helpers\Json;
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
    protected $_authors = [];
30
31
    public $configFile = 'chkipper.json';
32
33
    public $historyFile = 'history.md';
34
35
    public $changelogFile = 'CHANGELOG.md';
36
37
    public function bootstrap($app)
38
    {
39
        if (is_file($this->configFile)) {
40
            $json = file_get_contents($this->configFile);
41
            $data = Json::decode($json);
42
            Yii::configure($this, $data);
43
        }
44
    }
45
46
    public function setName($name)
47
    {
48
        $this->_name = $name;
49
    }
50
51
    public function getName()
52
    {
53
        return $this->_name;
54
    }
55
56
    public function setAuthors(array $authors)
57
    {
58
        $this->_authors = $authors;
59
    }
60
61
    public function getAuthors()
62
    {
63
        return $this->_authors;
64
    }
65
}
66