Completed
Pull Request — master (#552)
by Greg
03:19
created

ConfigLoader::getSourceName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Robo\Config;
4
5
use Grasmash\YamlExpander\Expander;
6
7
/**
8
 * Load configuration files, and fill in any property values that
9
 * need to be expanded.
10
 */
11
class ConfigLoader implements ConfigLoaderInterface
12
{
13
    protected $config = [];
14
    protected $source = '';
15
16
    public function getSourceName()
17
    {
18
        return $this->source;
19
    }
20
21
    public function setSourceName($source)
22
    {
23
        $this->source = $source;
24
        return $this;
25
    }
26
27
    public function import($data)
28
    {
29
        $this->config = [];
30
        return $this->add($data);
31
    }
32
33
    public function add($data)
34
    {
35
        if ($data instanceof ConfigLoaderInterface) {
36
            $data = $data->export();
37
        }
38
        $this->config = Expander::expandArrayProperties($data, $this->config);
39
        return $this;
40
    }
41
42
    public function export()
43
    {
44
        return $this->config;
45
    }
46
47
    public function keys()
48
    {
49
        return array_keys($this->config);
50
    }
51
}
52