<?php
declare(strict_types=1);

namespace App\Core;

final class ApiResponse
{
    public static function success($data, array $meta = []): array
    {
        return ['success' => true, 'data' => $data, 'meta' => $meta, 'errors' => null];
    }

    public static function error(string $message, int $code = 400, array $errors = []): array
    {
        return ['success' => false, 'data' => null, 'meta' => [], 'errors' => $errors ?: [$message]];
    }

    public static function paginated(array $data, array $pagination, array $meta = []): array
    {
        return [
            'success' => true,
            'data' => $data,
            'meta' => array_merge($meta, ['pagination' => $pagination]),
            'errors' => null,
        ];
    }
}
