Completed
Push — master ( c56f94...60d510 )
by Tomáš
9s
created

Configuration::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of Symplify
7
 * Copyright (c) 2016 Tomas Votruba (http://tomasvotruba.cz).
8
 */
9
10
namespace Symplify\PHP7_Sculpin\Configuration;
11
12
use SplFileInfo;
13
use Symplify\PHP7_Sculpin\Configuration\Parser\YamlAndNeonParser;
14
15
final class Configuration
16
{
17
    /**
18
     * @var array
19
     */
20
    private $options = [];
21
22
    /**
23
     * @var YamlAndNeonParser
24
     */
25
    private $yamlAndNeonParser;
26
27 9
    public function __construct(YamlAndNeonParser $yamlAndNeonParser)
28
    {
29 9
        $this->yamlAndNeonParser = $yamlAndNeonParser;
30 9
    }
31
32
    /**
33
     * @param SplFileInfo[] $files
34
     */
35 3
    public function loadOptionsFromFiles(array $files)
36
    {
37 3
        foreach ($files as $file) {
38 1
            $fileContent = file_get_contents($file->getRealPath());
39 1
            $this->options += $this->yamlAndNeonParser->decode($fileContent);
40
        }
41 3
    }
42
43
    /**
44
     * @param string       $name
45
     * @param string|array $value
46
     */
47 2
    public function addOption(string $name, $value)
48
    {
49 2
        $this->options[$name] = $value;
50 2
    }
51
52 9
    public function getOptions() : array
53
    {
54 9
        return $this->options;
55
    }
56
}
57