AbstractNormalizer::normalize()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 7
rs 10
cc 2
nc 2
nop 2
1
<?php declare(strict_types=1);
2
3
namespace Mgid\Component\Pagination\Normalizer;
4
5
abstract class AbstractNormalizer implements NormalizerInterface
6
{
7
    /**
8
     * {@inheritdoc}
9
     */
10
    final public function normalize($value, string $operator)
11
    {
12
        if ($this->supportsNormalization($value, $operator)) {
13
            return $this->process($value, $operator);
14
        }
15
16
        return $value;
17
    }
18
19
    /**
20
     * @param mixed  $value
21
     * @param string $operator
22
     *
23
     * @return mixed
24
     */
25
    abstract protected function process($value, string $operator);
26
27
    /**
28
     * @param mixed  $value
29
     * @param string $operator
30
     *
31
     * @return bool
32
     */
33
    abstract protected function supportsNormalization($value, string $operator): bool;
34
}
35