KeyUnsetTransformer   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 34
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A exec() 0 7 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\NodalFlow\NodalFlowException;
13
use fab2s\YaEtl\Transformers\TransformerAbstract;
14
15
/**
16
 * Class KeyUnsetTransformer
17
 */
18
class KeyUnsetTransformer extends TransformerAbstract
19
{
20
    /**
21
     * array of key to unset
22
     *
23
     * @var array
24
     */
25
    protected $unsetList;
26
27
    /**
28
     * @param array $unsetList array of key to unset
29
     *
30
     * @throws NodalFlowException
31
     */
32
    public function __construct(array $unsetList)
33
    {
34
        $this->unsetList = \array_unique($unsetList);
35
        parent::__construct();
36
    }
37
38
    /**
39
     * Unsets keys in array
40
     *
41
     * @param array $record
42
     *
43
     * @return array
44
     */
45
    public function exec($record = null)
46
    {
47
        foreach ($this->unsetList as $keyName) {
48
            unset($record[$keyName]);
49
        }
50
51
        return $record;
52
    }
53
}
54