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

IgnoreColumns   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 80%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 28
ccs 8
cts 10
cp 0.8
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getColumns() 0 3 1
A execute() 0 10 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