1 | <?php |
||
5 | class ResponseBuilder |
||
6 | { |
||
7 | |||
8 | private $request; |
||
9 | |||
10 | private $contentTypes = []; |
||
11 | |||
12 | 3 | public function __construct($request) |
|
16 | |||
17 | |||
18 | 3 | public function create() |
|
26 | |||
27 | |||
28 | 2 | private function attemptSettingContentType($instance) |
|
29 | { |
||
30 | 2 | $header = $this->request->getAcceptHeader(); |
|
31 | |||
32 | 2 | if ($header === null) { |
|
33 | 1 | return; |
|
34 | } |
||
35 | |||
36 | 1 | foreach ($this->contentTypes as $candidate) { |
|
37 | 1 | if ($header->contains($candidate)) { |
|
38 | 1 | $this->applyContentTypeHeader($instance, $candidate); |
|
39 | 1 | return; |
|
40 | } |
||
41 | } |
||
42 | } |
||
43 | |||
44 | |||
45 | 1 | private function applyContentTypeHeader($instance, $value) |
|
50 | |||
51 | 2 | public function setAvailableContentTypes($contentTypes) |
|
55 | } |
||
56 |