<?php

declare(strict_types=1);

namespace apexl\Io\factories;

use apexl\Io\enums\HttpMethod;
use apexl\Io\utilityIncludes\Route;
use DI\Container;
use DI\DependencyException;
use DI\NotFoundException;

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

    /**
     * @throws DependencyException
     * @throws NotFoundException
     */
    public function make(
        string $name,
        string $pattern,
        string|array|callable $callable,
        HttpMethod $method,
        array $args = [],
        array $middleware = []
    ): Route {
        return $this->container->make(Route::class, [
            'name' => $name,
            'pattern' => $pattern,
            'callable' => $callable,
            'method' => $method,
            'args' => $args,
            'middleware' => $middleware,
        ]);
    }
}