Passed
Push — master ( 25c805...999286 )
by Andy
02:56 queued 11s
created

AbstractNormalizer   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Test Coverage

Coverage 76.92%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
eloc 10
dl 0
loc 39
ccs 10
cts 13
cp 0.7692
rs 10
c 1
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A normalize() 0 9 2
A getNormalizer() 0 3 1
A setNormalizer() 0 5 1
A __construct() 0 3 1
1
<?php
2
3
namespace Palmtree\Csv\Normalizer;
4
5
abstract class AbstractNormalizer implements NormalizerInterface
6
{
7
    /** @var NormalizerInterface|null */
8
    protected $normalizer;
9
10 10
    public function __construct(?NormalizerInterface $normalizer = null)
11
    {
12 10
        $this->setNormalizer($normalizer);
13 10
    }
14
15
    /**
16
     * @return mixed
17
     */
18
    abstract protected function getNormalizedValue(string $value);
19
20
    /**
21
     * @inheritdoc
22
     */
23 10
    public function normalize(string $value)
24
    {
25 10
        if ($this->normalizer) {
26
            $value = $this->normalizer->normalize($value);
27
        }
28
29 10
        $value = $this->getNormalizedValue($value);
30
31 10
        return $value;
32
    }
33
34 10
    public function setNormalizer(?NormalizerInterface $normalizer = null): self
35
    {
36 10
        $this->normalizer = $normalizer;
37
38 10
        return $this;
39
    }
40
41
    public function getNormalizer(): ?NormalizerInterface
42
    {
43
        return $this->normalizer;
44
    }
45
}
46