ListNormalizer   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 3
c 1
b 0
f 0
dl 0
loc 19
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A supportsNormalization() 0 3 2
A process() 0 3 2
1
<?php declare(strict_types=1);
2
3
namespace Mgid\Component\Pagination\Normalizer;
4
5
use Mgid\Component\Pagination\Contract\FilterableInterface;
6
7
final class ListNormalizer extends AbstractNormalizer
8
{
9
    /**
10
     * @param mixed  $value
11
     * @param string $operator
12
     *
13
     * @return string[]
14
     */
15
    protected function process($value, string $operator): array
16
    {
17
        return \explode(',', $value) ?: [];
18
    }
19
20
    /**
21
     * {@inheritdoc}
22
     */
23
    protected function supportsNormalization($value, string $operator): bool
24
    {
25
        return \is_string($value) && \in_array($operator, [FilterableInterface::IN, FilterableInterface::NOT_IN], true);
26
    }
27
}
28