Passed
Push — master ( 661ff5...b3b57f )
by Fabrice
02:02
created

KeyUnsetTransformer::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
/*
4
 * This file is part of YaEtl.
5
 *     (c) Fabrice de Stefanis / https://github.com/fab2s/YaEtl
6
 * This source file is licensed under the MIT license which you will
7
 * find in the LICENSE file or at https://opensource.org/licenses/MIT
8
 */
9
10
namespace fab2s\YaEtl\Transformers\Arrays;
11
12
use fab2s\YaEtl\Transformers\TransformerAbstract;
13
14
/**
15
 * Class KeyUnsetTransformer
16
 */
17
class KeyUnsetTransformer extends TransformerAbstract
18
{
19
    /**
20
     * array of key to unset
21
     *
22
     * @var array
23
     */
24
    protected $unsetList;
25
26
    /**
27
     * @param array $unsetList array of key to unset
28
     */
29
    public function __construct(array $unsetList)
30
    {
31
        $this->unsetList = \array_unique($unsetList);
32
    }
33
34
    /**
35
     * Unsets keys in array
36
     *
37
     * @param mixed $record
38
     *
39
     * @return mixed
40
     */
41
    public function exec($record)
42
    {
43
        foreach ($this->unsetList as $keyName) {
44
            unset($record[$keyName]);
45
        }
46
47
        return $record;
48
    }
49
}
50