SkipComponent   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 18
rs 10
c 0
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A normalize() 0 16 3
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\NormalizerComponents;
7
8
use Vaimo\ComposerPatches\Patch\Definition as PatchDefinition;
9
10
class SkipComponent implements \Vaimo\ComposerPatches\Interfaces\DefinitionNormalizerComponentInterface
11
{
12
    public function normalize($target, $label, array $data, array $ownerConfig)
13
    {
14
        $source = $data[PatchDefinition::SOURCE];
15
        $flag = '#' . PatchDefinition::SKIP;
16
17
        if (strstr($source, $flag) !== $flag) {
18
            return array(
19
                PatchDefinition::SKIP => isset($data[PatchDefinition::SKIP])
20
                    ? $data[PatchDefinition::SKIP]
21
                    : false
22
            );
23
        }
24
25
        return array(
26
            PatchDefinition::SOURCE => substr($source, 0, strrpos($source, $flag)),
27
            PatchDefinition::SKIP => true
28
        );
29
    }
30
}
31