OutputStrategy::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 4
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\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