Passed
Push — master ( d96a4c...76b07c )
by Carlos C
05:39
created

IgnoreColumns   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 86.67%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 12
c 1
b 0
f 0
dl 0
loc 29
ccs 13
cts 15
cp 0.8667
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getColumns() 0 3 1
A execute() 0 12 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PhpCfdi\SatCatalogosPopulate\Utils\ArrayProcessors;
6
7
class IgnoreColumns extends AbstractPipeArrayProcessor implements ArrayProcessorInterface
8
{
9
    /** @var array<int, int> */
10
    private $columns;
11
12 6
    public function __construct(ArrayProcessorInterface $next = null, int ...$columns)
13
    {
14 6
        parent::__construct($next);
15 6
        $this->columns = $columns;
16 6
    }
17
18
    /** @return array<int, int> */
19
    public function getColumns(): array
20
    {
21
        return $this->columns;
22
    }
23
24 6
    public function execute(array $array): array
25
    {
26 6
        $array = array_values(
27 6
            array_filter(
28 6
                $array,
29 6
                function (int $key): bool {
30 6
                    return ! in_array($key, $this->columns, true);
31 6
                },
32 6
                ARRAY_FILTER_USE_KEY
33
            )
34
        );
35 6
        return parent::execute($array);
36
    }
37
}
38