ConfigPatcher::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2.686

Importance

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