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