Passed
Push — master ( 09abe6...8522f2 )
by Nils
02:23
created

Config::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
nc 1
nop 1
dl 0
loc 3
c 0
b 0
f 0
cc 1
rs 10
1
<?php
2
3
namespace Startwind\Inventorio\Config;
4
5
use Symfony\Component\Yaml\Yaml;
6
7
class Config
8
{
9
    private array $configArray = [];
10
11
    public function __construct(string $configFile)
12
    {
13
        $this->configArray = Yaml::parse(file_get_contents($configFile));
14
    }
15
16
    public function getInventorioServer(): string
17
    {
18
        return $this->configArray['inventorio']['server'];
19
    }
20
21
    public function getCommands(): array
22
    {
23
        if (array_key_exists('commands', $this->configArray)) {
24
            return $this->configArray['commands'];
25
        } else {
26
            return [];
27
        }
28
    }
29
30
    public function getConfigFile(): string
31
    {
32
        return getenv("HOME") . DIRECTORY_SEPARATOR . $this->configArray['inventorio']['configFile'];
33
    }
34
}
35