1 | <?php declare(strict_types=1); |
||
8 | class HeadersBuilder |
||
9 | { |
||
10 | |||
11 | const DEFAULT_MAX_AGE = 3600; |
||
12 | |||
13 | const FORMAT_XML = 'xml'; |
||
14 | |||
15 | const DEFAULT_XML_CONTENT_TYPE = 'application/xhtml+xml'; |
||
16 | |||
17 | /** |
||
18 | * supported content-types |
||
19 | * @var array |
||
20 | */ |
||
21 | private $contentTypes = [ |
||
22 | self::FORMAT_XML => self::DEFAULT_XML_CONTENT_TYPE |
||
23 | ]; |
||
24 | |||
25 | /** |
||
26 | * if true, the response is marked s public |
||
27 | * @var bool |
||
28 | */ |
||
29 | private $public; |
||
30 | |||
31 | /** |
||
32 | * maximum amount of time before the cache gets invalidated (in seconds) |
||
33 | * @var int |
||
34 | */ |
||
35 | private $maxAge; |
||
36 | |||
37 | /** |
||
38 | * HeadersBuilder constructor. |
||
39 | * @param $public |
||
40 | * @param $maxAge |
||
41 | */ |
||
42 | 9 | public function __construct(bool $public = true, int $maxAge = self::DEFAULT_MAX_AGE) |
|
47 | |||
48 | 5 | public function setContentType(string $format, $value): void |
|
52 | |||
53 | 8 | public function setResponseHeaders(Response $response, string $format, \DateTime $lastModified): void |
|
62 | |||
63 | 8 | private function getContentType(string $format): string |
|
67 | |||
68 | } |
||
69 |