QueryStringUriParser::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 3
cp 0
crap 2
rs 10
1
<?php
2
/**
3
 * @author    Philip Bergman <[email protected]>
4
 * @copyright Zicht Online <http://www.zicht.nl>
5
 */
6
namespace Zicht\Bundle\UrlBundle\Url\Params;
7
8
/**
9
 * Parser for key/value pairs in the url.
10
 */
11
class QueryStringUriParser extends UriParser
12
{
13
    /**
14
     * Constructor; overridden to disable the separator parameters
15
     */
16
    public function __construct()
17
    {
18
        parent::__construct();
19
    }
20
21
22
    /**
23
     * Compose an URI from the passed params with the local separators
24
     *
25
     * @param Params $params
26
     * @return string
27
     */
28
    public function composeUri($params)
29
    {
30
        $ret   = [];
31
32
        foreach ($params as $param => $values) {
33
            $internal = $param;
34
            if ($external = $this->translateKeyOutput($param)) {
35
                $param = $external;
36
            }
37
            $ret[$param] = [];
38
            foreach ($values as $value) {
39
                if ($external = $this->translateValueOutput($internal, $value)) {
40
                    $value = $external;
41
                }
42
                $ret[$param][]= $value;
43
            }
44
        }
45
46
        return http_build_query($ret);
47
    }
48
}
49