<?php

declare(strict_types=1);

namespace Apexl\Io\Routing;

use Slim\Routing\RouteGroup;

/**
 * A route group that will say what was attached to it.
 *
 * Slim already keeps a group's middleware as a plain list, so this only has to expose it —
 * unlike a route, where middleware disappears into a chain of anonymous handlers.
 *
 * The reason it matters: middleware added to a group never passes through `Route::add()`, and
 * Slim does not even attach it until the route is first handled. Without this, a permission
 * put on a group would be enforced perfectly and be invisible to everything that asks a route
 * what it requires — so the menu would keep offering pages that answer 403. Enforced but
 * unreadable is the one combination worth ruling out.
 */
final class IoRouteGroup extends RouteGroup
{
    public function getMiddleware(): MiddlewareCollection
    {
        return new MiddlewareCollection(array_values($this->middleware));
    }
}
