Normalizer   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 14
c 0
b 0
f 0
dl 0
loc 40
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A process() 0 18 3
A __construct() 0 5 1
1
<?php
2
/**
3
 * Copyright © Vaimo Group. All rights reserved.
4
 * See LICENSE_VAIMO.txt for license details.
5
 */
6
namespace Vaimo\ComposerPatches\Patch\Definition;
7
8
class Normalizer
9
{
10
    /**
11
     * @var \Vaimo\ComposerPatches\Interfaces\DefinitionNormalizerComponentInterface[]
12
     */
13
    private $components;
14
15
    /**
16
     * @var  \Vaimo\ComposerPatches\Patch\Definition\SourceResolver
17
     */
18
    private $sourceResolver;
19
20
    /**
21
     * @param \Vaimo\ComposerPatches\Interfaces\DefinitionNormalizerComponentInterface[] $components
22
     */
23
    public function __construct(
24
        array $components
25
    ) {
26
        $this->components = $components;
27
        $this->sourceResolver = new \Vaimo\ComposerPatches\Patch\Definition\SourceResolver();
28
    }
29
30
    public function process($target, $label, $data, array $ownerConfig)
31
    {
32
        $data = $this->sourceResolver->updateSourceDeclaration($label, $data);
33
34
        $config = array();
35
36
        foreach ($this->components as $component) {
37
            $updates = $component->normalize($target, $label, $data, $ownerConfig);
38
39
            if (empty($updates)) {
40
                continue;
41
            }
42
43
            $config = array_replace($config, $updates);
44
            $data = array_replace($data, $updates);
45
        }
46
47
        return $config;
48
    }
49
}
50