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