SequenceItemComponent   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 30
rs 10
c 0
b 0
f 0
wmc 7

3 Methods

Rating   Name   Duplication   Size   Complexity  
A shouldProcess() 0 10 5
A explode() 0 6 1
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\ExploderComponents;
7
8
use Vaimo\ComposerPatches\Patch\Definition as PatchDefinition;
9
10
class SequenceItemComponent implements \Vaimo\ComposerPatches\Interfaces\DefinitionExploderComponentInterface
11
{
12
    /**
13
     * @var \Vaimo\ComposerPatches\Patch\Definition\Exploder\ItemBuilder
14
     */
15
    private $itemBuilder;
16
17
    public function __construct()
18
    {
19
        $this->itemBuilder = new \Vaimo\ComposerPatches\Patch\Definition\Exploder\ItemBuilder();
20
    }
21
22
    public function shouldProcess($label, $data)
23
    {
24
        if (!is_array($data)) {
25
            return false;
26
        }
27
28
        return is_numeric($label)
29
            && isset($data[PatchDefinition::LABEL], $data[PatchDefinition::SOURCE])
30
            && is_array($data[PatchDefinition::SOURCE])
31
            && is_array(reset($data[PatchDefinition::SOURCE]));
32
    }
33
34
    public function explode($label, $data)
35
    {
36
        return $this->itemBuilder->createMultiple(
37
            $data[PatchDefinition::LABEL],
38
            $data,
39
            PatchDefinition::SOURCE
40
        );
41
    }
42
}
43