-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathResponses.php
More file actions
113 lines (99 loc) · 4.23 KB
/
Responses.php
File metadata and controls
113 lines (99 loc) · 4.23 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
<?php
declare(strict_types=1);
namespace TinyBlocks\Http;
use Psr\Http\Message\ResponseInterface;
/**
* Define standard HTTP response methods.
*
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Status
*/
interface Responses
{
/**
* Creates a response with a 200 OK status.
*
* @param mixed $body The body of the response.
* @param Headers ...$headers Optional additional headers for the response.
* @return ResponseInterface The generated 200 OK response.
*/
public static function ok(mixed $body, Headers ...$headers): ResponseInterface;
/**
* Creates a response with a 201 Created status.
*
* @param mixed $body The body of the response.
* @param Headers ...$headers Optional additional headers for the response.
* @return ResponseInterface The generated 201 Created response.
*/
public static function created(mixed $body, Headers ...$headers): ResponseInterface;
/**
* Creates a response with a 202 Accepted status.
*
* @param mixed $body The body of the response.
* @param Headers ...$headers Optional additional headers for the response.
* @return ResponseInterface The generated 202 Accepted response.
*/
public static function accepted(mixed $body, Headers ...$headers): ResponseInterface;
/**
* Creates a response with a 204 No Content status.
*
* @param Headers ...$headers Optional additional headers for the response.
* @return ResponseInterface The generated 204 No Content response.
*/
public static function noContent(Headers ...$headers): ResponseInterface;
/**
* Creates a response with a 400 Bad Request status.
*
* @param mixed $body The body of the response.
* @param Headers ...$headers Optional additional headers for the response.
* @return ResponseInterface The generated 400 Bad Request response.
*/
public static function badRequest(mixed $body, Headers ...$headers): ResponseInterface;
/**
* Creates a response with a 401 Unauthorized status.
*
* @param mixed $body The body of the response.
* @param Headers ...$headers Optional additional headers for the response.
* @return ResponseInterface The generated 401 Unauthorized response.
*/
public static function unauthorized(mixed $body, Headers ...$headers): ResponseInterface;
/**
* Creates a response with a 403 Forbidden status.
*
* @param mixed $body The body of the response.
* @param Headers ...$headers Optional additional headers for the response.
* @return ResponseInterface The generated 403 Forbidden response.
*/
public static function forbidden(mixed $body, Headers ...$headers): ResponseInterface;
/**
* Creates a response with a 404 Not Found status.
*
* @param mixed $body The body of the response.
* @param Headers ...$headers Optional additional headers for the response.
* @return ResponseInterface The generated 404 Not Found response.
*/
public static function notFound(mixed $body, Headers ...$headers): ResponseInterface;
/**
* Creates a response with a 409 Conflict status.
*
* @param mixed $body The body of the response.
* @param Headers ...$headers Optional additional headers for the response.
* @return ResponseInterface The generated 409 Conflict response.
*/
public static function conflict(mixed $body, Headers ...$headers): ResponseInterface;
/**
* Creates a response with a 422 Unprocessable Entity status.
*
* @param mixed $body The body of the response.
* @param Headers ...$headers Optional additional headers for the response.
* @return ResponseInterface The generated 422 Unprocessable Entity response.
*/
public static function unprocessableEntity(mixed $body, Headers ...$headers): ResponseInterface;
/**
* Creates a response with a 500 Internal Server Error status.
*
* @param mixed $body The body of the response.
* @param Headers ...$headers Optional additional headers for the response.
* @return ResponseInterface The generated 500 Internal Server Error response.
*/
public static function internalServerError(mixed $body, Headers ...$headers): ResponseInterface;
}