Completed
Push — master ( 0918de...c6b316 )
by BENOIT
01:36
created

ArrayValuesNormalizerRenderer   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 27
rs 10
c 0
b 0
f 0
wmc 2
lcom 1
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A render() 0 8 1
1
<?php
2
3
namespace BenTools\QueryString\Renderer;
4
5
use BenTools\QueryString\QueryString;
6
7
final class ArrayValuesNormalizerRenderer implements QueryStringRendererInterface
8
{
9
    /**
10
     * @var NativeRenderer
11
     */
12
    private $renderer;
13
14
    /**
15
     * ArrayValuesStringifier constructor.
16
     */
17
    public function __construct(QueryStringRendererInterface $renderer = null)
18
    {
19
        $this->renderer = $renderer ?? NativeRenderer::rfc3986();
0 ignored issues
show
Documentation Bug introduced by
It seems like $renderer ?? \BenTools\Q...tiveRenderer::rfc3986() of type object<BenTools\QueryStr...tringRendererInterface> or object<self> is incompatible with the declared type object<BenTools\QueryStr...enderer\NativeRenderer> of property $renderer.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
20
    }
21
22
    /**
23
     * @inheritDoc
24
     */
25
    public function render(QueryString $queryString): string
26
    {
27
        return preg_replace(
28
            '/\%5B\d+\%5D/',
29
            '%5B%5D',
30
            $this->renderer->render($queryString)
31
        );
32
    }
33
}
34