<?php

/**
 * REST API response helper functions  ArraySubs
 *
 * This file contains utility functions for formatting and sending
 * consistent REST API responses throughout the plugin.
 *
 * @package ArraySubs
 * @subpackage Functions
 * @since 1.0.0
 */

if (! defined('ABSPATH')) {
exit; // Exit if accessed directly
}

// if function not exists
if (!function_exists('arraysubs_rest_response')) {

    function arraysubs_rest_response($content = null, $status = 200, $message = null, $headers = array(), $options = array(), $code = null)
    {
        return new WP_REST_Response(
            [
                'code' => $code ?? $status,
                'message' => $message,
                'content' => $content
            ],
            $status,
            $headers,
        );
    }
}
