Passed
Push — master ( 27afec...e8b4e9 )
by Klaas
01:42 queued 14s
created

ConfigPatcher   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Test Coverage

Coverage 61.53%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
c 1
b 0
f 0
dl 0
loc 39
ccs 8
cts 13
cp 0.6153
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A patch() 0 5 2
A __construct() 0 12 2
1
<?php declare(strict_types=1);
2
/**
3
 * Copyright MediaCT. All rights reserved.
4
 * https://www.mediact.nl
5
 */
6
7
namespace Mediact\CodingStandard\PhpStorm\Patcher;
8
9
use Mediact\CodingStandard\PhpStorm\EnvironmentInterface;
10
use Mediact\CodingStandard\PhpStorm\XmlAccessor;
11
12
class ConfigPatcher implements ConfigPatcherInterface
13
{
14
    /**
15
     * @var ConfigPatcherInterface[]
16
     */
17
    private $patchers;
18
19
    /**
20
     * Constructor.
21
     *
22
     * @param array $patchers
23
     */
24 1
    public function __construct(array $patchers = null)
25
    {
26 1
        $xmlAccessor = new XmlAccessor();
27
28 1
        $this->patchers = $patchers !== null
29 1
            ? $patchers
30
            : [
31
                new CodeStylePatcher(),
32
                new FileTemplatesPatcher($xmlAccessor),
33
                new InspectionsPatcher($xmlAccessor),
34
                new TemplateSettingsPatcher($xmlAccessor),
35
                new LiveTemplatesPatcher()
36
            ];
37 1
    }
38
39
    /**
40
     * Patch the config.
41
     *
42
     * @param EnvironmentInterface $environment
43
     *
44
     * @return void
45
     */
46 1
    public function patch(
47
        EnvironmentInterface $environment
48
    ): void {
49 1
        foreach ($this->patchers as $patcher) {
50 1
            $patcher->patch($environment);
51
        }
52 1
    }
53
}
54