Total Complexity | 3 |
Total Lines | 33 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
11 | final class HtmlDataResponseFormatter implements DataResponseFormatterInterface |
||
12 | { |
||
13 | /** |
||
14 | * @var string the Content-Type header for the response |
||
15 | */ |
||
16 | private string $contentType = 'text/html'; |
||
17 | |||
18 | /** |
||
19 | * @var string the XML encoding. |
||
20 | */ |
||
21 | private string $encoding = 'UTF-8'; |
||
22 | |||
23 | public function format(DataResponse $dataResponse): ResponseInterface |
||
24 | { |
||
25 | $data = $dataResponse->getData(); |
||
26 | $response = $dataResponse->getResponse(); |
||
27 | $response->getBody()->write((string)$data); |
||
28 | |||
29 | return $response->withHeader('Content-Type', $this->contentType . '; charset=' . $this->encoding); |
||
30 | } |
||
31 | |||
32 | public function withEncoding(string $encoding): self |
||
37 | } |
||
38 | |||
39 | public function withContentType(string $contentType): self |
||
44 | } |
||
45 | } |
||
46 |