Completed
Push — master ( ef8a42...b5fe4d )
by Andrii
15:02
created

System::writeFile()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 0
cts 1
cp 0
rs 10
cc 1
nc 1
nop 2
crap 2
1
<?php
2
/**
3
 * Composer plugin for config assembling
4
 *
5
 * @link      https://github.com/hiqdev/composer-config-plugin
6
 * @package   composer-config-plugin
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2016-2018, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hiqdev\composer\config\configs;
12
13
/**
14
 * System class represents system configuration files:
15
 * __files, aliases, packages.
16
 *
17
 * @author Andrii Vasyliev <[email protected]>
18
 */
19
class System extends Config
20
{
21
    public function setValue(string $name, $value): Config
22
    {
23
        $this->values[$name] = $value;
24
25
        return $this;
26
    }
27
28
    public function setValues(array $values): Config
29
    {
30
        $this->values = $values;
31
32
        return $this;
33
    }
34
35
    public function mergeValues(array $values): Config
36
    {
37
        $this->values = array_merge($this->values, $values);
38
39
        return $this;
40
    }
41
42
    public function load(array $paths = []): Config
43
    {
44
        $path = $this->getOutputPath();
45
        if (!file_exists($path)) {
46
            return $this;
47
        }
48
49
        $this->values = array_merge($this->loadFile($path), $this->values);
50
51
        return $this;
52
    }
53
54
    public function build(): Config
55
    {
56
        $this->values = $this->substituteOutputDirs($this->values);
57
58
        return $this;
59
    }
60
}
61