<?php

namespace App\Framework\QueryBus;

use App\Framework\DI\Container;
use App\Framework\DI\Initializer;
use App\Framework\Discovery\Results\DiscoveryResults;

final readonly class QueryBusInitializer
{
    public function __construct(
        private Container        $container,
        private DiscoveryResults $results
    ){}

    #[Initializer]
    public function __invoke(): QueryBus
    {
        $handlers = $this->results->get(QueryHandler::class);

        return new DefaultQueryBus($handlers, $this->container);
    }
}
