예제 #1
0
 /**
  * @param string $message
  * @param int    $code
  * @param null   $data
  */
 public function __construct($message, $code = 500, $data = null)
 {
     $body = json_encode(array_filter(['status' => 'error', 'code' => $code, 'message' => (string) $message, 'data' => '']));
     if ($data) {
         $body = str_replace('"data": ""', substr(substr($data, 1), 0, -1), $body);
     }
     $this->response = parent::instance($body, 500, $this->headers);
 }
예제 #2
0
 /**
  * @param string $content
  */
 public function __construct($content)
 {
     $this->response = parent::instance(sprintf('{"status": "success", %s}', substr(substr($content, 1), 0, -1)), 200, $this->headers);
 }