1 | <?php |
||
13 | class Response |
||
14 | { |
||
15 | |||
16 | /** |
||
17 | * @var array HTTP headers |
||
18 | */ |
||
19 | protected $headers = []; |
||
20 | |||
21 | /** |
||
22 | * @var Cookie |
||
23 | */ |
||
24 | protected $cookie; |
||
25 | |||
26 | /** |
||
27 | * @var string Output |
||
28 | */ |
||
29 | protected $output; |
||
30 | |||
31 | /** |
||
32 | * Response constructor. |
||
33 | * |
||
34 | * @param array $headers |
||
35 | * @param Cookie $cookie |
||
36 | * @param string $output |
||
37 | */ |
||
38 | 1 | public function __construct(array $headers, Cookie $cookie, string $output) |
|
44 | |||
45 | /** |
||
46 | * Get response headers as an array, to be set in the index.php file |
||
47 | * |
||
48 | * ``` |
||
49 | * foreach ($response->getHeaders() as $header) { |
||
50 | * header($header); |
||
51 | * } |
||
52 | * ``` |
||
53 | * |
||
54 | * @return array |
||
55 | */ |
||
56 | 2 | public function getHeaders(): array |
|
60 | |||
61 | /** |
||
62 | * Get response cookie, to be set in the index.php file |
||
63 | * |
||
64 | * ``` |
||
65 | * setcookie('token', $response->getCookie->getTokenString(), time() + 3600, '/', '', true, true); |
||
66 | * ``` |
||
67 | * |
||
68 | * @return Cookie |
||
69 | */ |
||
70 | 2 | public function getCookie(): Cookie |
|
74 | |||
75 | /** |
||
76 | * Get response output, to be echoed in the index.php file |
||
77 | * |
||
78 | * ``` |
||
79 | * echo $response->getOutput(); |
||
80 | * ``` |
||
81 | * |
||
82 | * @return string |
||
83 | */ |
||
84 | 2 | public function getOutput(): string |
|
88 | } |
||
89 |