/**
* Base constructor.
*
* @param string|array|ArrayObject $content Json content.
* @param array $headers Headers to attach to the response.
* @param bool $prettyPrint Should we use JSON_PRETTY_PRINT to nicely format the output.
*/
public function __construct($content, $headers = [], $prettyPrint = false)
{
if (StdObjectWrapper::isArrayObject($content)) {
$content = $this->jsonEncode($content->val(), $prettyPrint ? JSON_PRETTY_PRINT : 0);
} else {
if ($this->isArray($content) || $this->isObject($content)) {
$content = $this->jsonEncode($content, $prettyPrint ? JSON_PRETTY_PRINT : 0);
}
}
parent::__construct($content, 200, $headers);
$this->setContentType('application/json');
}