Total Complexity | 7 |
Total Lines | 41 |
Duplicated Lines | 0 % |
Coverage | 94.74% |
Changes | 0 |
1 | <?php |
||
9 | class ResponseSender |
||
10 | { |
||
11 | protected $response; |
||
12 | |||
13 | 1 | public function __construct(ResponseInterface $response) |
|
14 | { |
||
15 | 1 | $this->response = $response; |
|
16 | 1 | } |
|
17 | |||
18 | 1 | public function sendResponse() |
|
19 | { |
||
20 | 1 | $this->sendHeaders(); |
|
21 | 1 | $this->sendContent(); |
|
22 | |||
23 | 1 | return $this; |
|
24 | } |
||
25 | |||
26 | 1 | public function sendHeaders() |
|
27 | { |
||
28 | 1 | $res = $this->response; |
|
29 | |||
30 | 1 | if (headers_sent($file, $line)) { |
|
31 | return $this; |
||
32 | } |
||
33 | |||
34 | 1 | foreach ($res->getHeaders() as $name => $values) { |
|
35 | 1 | foreach ($values as $value) { |
|
36 | 1 | header($name.': '.$value, false, $res->getStatusCode()); |
|
37 | } |
||
38 | } |
||
39 | |||
40 | 1 | header(sprintf('HTTP/%s %s %s', $res->getProtocolVersion(), $res->getStatusCode(), $res->getReasonPhrase())); |
|
41 | |||
42 | 1 | return $this; |
|
43 | } |
||
44 | |||
45 | 1 | public function sendContent() |
|
50 | } |
||
51 | } |
||
52 |