Passed
Pull Request — master (#24)
by Dmitriy
37:45 queued 22:43
created

System::mergeValues()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 5
c 0
b 0
f 0
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
namespace Yiisoft\Composer\Config\Config;
4
5
/**
6
 * System class represents system configuration files:
7
 * __files, aliases, packages.
8
 */
9
class System extends Config
10
{
11
    public function setValue(string $name, $value): Config
12
    {
13
        $this->values[$name] = $value;
14
15
        return $this;
16
    }
17
18
    public function setValues(array $values): Config
19
    {
20
        $this->values = $values;
21
22
        return $this;
23
    }
24
25
    public function mergeValues(array $values): Config
26
    {
27
        $this->values = array_merge($this->values, $values);
28
29
        return $this;
30
    }
31
32
    public function load(array $paths = []): Config
33
    {
34
        $path = $this->getOutputPath();
35
        if (!file_exists($path)) {
36
            return $this;
37
        }
38
39
        $this->values = array_merge($this->loadFile($path), $this->values);
40
41
        return $this;
42
    }
43
44
    public function build(): Config
45
    {
46
        $this->values = $this->substituteOutputDirs($this->values);
47
48
        return $this;
49
    }
50
}
51