| Total Complexity | 7 |
| Total Lines | 41 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 9 | class ResponseSender |
||
| 10 | { |
||
| 11 | protected $response; |
||
| 12 | |||
| 13 | 2 | public function __construct(ResponseInterface $response) |
|
| 14 | { |
||
| 15 | 2 | $this->response = $response; |
|
| 16 | 2 | } |
|
| 17 | |||
| 18 | 2 | public function sendResponse() |
|
| 19 | { |
||
| 20 | 2 | $this->sendHeaders(); |
|
| 21 | 2 | $this->sendContent(); |
|
| 22 | |||
| 23 | 2 | return $this; |
|
| 24 | } |
||
| 25 | |||
| 26 | 2 | public function sendHeaders() |
|
| 27 | { |
||
| 28 | 2 | $res = $this->response; |
|
| 29 | |||
| 30 | 2 | if (headers_sent($file, $line)) { |
|
| 31 | 1 | 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 | 2 | public function sendContent() |
|
| 50 | } |
||
| 51 | } |
||
| 52 |