1 | <?php |
||
11 | class JsonApiResponse implements ResponseInterface |
||
12 | { |
||
13 | use SmartObject; |
||
14 | |||
15 | /** @var integer */ |
||
16 | private $code; |
||
17 | |||
18 | /** @var array */ |
||
19 | private $payload; |
||
20 | |||
21 | /** @var string */ |
||
22 | private $contentType; |
||
23 | |||
24 | /** @var string */ |
||
25 | private $charset; |
||
26 | |||
27 | /** @var DateTimeInterface|null */ |
||
28 | private $expiration; |
||
29 | |||
30 | 21 | public function __construct(int $code, array $payload, string $contentType = 'application/json', string $charset = 'utf-8', ?DateTimeInterface $expiration = null) |
|
31 | { |
||
32 | 21 | $this->code = $code; |
|
33 | 21 | $this->payload = $payload; |
|
34 | 21 | $this->contentType = $contentType ?: 'application/json'; |
|
35 | 21 | $this->charset = $charset; |
|
36 | 21 | $this->expiration = $expiration; |
|
37 | 21 | } |
|
38 | |||
39 | /** |
||
40 | * {@inheritdoc} |
||
41 | */ |
||
42 | 21 | public function getCode(): int |
|
46 | |||
47 | 21 | public function getPayload(): array |
|
51 | |||
52 | 9 | public function getContentType(): string |
|
56 | |||
57 | 9 | public function getCharset(): string |
|
61 | |||
62 | 3 | public function getExpiration(): ?DateTimeInterface |
|
66 | |||
67 | /** |
||
68 | * {@inheritdoc} |
||
69 | */ |
||
70 | 3 | public function send(IRequest $httpRequest, IResponse $httpResponse): void |
|
78 | } |
||
79 |