['invalid', null, 'No URL found with short code "invalid"']; yield 'invalid shortcode without domain' => [ 'abc123', 'example.com', 'No URL found with short code "abc123" for domain "example.com"', ]; yield 'invalid shortcode + domain' => [ 'custom-with-domain', 'example.com', 'No URL found with short code "custom-with-domain" for domain "example.com"', ]; } public function buildShortUrlPath(string $shortCode, ?string $domain, string $suffix = ''): string { $url = new Uri(sprintf('/short-urls/%s%s', $shortCode, $suffix)); if ($domain !== null) { $url = $url->withQuery(build_query(['domain' => $domain])); } return (string) $url; } }