Passed
Push — master ( 2bfb13...b8de7b )
by De Cramer
02:14
created

CallbackTransformerOperation   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 18
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A processData() 0 4 1
1
<?php
2
3
namespace Oliverde8\Component\PhpEtl\ChainOperation\Transformer;
4
5
use Oliverde8\Component\PhpEtl\ChainOperation\AbstractChainOperation;
6
use Oliverde8\Component\PhpEtl\ChainOperation\DataChainOperationInterface;
7
use Oliverde8\Component\PhpEtl\Item\DataItemInterface;
8
use Oliverde8\Component\PhpEtl\Item\ItemInterface;
9
10
/**
11
 * Class CallbackTransformerOperation
12
 *
13
 * @author    de Cramer Oliver<[email protected]>
14
 * @copyright 2018 Oliverde8
15
 * @package Oliverde8\Component\PhpEtl\ChainOperation\Transformer
16
 */
17
class CallbackTransformerOperation extends AbstractChainOperation implements DataChainOperationInterface
18
{
19
    protected $callback;
20
21
    /**
22
     * CallbackTransformerOperation constructor.
23
     *
24
     * @param $callback
25
     */
26 4
    public function __construct($callback)
27
    {
28 4
        $this->callback = $callback;
29 4
    }
30
31 4
    public function processData(DataItemInterface $item, array &$context): ItemInterface
32
    {
33 4
        $method = $this->callback;
34 4
        return $method($item, $context);
35
    }
36
}