Response.php
37 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Wpae\Http; |
| 4 | |
| 5 | |
| 6 | class Response |
| 7 | { |
| 8 | protected $content; |
| 9 | |
| 10 | protected $headers = array( |
| 11 | 'Content-Type' => 'text/html' |
| 12 | ); |
| 13 | |
| 14 | public function __construct($content) |
| 15 | { |
| 16 | $this->content = $content; |
| 17 | } |
| 18 | |
| 19 | public function render() |
| 20 | { |
| 21 | $this->sendHeaders(); |
| 22 | $this->sendContent(); |
| 23 | die; |
| 24 | } |
| 25 | |
| 26 | protected function sendHeaders() |
| 27 | { |
| 28 | foreach($this->headers as $header => $value) { |
| 29 | header($header.': '.$value); |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | protected function sendContent() |
| 34 | { |
| 35 | echo $this->content; |
| 36 | } |
| 37 | } |