<?php
declare(strict_types=1);
namespace Helpers;

final class Response
{
    public static function json(array $data, int $status = 200): never
    {
        http_response_code($status);
        echo json_encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
        exit;
    }

    public static function success(mixed $data = null, string $message = 'Success', int $status = 200, array $meta = []): never
    {
        self::json(['success' => true, 'message' => $message, 'data' => $data, 'meta' => $meta], $status);
    }

    public static function error(string $message, int $status = 400, array $errors = []): never
    {
        self::json(['success' => false, 'message' => $message, 'errors' => $errors], $status);
    }
}
