-
-
Notifications
You must be signed in to change notification settings - Fork 161
Expand file tree
/
Copy pathResponse.php
More file actions
81 lines (65 loc) · 1.72 KB
/
Response.php
File metadata and controls
81 lines (65 loc) · 1.72 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php
declare(strict_types=1);
namespace Tempest\Http;
use Generator;
use JsonSerializable;
use Tempest\Http\Cookie\Cookie;
use Tempest\View\View;
use UnitEnum;
interface Response
{
/**
* Gets the status code of the response.
*/
public Status $status { get; }
/**
* Gets the headers of the response.
*
* @var \Tempest\Http\Header[] $headers
*/
public array $headers { get; }
/**
* Gets the body of the response.
*/
public View|string|array|Generator|JsonSerializable|null $body { get; }
/**
* Gets a header by its name, case insensitive.
*/
public function getHeader(string $name): ?Header;
/**
* Adds a header to the response.
*/
public function addHeader(string $key, string $value): self;
/**
* Removes a header from the response.
*/
public function removeHeader(string $key): self;
/**
* Adds a value to the session.
*/
public function addSession(string $name, mixed $value): self;
/**
* Removes a value from the session.
*/
public function removeSession(string $name): self;
/**
* Flash a value to the session for the next request.
*/
public function flash(string|UnitEnum $key, mixed $value): self;
/**
* Adds a cookie to the response.
*/
public function addCookie(Cookie $cookie): self;
/**
* Removes a cookie from the response.
*/
public function removeCookie(string $key): self;
/**
* Sets the status code of the response.
*/
public function setStatus(Status $status): self;
/**
* Sets the body of the response.
*/
public function setBody(View|string|array|Generator|null $body): self;
}