Rfc3986Serializer   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 29
c 0
b 0
f 0
wmc 3
lcom 1
cbo 0
ccs 9
cts 9
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A aggregate() 0 10 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
}