/** * Constructor. * * @param string $content Content. * @param int $status [optional] Response status code. Default: 404. * @param array $headers [optional] Headers array. */ public function __construct($content = '', $status = 404, $headers = array()) { if (!is_array($headers)) { throw new InvalidArgumentException('array', $headers, 3); } parent::__construct($content, $status, $headers); }
/** * Constructor. * * @param string $url URL to redirect to. * @param int $status [optional] Response status code. Default: 302. * @param array $headers [optional] Headers array. */ public function __construct($url = '', $status = 302, $headers = array()) { if (empty($url)) { throw new InvalidArgumentException('non-empty string', $url); } if (!is_array($headers)) { throw new InvalidArgumentException('array', $headers, 3); } parent::__construct('', $status, array('Location' => $url)); $this->url = $url; }
/** * Constructor. * * @param array $data [optional] Array of data to be sent in JSON. * @param int $status [optional] HTTP response status code. Default: 200. * @param array $headers [optional] Headers array. */ public function __construct($data = '', $status = 200, $headers = array()) { if (!is_array($data)) { throw new InvalidArgumentException('array', $data); } if (!is_array($headers)) { throw new InvalidArgumentException('array', $headers, 3); } $this->jsonData = $data; $headers = array_merge($headers, array('Content-Type' => 'application/json')); parent::__construct('', $status, $headers); }