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

AbstractNormalizer::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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