Total Complexity | 5 |
Total Lines | 23 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
10 | final class UrlGenerator |
||
11 | { |
||
12 | private string $baseUrl; |
||
13 | |||
14 | 10 | public function __construct(string $baseUrl) |
|
17 | 10 | } |
|
18 | |||
19 | 10 | public function to(string $path, array $query = []): string |
|
20 | { |
||
21 | 10 | $query = array_filter($query); |
|
22 | |||
23 | 10 | if (count($query) === 0) { |
|
24 | 6 | return $this->format($path); |
|
25 | } |
||
26 | |||
27 | 4 | return $this->format($path) . '?' . http_build_query($query); |
|
28 | } |
||
29 | |||
30 | 10 | private function format(string $path): string |
|
33 | } |
||
34 | } |
||
35 |