Rfc3986Serializer::aggregate()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 6
cts 6
cp 1
rs 9.9332
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 2
1
<?php
2
3
namespace GuzzleHttp\Command\Guzzle\QuerySerializer;
4
5
class Rfc3986Serializer implements QuerySerializerInterface
6
{
7
    /**
8
     * @var bool
9
     */
10
    private $removeNumericIndices;
11
12
    /**
13
     * @param bool $removeNumericIndices
14
     */
15 4
    public function __construct($removeNumericIndices = false)
16
    {
17 4
        $this->removeNumericIndices = $removeNumericIndices;
18 4
    }
19
20
    /**
21
     * {@inheritDoc}
22
     */
23 4
    public function aggregate(array $queryParams)
24
    {
25 4
        $queryString = http_build_query($queryParams, null, '&', PHP_QUERY_RFC3986);
26
27 4
        if ($this->removeNumericIndices) {
28 1
            $queryString = preg_replace('/%5B[0-9]+%5D/simU', '%5B%5D', $queryString);
29 1
        }
30
31 4
        return $queryString;
32
    }
33
}