for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace EtherpadLite;
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;
private $response = array();
/**
* @param \Guzzle\Http\Message\Response $response
*/
public function __construct(\Guzzle\Http\Message\Response $response)
if ($response->isSuccessful()) {
$this->response = $response->json();
if (is_array($this->response)) {
foreach ($this->response as $key => $value) {
$this->response[$key] = $value;
}
} else {
else
This check looks for the else branches of if statements that have no statements or where all statements have been commented out. This may be the result of changes for debugging or the code may simply be obsolete.
if
These else branches can be removed.
if (rand(1, 6) > 3) { print "Check failed"; } else { //print "Check succeeded"; }
could be turned into
if (rand(1, 6) > 3) { print "Check failed"; }
This is much more concise to read.
// TODO: Error handling
* @return string|null
public function getCode()
return isset($this->response['code']) ? $this->response['code'] : null;
public function getMessage()
return isset($this->response['message']) ? $this->response['message'] : null;
public function getData()
return isset($this->response['data']) ? $this->response['data'] : null;
* Returns the entire response from Etherpad Lite API
*
* @return array
public function getResponse()
return $this->response;
This check looks for the
elsebranches ofifstatements that have no statements or where all statements have been commented out. This may be the result of changes for debugging or the code may simply be obsolete.These
elsebranches can be removed.could be turned into
This is much more concise to read.