<?php declare(strict_types=1); namespace Kreait\Firebase; use Beste\Json; use GuzzleHttp\Psr7\Utils; use JsonSerializable; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\UriInterface; use function trim; /** * @see https://github.com/googleapis/google-api-nodejs-client/blob/main/src/apis/firebasedynamiclinks/v1.ts * * @phpstan-type DynamicLinkWarningShape array{ * warningCode?: non-empty-string, * warningDocumentLink?: non-empty-string, * warningMessage?: non-empty-string * } * @phpstan-type DynamicLinkShape array{ * shortLink: non-empty-string, * previewLink?: non-empty-string, * warning?: list<DynamicLinkWarningShape> * } */ final class DynamicLink implements JsonSerializable { /** * @param DynamicLinkShape $data */ private function __construct(private readonly array $data) { } public function __toString(): string { return (string) $this->uri(); } /** * @internal */ public static function fromApiResponse(ResponseInterface $response): self { return new self(Json::decode((string) $response->getBody(), true)); } public function uri(): UriInterface { return Utils::uriFor($this->data['shortLink']); } public function previewUri(): ?UriInterface { $previewLink = $this->data['previewLink'] ?? null; return $previewLink !== null ? Utils::uriFor($previewLink) : null; } /** * @return non-empty-string */ public function domain(): string { $uri = $this->uri(); return $uri->getScheme().'://'.$uri->getHost(); } public function suffix(): string { return trim($this->uri()->getPath(), '/'); } /** * @return list<DynamicLinkWarningShape> */ public function warnings(): array { return $this->data['warning'] ?? []; } public function hasWarnings(): bool { return !empty($this->warnings()); } public function jsonSerialize(): array { return $this->data; } }
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
AppCheck | Folder | 0755 |
|
|
Auth | Folder | 0755 |
|
|
Contract | Folder | 0755 |
|
|
Database | Folder | 0755 |
|
|
DynamicLink | Folder | 0755 |
|
|
Exception | Folder | 0755 |
|
|
Http | Folder | 0755 |
|
|
Messaging | Folder | 0755 |
|
|
RemoteConfig | Folder | 0755 |
|
|
Request | Folder | 0755 |
|
|
Util | Folder | 0755 |
|
|
Value | Folder | 0755 |
|
|
AppCheck.php | File | 1.32 KB | 0644 |
|
Auth.php | File | 22.53 KB | 0644 |
|
Database.php | File | 2.2 KB | 0644 |
|
DynamicLink.php | File | 2.04 KB | 0644 |
|
DynamicLinks.php | File | 5.26 KB | 0644 |
|
Factory.php | File | 20.57 KB | 0644 |
|
Firestore.php | File | 558 B | 0644 |
|
Messaging.php | File | 7.69 KB | 0644 |
|
RemoteConfig.php | File | 3.52 KB | 0644 |
|
Request.php | File | 131 B | 0644 |
|
Storage.php | File | 1.18 KB | 0644 |
|
Util.php | File | 1.55 KB | 0644 |
|