<?php
declare(strict_types=1);

namespace App\Middleware;

use App\Core\Response;
use App\Core\MiddlewareInterface;

/**
 * Role and Permission validation
 */
class RoleMiddleware implements MiddlewareInterface
{
    public function handle(): bool
    {
        // This middleware usually takes parameters, but since our handler
        // is called without them, we'd need to check the specific route requirements
        // stored in $_REQUEST or defined globally.
        // For a foundation, we ensure the user has a role.
        if (!isset($_REQUEST['user']['role'])) {
            Response::error('Permission Denied', [], 403);
            return false;
        }
        return true;
    }
}
