<?php

namespace EasyLinkAutomations\HTTP;

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

/**
 * Request type detection — identifies whether the current request
 * is an AJAX call, a REST API call, or an admin page request.
 */
final class RequestType
{
    public const AJAX  = 'ajax';
    public const API   = 'api';
    public const ADMIN = 'admin';

    public static function is(string $type): bool
    {
        return match ($type) {
            self::AJAX  => wp_doing_ajax(),
            self::API   => defined('REST_REQUEST') && REST_REQUEST,
            self::ADMIN => is_admin(),
            default     => false,
        };
    }
}
