debug !== true) { return $this->getMessage(); } return [ 'message' => $this->getMessage(), 'stacktrace' => get_class($this) . ': ' . $this->getTraceAsString() ]; } /** * Build the Response object to return. * * @param int $code HTTP status. * * @return Response with status + body. */ protected function buildApiResponse($code) { $style = $this->debug ? JSON_PRETTY_PRINT : null; return $this->response->withJson($this->getApiResponseBody(), $code, $style); } /** * @param Response $response */ public function setResponse($response) { $this->response = $response; } /** * @param bool $debug */ public function setDebug($debug) { $this->debug = $debug; } }