<?php

namespace MintyPHP\Module\Bookmarks;

use MintyPHP\App\AppContainer;
use MintyPHP\App\Container\ContainerRegistrar;
use MintyPHP\Module\Bookmarks\Service\BookmarkRepositoryFactory;
use MintyPHP\Module\Bookmarks\Service\BookmarkService;
use MintyPHP\Module\Bookmarks\Service\BookmarkServicesFactory;

final class BookmarksContainerRegistrar implements ContainerRegistrar
{
    public function register(AppContainer $container): void
    {
        $container->set(BookmarkRepositoryFactory::class, static fn (): BookmarkRepositoryFactory => new BookmarkRepositoryFactory());
        $container->set(BookmarkServicesFactory::class, static fn (AppContainer $c): BookmarkServicesFactory => new BookmarkServicesFactory(
            $c->get(BookmarkRepositoryFactory::class)
        ));
        $container->set(BookmarkService::class, static fn (AppContainer $c): BookmarkService => $c->get(BookmarkServicesFactory::class)->createBookmarkService());
    }
}
