| @@ 16-25 (lines=10) @@ | ||
| 13 | * @param int $status The response status code |
|
| 14 | * @param array $headers An array of response headers |
|
| 15 | */ |
|
| 16 | public function __construct($data = null, $status = 200, $headers = []) |
|
| 17 | { |
|
| 18 | parent::__construct('', $status, $headers); |
|
| 19 | ||
| 20 | if (null === $data) { |
|
| 21 | $data = new \ArrayObject(); |
|
| 22 | } |
|
| 23 | ||
| 24 | $this->setContent($data); |
|
| 25 | } |
|
| 26 | ||
| 27 | /** |
|
| 28 | * We need this because setData() does json encoding already and |
|
| @@ 15-24 (lines=10) @@ | ||
| 12 | * @param array $headers An array of response headers |
|
| 13 | * @param bool $json If the data is already a JSON string |
|
| 14 | */ |
|
| 15 | public function __construct($data = null, int $status = 200, array $headers = [], bool $json = false) |
|
| 16 | { |
|
| 17 | parent::__construct('', $status, $headers); |
|
| 18 | ||
| 19 | if (null === $data) { |
|
| 20 | $data = new \ArrayObject(); |
|
| 21 | } |
|
| 22 | ||
| 23 | $this->setContent($data); |
|
| 24 | } |
|
| 25 | ||
| 26 | /** |
|
| 27 | * Sets the response content. |
|