| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Webauthn; |
| 6 | |
| 7 | /** |
| 8 | * Represents a URL that can be either an absolute HTTPS URL or a Symfony route name. |
| 9 | * For Passkey Endpoints, URLs must always be absolute HTTPS URLs. |
| 10 | * |
| 11 | * @see https://w3c.github.io/webappsec-passkey-endpoints/ |
| 12 | */ |
| 13 | final readonly class Url |
| 14 | { |
| 15 | /** |
| 16 | * @param string $path The absolute HTTPS URL or Symfony route name |
| 17 | * @param array<string, mixed> $params Route parameters (only used when path is a route name) |
| 18 | */ |
| 19 | public function __construct( |
| 20 | public string $path, |
| 21 | public array $params = [], |
| 22 | ) { |
| 23 | } |
| 24 | |
| 25 | /** |
| 26 | * @param array<string, mixed> $params Route parameters |
| 27 | */ |
| 28 | public static function create(string $path, array $params = []): self |
| 29 | { |
| 30 | return new self($path, $params); |
| 31 | } |
| 32 | } |