<?php

namespace EasyLinkAutomations\HTTP\Middleware;

if (!defined('ABSPATH')) {
    exit;
}

use EasyLinkAutomations\HTTP\Response;
use EasyLinkAutomations\Utils\Capabilities;

/**
 * Ensures the current user has `manage_options` capability.
 */
final class AdminCheckerMiddleware
{
    public function handle(): Response|bool
    {
        if (!Capabilities::check('manage_options')) {
            return Response::error('Access denied: administrator privileges required')->httpStatus(403);
        }

        return true;
    }
}
