Skip to content

Instantly share code, notes, and snippets.

@PeeHaa
Created June 29, 2017 14:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PeeHaa/f67163c64b2a797ee388fb13535130d5 to your computer and use it in GitHub Desktop.
Save PeeHaa/f67163c64b2a797ee388fb13535130d5 to your computer and use it in GitHub Desktop.
v1 vs v2
public function appendResponse(Response $response)
{
try {
$events = \json_try_decode($response->getBody(), true);
} catch (DecodeErrorException $e) {
$this->logger->emergency('Failed to decode response body as JSON', ['exception' => $e]);
throw new DecodingFailedException('Failed to decode response body as JSON', $e->getCode(), $e);
}
foreach ($events as $event) {
$this->appendEvent($event);
}
}
public function appendResponse(Response $response)
{
try {
$events = \json_try_decode(yield $response->getBody()->read(), true);
} catch (DecodeErrorException $e) {
$this->logger->emergency('Failed to decode response body as JSON', ['exception' => $e]);
throw new DecodingFailedException('Failed to decode response body as JSON', $e->getCode(), $e);
}
foreach ($events as $event) {
$this->appendEvent($event);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment