<?php

declare(strict_types=1);

namespace App\Middlewares;

use App\Helpers\Request;

class RoleMiddleware
{
    private string $role;

    public function __construct(string $role)
    {
        $this->role = $role;
    }

    public function handle(Request $request): mixed
    {
        $userRole = $request->param('auth_user_role');

        if ($userRole !== $this->role) {
            return 'No tiene permisos para realizar esta acción';
        }

        return null;
    }
}
