for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace EtherpadLite;
use Psr\Http\Message\ResponseInterface;
class Response
{
const CODE_OK = 0;
const CODE_WRONG_PARAMETERS = 1;
const CODE_INTERNAL_ERROR = 2;
const CODE_NO_SUCH_FUNCTION = 3;
const CODE_NO_OR_WRONG_API_KEY = 4;
/** @var array */
private $data;
/**
* @param ResponseInterface $response
*/
public function __construct(ResponseInterface $response)
if ($response->getStatusCode() === 200) {
$this->data = (array) \GuzzleHttp\json_decode($response->getBody(), true);
} else {
$this->data = array();
}
* @return string|null
public function getCode()
return $this->getPropertyFromData('code');
public function getMessage()
return $this->getPropertyFromData('message');
public function getData()
return $this->getPropertyFromData('data');
* @return array
public function getResponse()
return $this->data;
* @param string $key
* @return mixed
private function getPropertyFromData($key)
return isset($this->data[$key]) ? $this->data[$key] : null;