<?php

declare(strict_types=1);

namespace Apexl\Io\Validation\Hooks;

use Apexl\Io\Interfaces\AbstractHook;
use Apexl\Io\System\Collections\MiddlewareCollectionCollection;
use Apexl\Io\System\Services\MiddlewareCollector;
use Apexl\Io\Validation\Middleware\ValidationMiddleware;

final readonly class AddMiddleware implements AbstractHook
{
    public function hooks(): array
    {
        return [MiddlewareCollector::HOOK__COLLECT];
    }

    public function __invoke(MiddlewareCollectionCollection $weightedMiddleware): MiddlewareCollectionCollection
    {
        $weightedMiddleware->add(ValidationMiddleware::class);

        return $weightedMiddleware;
    }
}
