Passed
Branch master (4a352c)
by Allan
04:38 queued 02:31
created

Exploder   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 31
rs 10
c 0
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A process() 0 19 3
A __construct() 0 3 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\Constraint;
7
8
use Vaimo\ComposerPatches\Patch\Definition as PatchDefinition;
9
10
class Exploder
11
{
12
    /**
13
     * @var \Vaimo\ComposerPatches\Patch\Definition\Value\Analyser
14
     */
15
    private $valueAnalyser;
16
    
17
    public function __construct()
18
    {
19
        $this->valueAnalyser = new \Vaimo\ComposerPatches\Patch\Definition\Value\Analyser();
20
    }
21
    
22
    public function process($label, array $data)
23
    {
24
        $items = array();
25
        
26
        foreach ($data as $constraint => $source) {
27
            if (!$this->valueAnalyser->isConstraint($constraint)) {
28
                continue;
29
            }
30
31
            $items[] = array(
32
                $label,
33
                array(
34
                    PatchDefinition::VERSION => $constraint,
35
                    PatchDefinition::SOURCE => $source
36
                )
37
            );
38
        }
39
        
40
        return $items;
41
    }
42
}
43