for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace ScayTrase\Api\JsonRpc;
final class JsonRpcError implements JsonRpcErrorInterface
{
/** @var int */
private $code;
/** @var string */
private $message;
/** @var null|\stdClass */
private $data;
/**
* JsonRpcError constructor.
* @param int $code
* @param string $message
* @param \stdClass|mixed|null $data
*/
public function __construct($code, $message, $data = null)
$this->code = $code;
$this->message = $message;
$this->data = $data;
}
/** {@inheritdoc} */
public function getCode()
return $this->code;
public function getMessage()
return $this->message;
public function getData()
return $this->data;
public function jsonSerialize()
$error = [
self::ERROR_CODE_FIELD => $this->getCode(),
self::ERROR_MESSAGE_FIELD => $this->getMessage(),
];
if (null !== ($data = $this->getData())) {
$error[self::ERROR_DATA_FIELD] = $data;
return $error;