for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* Part of the AmazonGiftCode package.
* Author: Kashyap Merai <[email protected]>
*
*/
namespace kamerk22\AmazonGiftCode\Response;
class CancelResponse
{
* Amazon Gift Card gcId.
* @var string
protected $_id;
* Amazon Gift Card creationRequestId
protected $_creation_request_id;
* Amazon Gift Card status
protected $_status;
* Amazon Gift Card Raw JSON
protected $_raw_json;
* Response constructor.
* @param $jsonResponse
public function __construct($jsonResponse)
$this->_raw_json = $jsonResponse;
$this->_status = TRUE;
$_status
string
TRUE
true
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.
$answer = 42; $correct = false; $correct = (bool) $answer;
$this->parseJsonResponse($jsonResponse);
}
* @return string
public function getId(): string
return $this->_id;
public function getCreationRequestId(): string
return $this->_creation_request_id;
public function getStatus(): string
return $this->_status;
public function getRawJson(): string
return json_encode($this->_raw_json);
* @return CancelResponse
public function parseJsonResponse($jsonResponse): self
if (!is_array($jsonResponse)) {
throw new \RuntimeException('Response must be a scalar value');
if (array_key_exists('gcId', $jsonResponse)) {
$this->_id = $jsonResponse['gcId'];
if (array_key_exists('creationRequestId', $jsonResponse)) {
$this->_creation_request_id = $jsonResponse['creationRequestId'];
return $this;
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.