System   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 6
Bugs 0 Features 0
Metric Value
wmc 6
eloc 14
c 6
b 0
f 0
dl 0
loc 40
ccs 0
cts 15
cp 0
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setValue() 0 5 1
A setValues() 0 5 1
A mergeValues() 0 5 1
A build() 0 5 1
A load() 0 10 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