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

Config::getName()   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 2
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 0
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-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