true, 'data' => $data ], $status ); } public static function sendFail( string $message, int $status = 400, array $details = [] ): Response { $data = ['message' => $message]; if (!empty($details)) { $data['details'] = $details; } return self::json( [ 'success' => false, 'data' => $data ], $status ); } private static function json(array $payload, int $status): Response { $json = json_encode($payload, JSON_UNESCAPED_UNICODE); if ($json === false) { // fallback extremo: nunca quebrar a API $json = '{"success":false,"error":"Response encoding error"}'; $status = 500; } return new Response( $status, [ 'Content-Type' => 'application/json', 'Cache-Control' => 'no-store' ], $json ); } }