Passed
Push — master ( b97c32...e7e450 )
by Carlos C
10:36 queued 12s
created

IgnoreColumns::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
nc 1
nop 2
crap 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 array $columns;
11
12 7
    public function __construct(ArrayProcessorInterface $next = null, int ...$columns)
13
    {
14 7
        parent::__construct($next);
15 7
        $this->columns = array_values($columns);
16
    }
17
18
    /** @return array<int, int> */
19
    public function getColumns(): array
20
    {
21
        return $this->columns;
22
    }
23
24
    /** @inheritdoc */
25 7
    public function execute(array $array): array
26
    {
27 7
        $array = array_values(
28 7
            array_filter(
29
                $array,
30 7
                fn (int $key): bool => ! in_array($key, $this->columns, true),
31
                ARRAY_FILTER_USE_KEY
32
            )
33
        );
34 7
        return parent::execute($array);
35
    }
36
}
37