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

IgnoreColumns::getColumns()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
cc 1
nc 1
nop 0
crap 2
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