Conditions | 6 |
Paths | 32 |
Total Lines | 27 |
Code Lines | 17 |
Lines | 0 |
Ratio | 0 % |
Tests | 16 |
CRAP Score | 6.0493 |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
15 | 2 | public static function addOrUpdateArgs(string $url, string $key, mixed $value = null): string |
|
16 | { |
||
17 | 2 | $a = parse_url($url); |
|
18 | 2 | $query = $a['query'] ?? ''; |
|
19 | |||
20 | 2 | parse_str($query, $params); |
|
21 | 2 | $params[$key] = $value; |
|
22 | 2 | $query = http_build_query($params); |
|
23 | |||
24 | 2 | $result = ''; |
|
25 | 2 | if (!empty($a['scheme'])) { |
|
26 | 2 | $result .= $a['scheme'].':'; |
|
27 | } |
||
28 | 2 | if (!empty($a['host'])) { |
|
29 | 2 | $result .= '//'.$a['host']; |
|
30 | } |
||
31 | 2 | if (!empty($a['port'])) { |
|
32 | $result .= ':'.$a['port']; |
||
33 | } |
||
34 | 2 | if (!empty($a['path'])) { |
|
35 | $result .= $a['path']; |
||
36 | } |
||
37 | 2 | if ($query) { |
|
38 | 2 | $result .= '?'.$query; |
|
39 | } |
||
40 | |||
41 | 2 | return $result; |
|
42 | } |
||
44 |