CallbackTransformerOperation::processData()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 4
rs 10
c 1
b 0
f 0
ccs 1
cts 1
cp 1
crap 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
}