<?php

declare(strict_types=1);

namespace App\Core\Middleware;

use App\Core\Authorization;

final class PermissionMiddleware implements MiddlewareInterface
{
    public function __construct(private readonly string $permission)
    {
    }

    public function handle(callable $next): mixed
    {
        Authorization::requirePermission($this->permission);
        return $next();
    }
}
