Test Failed
Push — master ( f0f126...457d36 )
by Andy
01:35
created

AbstractNormalizer   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Test Coverage

Coverage 66.67%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
eloc 11
dl 0
loc 47
ccs 10
cts 15
cp 0.6667
rs 10
c 1
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A normalize() 0 9 2
A getNormalizer() 0 3 1
A create() 0 3 1
A setNormalizer() 0 5 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
     * Alternative method of instantiation for chaining.
17
     */
18
    public static function create(): self
19
    {
20
        return new static(...\func_get_args());
0 ignored issues
show
Bug introduced by
func_get_args() is expanded, but the parameter $normalizer of Palmtree\Csv\Normalizer\...rmalizer::__construct() does not expect variable arguments. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

20
        return new static(/** @scrutinizer ignore-type */ ...\func_get_args());
Loading history...
21
    }
22
23
    /**
24
     * @return mixed
25
     */
26
    abstract protected function getNormalizedValue(string $value);
27
28
    /**
29
     * @inheritdoc
30
     */
31 10
    public function normalize(string $value)
32
    {
33 10
        if ($this->normalizer) {
34
            $value = $this->normalizer->normalize($value);
35
        }
36
37 10
        $value = $this->getNormalizedValue($value);
38
39 10
        return $value;
40
    }
41
42 10
    public function setNormalizer(?NormalizerInterface $normalizer = null): self
43
    {
44 10
        $this->normalizer = $normalizer;
45
46 10
        return $this;
47
    }
48
49
    public function getNormalizer(): ?NormalizerInterface
50
    {
51
        return $this->normalizer;
52
    }
53
}
54