Completed
Push — master ( c6b316...f71d6f )
by BENOIT
01:20
created

ArrayValuesNormalizerRenderer::getEncoding()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
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
    /**
35
     * @inheritDoc
36
     */
37
    public function getEncoding(): int
38
    {
39
        return $this->renderer->getEncoding();
40
    }
41
42
    /**
43
     * @inheritDoc
44
     */
45
    public function withEncoding(int $encoding): QueryStringRendererInterface
46
    {
47
        return new self($this->renderer->withEncoding($encoding));
48
    }
49
50
    /**
51
     * @inheritDoc
52
     */
53
    public function getSeparator(): string
54
    {
55
        return $this->renderer->getSeparator();
56
    }
57
58
    /**
59
     * @inheritDoc
60
     */
61
    public function withSeparator(?string $separator): QueryStringRendererInterface
62
    {
63
        return new self($this->renderer->withSeparator($separator));
64
    }
65
}
66