OutputStrategy   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 25
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A shouldAllowForPatches() 0 9 1
A __construct() 0 4 1
1
<?php
2
/**
3
 * Copyright © Vaimo Group. All rights reserved.
4
 * See LICENSE_VAIMO.txt for license details.
5
 */
6
namespace Vaimo\ComposerPatches\Strategies;
7
8
class OutputStrategy
9
{
10
    /**
11
     * @var array
12
     */
13
    private $outputTriggers;
14
15
    /**
16
     * @param array $outputTriggers
17
     */
18
    public function __construct(
19
        $outputTriggers = array()
20
    ) {
21
        $this->outputTriggers = $outputTriggers;
22
    }
23
24
    public function shouldAllowForPatches(array $patches)
25
    {
26
        $muteTriggersMatcher = array_flip($this->outputTriggers);
27
28
        return (bool)array_filter(
29
            $patches,
30
            function (array $patch) use ($muteTriggersMatcher) {
31
                return array_filter(
32
                    array_intersect_key($patch, $muteTriggersMatcher)
33
                );
34
            }
35
        );
36
    }
37
}
38