1 | <?php |
||
19 | abstract class AbstractResponse implements ResponseInterface |
||
20 | { |
||
21 | /** |
||
22 | * @var int |
||
23 | */ |
||
24 | protected $httpCode = 0; |
||
25 | |||
26 | /** |
||
27 | * @var \Zend\Diactoros\Response |
||
28 | */ |
||
29 | protected $response; |
||
30 | |||
31 | /** |
||
32 | * @var array |
||
33 | */ |
||
34 | protected $headers = [ |
||
35 | 'Content-type' => 'application/json; charset=utf-8', |
||
36 | 'Cache-Control' => 'private, max-age=0, must-revalidate', |
||
37 | ]; |
||
38 | |||
39 | /** |
||
40 | * @param string $json |
||
41 | */ |
||
42 | public function __construct($json) |
||
46 | |||
47 | /** |
||
48 | * @param string $body |
||
49 | * @param int $status |
||
50 | * @param array $headers |
||
51 | * |
||
52 | * @return AbstractResponse |
||
53 | */ |
||
54 | protected function instance($body, $status = 200, array $headers = []) |
||
61 | |||
62 | /** |
||
63 | * {@inheritdoc} |
||
64 | */ |
||
65 | public function getStatusCode() |
||
69 | |||
70 | /** |
||
71 | * {@inheritdoc} |
||
72 | */ |
||
73 | public function getReasonPhrase() |
||
77 | |||
78 | /** |
||
79 | * {@inheritdoc} |
||
80 | */ |
||
81 | public function getProtocolVersion() |
||
85 | |||
86 | /** |
||
87 | * {@inheritdoc} |
||
88 | */ |
||
89 | public function withProtocolVersion($version) |
||
93 | |||
94 | /** |
||
95 | * {@inheritdoc} |
||
96 | */ |
||
97 | public function getHeaders() |
||
101 | |||
102 | /** |
||
103 | * {@inheritdoc} |
||
104 | */ |
||
105 | public function hasHeader($header) |
||
109 | |||
110 | /** |
||
111 | * {@inheritdoc} |
||
112 | */ |
||
113 | public function getHeader($header) |
||
117 | |||
118 | /** |
||
119 | * {@inheritdoc} |
||
120 | */ |
||
121 | public function getHeaderLine($name) |
||
125 | |||
126 | /** |
||
127 | * {@inheritdoc} |
||
128 | */ |
||
129 | public function withHeader($header, $value) |
||
133 | |||
134 | /** |
||
135 | * {@inheritdoc} |
||
136 | */ |
||
137 | public function withAddedHeader($header, $value) |
||
141 | |||
142 | /** |
||
143 | * {@inheritdoc} |
||
144 | */ |
||
145 | public function withoutHeader($header) |
||
149 | |||
150 | /** |
||
151 | * @return string |
||
152 | */ |
||
153 | public function getBody() |
||
157 | |||
158 | /** |
||
159 | * {@inheritdoc} |
||
160 | */ |
||
161 | public function withBody(StreamInterface $body) |
||
165 | |||
166 | /** |
||
167 | * {@inheritdoc} |
||
168 | */ |
||
169 | public function withStatus($code, $reasonPhrase = '') |
||
173 | } |
||
174 |