CallbackTransformerOperation   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 21
ccs 6
cts 6
cp 1
rs 10
wmc 2

2 Methods

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