HEX
Server: LiteSpeed
System: Linux php-prod-3.spaceapp.ru 5.15.0-151-generic #161-Ubuntu SMP Tue Jul 22 14:25:40 UTC 2025 x86_64
User: sarli3128 (1010)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /home/marketing.cfbon.ru/public_html/vendor/kreait/firebase-php/src/Firebase/DynamicLink.php
<?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 Stringable;

use function trim;

/**
 * @deprecated 7.14.0 Firebase Dynamic Links is deprecated and should not be used in new projects. The service will
 *                     shut down on August 25, 2025. The component will remain in the SDK until then, but as the
 *                     Firebase service is deprecated, this component is also deprecated
 *
 * @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, Stringable
{
    /**
     * @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;
    }
}