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

AbstractNormalizer::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

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