Total Complexity | 8 |
Total Lines | 49 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
9 | abstract class AbstractParametersProcessor implements ParametersProcessorInterface |
||
10 | { |
||
11 | protected $parametersToProcess = []; |
||
12 | |||
13 | /** |
||
14 | * @var ConverterInterface |
||
15 | */ |
||
16 | protected $converter; |
||
17 | |||
18 | 8 | public function __construct(ConverterInterface $converter, array $parametersToProcess = []) |
|
19 | { |
||
20 | 8 | $this->converter = $converter; |
|
21 | 8 | $this->parametersToProcess = $parametersToProcess; |
|
22 | 8 | } |
|
23 | |||
24 | 2 | public function setParametersToProcess(array $parametersToProcess): ParametersProcessorInterface |
|
25 | { |
||
26 | 2 | $this->parametersToProcess = $parametersToProcess; |
|
27 | |||
28 | 2 | return $this; |
|
29 | } |
||
30 | |||
31 | 8 | public function getParametersToProcess(): array |
|
34 | } |
||
35 | |||
36 | 3 | public function getConverter(): ConverterInterface |
|
37 | { |
||
38 | 3 | return $this->converter; |
|
39 | } |
||
40 | |||
41 | 7 | public function process(array $parameters): array |
|
42 | { |
||
43 | 7 | foreach ($this->getParametersToProcess() as $parameter) { |
|
44 | 5 | if (isset($parameters[$parameter])) { |
|
45 | 5 | $parameters[$parameter] = $this->processValue($parameters[$parameter]); |
|
46 | } |
||
47 | } |
||
48 | |||
49 | 7 | return $parameters; |
|
50 | } |
||
51 | |||
52 | 4 | public function needToProcess(): bool |
|
55 | } |
||
56 | |||
57 | abstract protected function processValue($value); |
||
58 | } |
||
59 |