VersionConfigComponent::explode()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 2
dl 0
loc 3
rs 10
c 0
b 0
f 0
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\ExploderComponents;
7
8
use Vaimo\ComposerPatches\Patch\Definition as PatchDefinition;
9
10
class VersionConfigComponent implements \Vaimo\ComposerPatches\Interfaces\DefinitionExploderComponentInterface
11
{
12
    /**
13
     * @var \Vaimo\ComposerPatches\Patch\Definition\Value\Analyser
14
     */
15
    private $valueAnalyser;
16
17
    /**
18
     * @var \Vaimo\ComposerPatches\Patch\Definition\Constraint\Exploder
19
     */
20
    private $definitionExploder;
21
22
    public function __construct()
23
    {
24
        $this->valueAnalyser = new \Vaimo\ComposerPatches\Patch\Definition\Value\Analyser();
25
        $this->definitionExploder = new \Vaimo\ComposerPatches\Patch\Definition\Constraint\Exploder();
26
    }
27
28
    public function shouldProcess($label, $data)
29
    {
30
        if (!is_array($data)) {
31
            return false;
32
        }
33
34
        $key = key($data);
35
        $value = reset($data);
36
37
        return !isset($value[PatchDefinition::VERSION], $value[PatchDefinition::DEPENDS]) &&
38
            $this->valueAnalyser->isConstraint($key);
39
    }
40
41
    public function explode($label, $data)
42
    {
43
        return $this->definitionExploder->process($label, $data);
44
    }
45
}
46