public function __construct(mixed
$data = null, int
$status = 200, array
$headers =
[], bool
$json = false
) { parent::
__construct('',
$status,
$headers);
if ($json && !\
is_string($data) && !
is_numeric($data) && !\
is_callable([$data, '__toString'
])) { throw new \
TypeError(sprintf('"%s": If $json is set to true, argument $data must be a string or object implementing __toString(), "%s" given.', __METHOD__,
get_debug_type($data)));
} $data ??=
new \
ArrayObject();
$json ?
$this->
setJson($data) :
$this->
setData($data);
} /**
* Factory method for chainability.
*
* Example:
*
* return JsonResponse::fromJsonString('{"key": "value"}')
* ->setSharedMaxAge(300);
*
* @param string $data The JSON response string
* @param int $status The response status code (200 "OK" by default)
* @param array $headers An array of response headers
*/