<?php

declare(strict_types=1);

namespace apexl\Io\modules\tabulator\Factories;

use apexl\Io\modules\tabulator\Controllers\TabulatorAjaxController;
use apexl\Io\modules\tabulator\Interfaces\HasTabulatorViewInterface;
use DI\Container;
use DI\DependencyException;
use DI\NotFoundException;
use function apexl\Io\assertInstanceOf;

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

    /**
     * @param class-string<HasTabulatorViewInterface> $entityClass
     * @throws DependencyException
     * @throws NotFoundException
     */
    public function make(string $entityClass): TabulatorAjaxController
    {
        assertInstanceOf($entityClass, HasTabulatorViewInterface::class);

        return $this->container->make(TabulatorAjaxController::class, ['entityClass' => $entityClass]);
    }
}