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

KeyUnsetTransformer   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 33
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A exec() 0 8 2
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