AbstractExtractor   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 88.89%

Importance

Changes 1
Bugs 1 Features 0
Metric Value
eloc 8
c 1
b 1
f 0
dl 0
loc 31
ccs 8
cts 9
cp 0.8889
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A addTransformer() 0 3 1
A transformData() 0 11 3
1
<?php
2
3
namespace Smart\EtlBundle\Extractor;
4
5
use Smart\EtlBundle\Transformer\TransformerInterface;
6
7
/**
8
 * Nicolas Bastien <[email protected]>
9
 */
10
abstract class AbstractExtractor
11
{
12
    /**
13
     * @var TransformerInterface[]
14
     */
15
    protected $transformers = [];
16
17
    /**
18
     * @param TransformerInterface $transformer
19
     * @return mixed
20
     */
21 1
    public function addTransformer(TransformerInterface $transformer)
22
    {
23 1
        $this->transformers[] = $transformer;
24 1
    }
25
26
    /**
27
     * @param  array $data
28
     * @return mixed
29
     */
30 7
    protected function transformData(array $data)
31
    {
32 7
        foreach ($this->transformers as $transformer) {
33 1
            $data = $transformer->transform($data);
34 1
            if (is_null($data)) {
35
                //allow transformer to skip invalid data
36
                return null;
37
            }
38
        }
39
40 7
        return $data;
41
    }
42
}
43