1 | <?php |
||
9 | abstract class BaseApiResponse implements ApiResponse |
||
10 | { |
||
11 | /** @var int */ |
||
12 | protected $code; |
||
13 | |||
14 | /** @var mixed */ |
||
15 | protected $data; |
||
16 | |||
17 | /** @var string */ |
||
18 | protected $contentType; |
||
19 | |||
20 | /** @var string */ |
||
21 | protected $charset; |
||
22 | |||
23 | /** @var string|int|DateTimeInterface */ |
||
24 | protected $expiration = 0; |
||
25 | |||
26 | /** |
||
27 | * @param int $code |
||
28 | * @param mixed $data |
||
29 | * @param string $contentType |
||
30 | * @param string $charset |
||
31 | */ |
||
32 | 22 | public function __construct($code, $data, $contentType, $charset) |
|
39 | |||
40 | /** |
||
41 | * @param string|int|DateTimeInterface $expiration |
||
42 | * @return BaseApiResponse |
||
43 | */ |
||
44 | public function setExpiration($expiration) |
||
49 | |||
50 | /** |
||
51 | * Return api response http code |
||
52 | * @return integer |
||
53 | */ |
||
54 | 22 | public function getCode() |
|
58 | |||
59 | /** |
||
60 | * @return mixed |
||
61 | */ |
||
62 | 22 | public function getData() |
|
66 | |||
67 | /** |
||
68 | * Returns the MIME content type of a downloaded file. |
||
69 | * @return string |
||
70 | */ |
||
71 | 12 | public function getContentType() |
|
75 | |||
76 | /** |
||
77 | * Return encoding charset for http response |
||
78 | * @return string |
||
79 | */ |
||
80 | 12 | public function getCharset() |
|
84 | |||
85 | /** |
||
86 | * @param IRequest $httpRequest |
||
87 | * @param IResponse $httpResponse |
||
88 | */ |
||
89 | public function send(IRequest $httpRequest, IResponse $httpResponse) |
||
98 | } |
||
99 |