1 | <?php |
||
16 | final class JSendErrorResponse extends AbstractJSendResponse implements JSendErrorResponseInterface |
||
17 | { |
||
18 | /** |
||
19 | * @var string |
||
20 | */ |
||
21 | private $message; |
||
22 | /** |
||
23 | * @var int|null |
||
24 | */ |
||
25 | private $code; |
||
26 | |||
27 | /** |
||
28 | * JSendErrorResponse constructor. |
||
29 | * |
||
30 | * @param StatusInterface $status |
||
31 | * @param array $response |
||
32 | */ |
||
33 | public function __construct(StatusInterface $status, array $response) |
||
40 | |||
41 | /** |
||
42 | * @return int|null |
||
43 | */ |
||
44 | public function getCode(): ?int |
||
48 | |||
49 | /** |
||
50 | * @return string |
||
51 | */ |
||
52 | public function getMessage(): string |
||
56 | |||
57 | /** |
||
58 | * @return array |
||
59 | */ |
||
60 | public function asArray(): array |
||
61 | { |
||
62 | return array_merge( |
||
63 | array_filter(parent::asArray()), |
||
64 | array_filter([ |
||
65 | 'message' => $this->message, |
||
66 | 'code' => $this->code |
||
67 | ]) |
||
68 | ); |
||
69 | } |
||
70 | |||
71 | /** |
||
72 | * @return JSendErrorResponseInterface |
||
73 | */ |
||
74 | public function getError(): JSendErrorResponseInterface |
||
78 | } |