<?php

declare(strict_types=1);

namespace App\Framework\MagicLinks;

use App\Framework\DI\Container;
use App\Framework\DI\Initializer;
use App\Framework\MagicLinks\Actions\ActionRegistry;
use App\Framework\MagicLinks\Actions\DefaultActionRegistry;
use App\Framework\MagicLinks\Actions\EmailVerificationAction;
use App\Framework\MagicLinks\Services\CacheMagicLinkService;
use App\Framework\MagicLinks\Services\MagicLinkService;

final readonly class MagicLinkInitializer
{
    public function __construct(
        private Container $container
    ) {
    }

    #[Initializer]
    public function __invoke(): ActionRegistry
    {
        $registry = new DefaultActionRegistry();

        $registry->register(new EmailVerificationAction());

        return $registry;
    }

    #[Initializer]
    public function init(): MagicLinkService
    {
        return $this->container->get(CacheMagicLinkService::class);
    }
}
