for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* Created by PhpStorm.
* User: jaredchu
* Date: 31/05/2017
* Time: 09:50
*/
namespace JC\HttpClient;
use GuzzleHttp;
use Psr\Http\Message\ResponseInterface;
class JCResponse implements JCResponseInterface
{
* @var ResponseInterface
public $response;
* @var string
protected $body;
* JCResponse constructor.
* @param $response
public function __construct($response)
if ($response) {
$this->response = $response;
$this->body = $this->response->getBody()->getContents();
}
public function status()
if ($this->hasResponse()) {
return $this->response->getStatusCode();
} else {
return false;
public function body()
return $this->body;
public function headers()
return $this->response->getHeaders();
return null;
public function json()
return GuzzleHttp\json_decode($this->body());
public function success()
return $this->response->getStatusCode() < 300;
protected function hasResponse()
return !is_null($this->response);