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