<?php

declare(strict_types=1);

/*
 * This file is part of the Ferienpass package.
 *
 * (c) Richard Henkenjohann <richard@ferienpass.online>
 *
 * For more information visit the project website <https://ferienpass.online>
 * or the documentation under <https://docs.ferienpass.online>.
 */

namespace Ferienpass\AdminBundle\Message;

use Ferienpass\CoreBundle\Entity\User;
use Ferienpass\CoreBundle\Message\LoggableMessageInterface;

class LoginLinkRequested implements LoggableMessageInterface
{
    /** Magic links are off because the member turned e-mail sign-in off. */
    public const DENIED_BY_USER = 'user';

    /** Magic links are off because of the admin role-scoped kill-switch. */
    public const DENIED_FOR_ADMIN = 'admin';

    /**
     * @param string      $loginLink    the ready-built, host-rebased login link;
     *                                  empty when $deniedReason is set
     * @param string|null $deniedReason null → send the login link; otherwise the
     *                                  handler sends a short explanatory mail
     *                                  (no link) with the matching reason text.
     *                                  Delivering via this (async-routed) message
     *                                  keeps mail off the web request, preserving
     *                                  enumeration safety.
     */
    public function __construct(private readonly string $userUuid, private readonly string $loginLink = '', private readonly ?string $deniedReason = null)
    {
    }

    public function getUserUuid(): string
    {
        return $this->userUuid;
    }

    public function getLoginLink(): string
    {
        return $this->loginLink;
    }

    public function getDeniedReason(): ?string
    {
        return $this->deniedReason;
    }

    public function getRelated(): array
    {
        return [
            User::class => $this->userUuid,
        ];
    }
}
