/**
* Gets the SSE data decoded as an array when it's a JSON payload.
*/
public function getArrayData(): array
{ if (null !==
$this->jsonData
) { return $this->jsonData;
} if ('' ===
$this->data
) { throw new JsonException(sprintf('Server-Sent Event%s data is empty.', '' !==
$this->id ?
sprintf(' "%s"',
$this->id
) : ''
));
} try { $jsonData =
json_decode($this->data, true, 512, \JSON_BIGINT_AS_STRING | \JSON_THROW_ON_ERROR
);
} catch (\JsonException
$e) { throw new JsonException(sprintf('Decoding Server-Sent Event%s failed: ', '' !==
$this->id ?
sprintf(' "%s"',
$this->id
) : ''
).
$e->
getMessage(),
$e->
getCode());
} if (!\
is_array($jsonData)) { throw new JsonException(sprintf('JSON content was expected to decode to an array, "%s" returned in Server-Sent Event%s.',
get_debug_type($jsonData), '' !==
$this->id ?
sprintf(' "%s"',
$this->id
) : ''
));
}