SanitizeParameters   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A rawurlencode() 0 17 2
1
<?php
2
3
namespace Thinktomorrow\Locale\Parsers;
4
5
class SanitizeParameters
6
{
7
    /**
8
     * Loop over the parameters and make sure they are properly url encoded.
9
     *
10
     * @param array $parameters
11
     *
12
     * @return array
13
     */
14 31
    public static function rawurlencode(array $parameters): array
15
    {
16
        return array_map(function ($param) {
17
            // Null values are kept as is, so they'll get properly removed.
18 20
            if (null === $param) {
19 1
                return $param;
20
            }
21
22 20
            $param = rawurlencode($param);
23
24 20
            $param = str_replace('%2F', '/', $param);
25 20
            $param = str_replace('%3F', '?', $param);
26 20
            $param = str_replace('%3D', '=', $param);
27
28 20
            return $param;
29 31
        }, $parameters);
30
    }
31
}
32