1 | <?php declare(strict_types=1); |
||
30 | abstract class BaseResponses implements ResponsesInterface |
||
31 | { |
||
32 | /** Header name that contains format of input data from client */ |
||
33 | const HEADER_CONTENT_TYPE = HeaderParametersParserInterface::HEADER_CONTENT_TYPE; |
||
34 | |||
35 | /** Header name that location of newly created resource */ |
||
36 | const HEADER_LOCATION = 'Location'; |
||
37 | |||
38 | /** |
||
39 | * Create HTTP response. |
||
40 | * |
||
41 | * @param string|null $content |
||
42 | * @param int $statusCode |
||
43 | * @param array $headers |
||
44 | * |
||
45 | * @return mixed |
||
46 | */ |
||
47 | abstract protected function createResponse(?string $content, int $statusCode, array $headers); |
||
48 | |||
49 | /** |
||
50 | * @return EncoderInterface |
||
51 | */ |
||
52 | abstract protected function getEncoder(): EncoderInterface; |
||
53 | |||
54 | /** |
||
55 | * @return MediaTypeInterface |
||
56 | */ |
||
57 | abstract protected function getMediaType(): MediaTypeInterface; |
||
58 | |||
59 | /** |
||
60 | * @inheritdoc |
||
61 | */ |
||
62 | 2 | public function getContentResponse($data, int $statusCode = self::HTTP_OK, array $headers = []) |
|
68 | |||
69 | /** |
||
70 | * @inheritdoc |
||
71 | */ |
||
72 | 2 | public function getCreatedResponse($resource, string $url, array $headers = []) |
|
79 | |||
80 | /** |
||
81 | * @inheritdoc |
||
82 | */ |
||
83 | 1 | public function getCodeResponse(int $statusCode, array $headers = []) |
|
87 | |||
88 | /** |
||
89 | * @inheritdoc |
||
90 | */ |
||
91 | 2 | public function getMetaResponse($meta, int $statusCode = self::HTTP_OK, array $headers = []) |
|
97 | |||
98 | /** |
||
99 | * @inheritDoc |
||
100 | */ |
||
101 | 2 | public function getIdentifiersResponse($data, int $statusCode = self::HTTP_OK, array $headers = []) |
|
107 | |||
108 | /** |
||
109 | * @inheritdoc |
||
110 | * |
||
111 | * @SuppressWarnings(PHPMD.ElseExpression) |
||
112 | */ |
||
113 | 4 | public function getErrorResponse($errors, int $statusCode = self::HTTP_BAD_REQUEST, array $headers = []) |
|
125 | |||
126 | /** |
||
127 | * @param string|null $content |
||
128 | * @param int $statusCode |
||
129 | * @param array $headers |
||
130 | * @param bool $addContentType |
||
131 | * |
||
132 | * @return mixed |
||
133 | * |
||
134 | * @SuppressWarnings(PHPMD.BooleanArgumentFlag) |
||
135 | */ |
||
136 | 13 | protected function createJsonApiResponse( |
|
148 | } |
||
149 |