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

ArrayMapTransformer   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
c 0
b 0
f 0
lcom 1
cbo 1
dl 0
loc 29
rs 10

2 Methods

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