-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRpcResponse.php
48 lines (41 loc) · 993 Bytes
/
RpcResponse.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
namespace ScayTrase\Api\Rest;
use ScayTrase\Api\Rpc\RpcErrorInterface;
use ScayTrase\Api\Rpc\RpcResponseInterface;
/** @internal */
final class RpcResponse implements RpcResponseInterface
{
/** @var \stdClass|array|mixed|null */
private $body;
/** @var RpcErrorInterface */
private $error;
/**
* ResponseImpl constructor.
*
* @param array|mixed|null|\stdClass $body
* @param RpcErrorInterface $error
*/
public function __construct($body, RpcErrorInterface $error = null)
{
$this->body = $body;
$this->error = $error;
}
/** {@inheritdoc} */
public function getError()
{
return $this->error;
}
/** {@inheritdoc} */
public function getBody()
{
if ($this->isSuccessful()) {
return $this->body;
}
return null;
}
/** {@inheritdoc} */
public function isSuccessful()
{
return null === $this->error;
}
}