/** * Allows response to be type cast into a string when handling * * @return string */ public function __toString() { $resultJSON = $this->encodeResponse(); $callback = $this->request->getCallback(); if (!empty($callback)) { return "{$callback}({$resultJSON})"; } else { return $resultJSON; } }