Skip to content

Instantly share code, notes, and snippets.

@leitom
Created June 27, 2017 11:54
Show Gist options
  • Save leitom/127e7670b075cca3d6009c8a5a10583b to your computer and use it in GitHub Desktop.
Save leitom/127e7670b075cca3d6009c8a5a10583b to your computer and use it in GitHub Desktop.
Zonda?
<?php
trait Http
{
function wrapGuzzle($guzzle)
{
return new class($guzzle) {
private $guzzle;
public function __construct($guzzle)
{
$this->guzzle = $guzzle;
}
public function __call($method, $arguments)
{
$response = call_user_func_array([$this->guzzle, $method], $arguments);
if (in_array($method, ['get', 'post', 'delete', 'put', 'patch'])) {
return json_decode((string) $response->getBody(), true);
}
return $response;
}
};
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment