-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathResponseInterface.php
More file actions
147 lines (127 loc) · 3.52 KB
/
ResponseInterface.php
File metadata and controls
147 lines (127 loc) · 3.52 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
<?php
/**
* Slim Framework (https://slimframework.com)
*
* @license https://github.com/slimphp/Slim-Http/blob/master/LICENSE.md (MIT License)
*/
declare(strict_types=1);
namespace Slim\Http\Interfaces;
use Psr\Http\Message\ResponseInterface as PsrResponseInterface;
interface ResponseInterface extends PsrResponseInterface
{
/**
* Write JSON to Response Body.
*
* This method prepares the response object to return an HTTP Json
* response to the client.
*
* @param mixed $data The data
* @param int|null $status The HTTP status code
* @param int $options JSON encoding options
* @param int $depth JSON encoding max depth
* @return PsrResponseInterface
*/
public function withJson($data, ?int $status = null, int $options = 0, int $depth = 512): PsrResponseInterface;
/**
* Redirect to specified location
*
* This method prepares the response object to return an HTTP Redirect
* response to the client.
*
* @param string $url The redirect destination.
* @param int|null $status The redirect HTTP status code.
* @return PsrResponseInterface
*/
public function withRedirect(string $url, ?int $status = null): PsrResponseInterface;
/**
* This method will trigger the client to download the specified file
* It will append the `Content-Disposition` header to the response object
*
* @param mixed $file
* @param string|null $name
* @param bool|string $contentType
* @return PsrResponseInterface
*/
public function withFileDownload($file, ?string $name = null, $contentType = true): PsrResponseInterface;
/**
* This method prepares the response object to return a file response to the
* client without `Content-Disposition` header which defaults to `inline`
*
* @param mixed $file
* @param bool|string $contentType
* @return PsrResponseInterface
*/
public function withFile($file, $contentType = true): PsrResponseInterface;
/**
* Write data to the response body.
*
* @param string $data
* @return PsrResponseInterface
*/
public function write(string $data): PsrResponseInterface;
/**
* Is this response a client error?
*
* @return bool
*/
public function isClientError(): bool;
/**
* Is this response empty?
*
* @return bool
*/
public function isEmpty(): bool;
/**
* Is this response forbidden?
*
* @return bool
*/
public function isForbidden(): bool;
/**
* Is this response informational?
*
* @return bool
*/
public function isInformational(): bool;
/**
* Is this response OK?
*
* @return bool
*/
public function isOk(): bool;
/**
* Is this response not Found?
*
* @return bool
*/
public function isNotFound(): bool;
/**
* Is this response a redirect?
*
* @return bool
*/
public function isRedirect(): bool;
/**
* Is this response a redirection?
*
* @return bool
*/
public function isRedirection(): bool;
/**
* Is this response a server error?
*
* @return bool
*/
public function isServerError(): bool;
/**
* Is this response successful?
*
* @return bool
*/
public function isSuccessful(): bool;
/**
* Convert response to string.
* @return string
*/
public function __toString(): string;
}