1 | <?php declare(strict_types = 1); |
||
17 | abstract class AbstractResponder implements ResponderContract, ResponseFactoryAware |
||
18 | { |
||
19 | /** |
||
20 | * @var ResponseFactory |
||
21 | */ |
||
22 | private $responseFactory; |
||
23 | |||
24 | /** |
||
25 | * @inheritDoc |
||
26 | */ |
||
27 | public function setResponseFactory(ResponseFactory $factory) |
||
31 | |||
32 | protected function empty($status = 204, array $headers = []) |
||
36 | |||
37 | /** |
||
38 | * Creates html response. |
||
39 | * |
||
40 | * @param string $html |
||
41 | * @param int $status |
||
42 | * @param array $headers |
||
43 | * @return ResponseInterface |
||
44 | */ |
||
45 | protected function html(string $html, int $status = 200, array $headers = []): ResponseInterface |
||
49 | |||
50 | /** |
||
51 | * Creates HTTP response with JSON content type header and JSON encoded $data. |
||
52 | * |
||
53 | * @param mixed $data Data to convert to JSON. |
||
54 | * @param int $status Integer status code for the response; 200 by default. |
||
55 | * @param array $headers Array of headers to use at initialization. |
||
56 | * @param int $encodingOptions |
||
57 | * @return ResponseInterface |
||
58 | */ |
||
59 | protected function json( |
||
67 | |||
68 | /** |
||
69 | * Creates HTTP redirect response with $uri used as Location header. |
||
70 | * |
||
71 | * @param string|UriInterface $uri |
||
72 | * @param int $status |
||
73 | * @param array $headers |
||
74 | * @return ResponseInterface |
||
75 | */ |
||
76 | protected function redirect($uri, $status = 302, array $headers = []): ResponseInterface |
||
80 | |||
81 | /** |
||
82 | * Creates HTTP response. |
||
83 | * |
||
84 | * @param string $bodyStream Stream to use as response body. |
||
85 | * @param int $status |
||
86 | * @param array $headers |
||
87 | * @return ResponseInterface |
||
88 | */ |
||
89 | protected function response($bodyStream = 'php://memory', int $status = 200, array $headers = []): ResponseInterface |
||
93 | } |