Total Complexity | 5 |
Total Lines | 40 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
9 | class Open implements ConfigProviderContract |
||
10 | { |
||
11 | /** |
||
12 | * @var array |
||
13 | */ |
||
14 | private $config; |
||
15 | |||
16 | /** |
||
17 | * @param string $configFilePath |
||
18 | */ |
||
19 | public function load(string $configFilePath = self::CONFIG_FILE_PATH) |
||
20 | { |
||
21 | $this->config = require $configFilePath; |
||
22 | } |
||
23 | |||
24 | /** |
||
25 | * {@inheritdoc} |
||
26 | */ |
||
27 | public function get(string $key, $default = null) |
||
28 | { |
||
29 | $segments = explode('.', $key); |
||
30 | $data = $this->config; |
||
31 | |||
32 | foreach ($segments as $segment) { |
||
33 | if (empty($data[$segment])) { |
||
34 | return $default; |
||
35 | } |
||
36 | |||
37 | $data = $data[$segment]; |
||
38 | } |
||
39 | |||
40 | return $data; |
||
41 | } |
||
42 | |||
43 | /** |
||
44 | * @return array |
||
45 | */ |
||
46 | public function getVocabularyDirectories(): array |
||
49 | } |
||
50 | } |
||
51 |