| Total Complexity | 3 |
| Total Lines | 17 |
| Duplicated Lines | 0 % |
| Changes | 6 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 13 | final readonly class UriFactory |
||
|
|
|||
| 14 | { |
||
| 15 | public function __construct( |
||
| 16 | #[ContextScheme] |
||
| 17 | private string $schemaHost = 'page://self', |
||
| 18 | ) { |
||
| 19 | } |
||
| 20 | |||
| 21 | /** @param Query $query */ |
||
| 22 | public function __invoke(string $uri, array $query = []): Uri |
||
| 23 | { |
||
| 24 | $parsedUrl = (array) parse_url($uri); |
||
| 25 | if (! array_key_exists('scheme', $parsedUrl)) { |
||
| 26 | $uri = $this->schemaHost . $uri; |
||
| 27 | } |
||
| 28 | |||
| 29 | return new Uri($uri, $query); |
||
| 30 | } |
||
| 32 |