Passed
Pull Request — master (#3)
by De Cramer
03:42 queued 01:23
created

AbstractChainOperation   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 7
dl 0
loc 24
rs 10
c 2
b 0
f 0
ccs 4
cts 4
cp 1
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A process() 0 9 2
A processData() 0 3 1
A processStop() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Oliverde8\Component\PhpEtl\ChainOperation;
6
7
use Oliverde8\Component\PhpEtl\Item\DataItemInterface;
8
use Oliverde8\Component\PhpEtl\Item\ItemInterface;
9
use Oliverde8\Component\PhpEtl\Item\StopItem;
10
use Oliverde8\Component\PhpEtl\Model\ExecutionContext;
11
12
/**
13
 * Class AbstractChainOperation
14
 *
15
 * @author    de Cramer Oliver<[email protected]>
16
 * @copyright 2018 Oliverde8
17
 * @package Oliverde8\Component\PhpEtl\ChainOperation
18 13
 */
19
class AbstractChainOperation implements ChainOperationInterface
20 13
{
21
    /**
22 13
     * @inheritdoc
23 13
     */
24
    public function process(ItemInterface $item, ExecutionContext $context): ItemInterface
25
    {
26 4
        // TODO Make this more intelligent with a small cache not to make it slow.
27
        $method = 'process' . ucfirst($item->getMethod());
28
        if (method_exists($this, $method)) {
29
            return $this->$method($item, $context);
30
        }
31
32
        return $item;
33
    }
34
35
    protected function processData(DataItemInterface $item, ExecutionContext $context): ItemInterface
36
    {
37
        return $item;
38
    }
39
40
    protected function processStop(StopItem $item, ExecutionContext $context): ItemInterface
41
    {
42
        return $item;
43
    }
44
}
45