Total Complexity | 6 |
Total Lines | 47 |
Duplicated Lines | 0 % |
Coverage | 66.67% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
5 | abstract class AbstractNormalizer implements NormalizerInterface |
||
6 | { |
||
7 | /** @var NormalizerInterface|null */ |
||
8 | protected $normalizer; |
||
9 | |||
10 | 10 | public function __construct(?NormalizerInterface $normalizer = null) |
|
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()); |
||
|
|||
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) |
|
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 |
||
52 | } |
||
53 | } |
||
54 |