Passed
Push — master ( 7bba5d...c1c3fd )
by Fabrice
02:35
created

ArrayMapTransformer::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
rs 10
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 ArrayMapTransformer
16
 */
17
class ArrayMapTransformer extends TransformerAbstract
18
{
19
    /**
20
     * Any callable with one argument which returns something
21
     *
22
     * @var callable
23
     */
24
    protected $maper;
25
26
    /**
27
     * @param callable $maper
28
     */
29
    public function __construct(callable $maper)
30
    {
31
        $this->maper = $maper;
32
    }
33
34
    /**
35
     * Execute the array_map call
36
     *
37
     * @param mixed $record
38
     *
39
     * @return mixed
40
     */
41
    public function exec($record)
42
    {
43
        return \array_map($this->maper, $record);
44
    }
45
}
46