-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathResponse.php
More file actions
66 lines (52 loc) · 2.25 KB
/
Response.php
File metadata and controls
66 lines (52 loc) · 2.25 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
<?php
declare(strict_types=1);
namespace TinyBlocks\Http;
use Psr\Http\Message\ResponseInterface;
use TinyBlocks\Http\Internal\Response\InternalResponse;
final readonly class Response implements Responses
{
public static function ok(mixed $body, Headers ...$headers): ResponseInterface
{
return InternalResponse::createWithBody($body, Code::OK, ...$headers);
}
public static function created(mixed $body, Headers ...$headers): ResponseInterface
{
return InternalResponse::createWithBody($body, Code::CREATED, ...$headers);
}
public static function accepted(mixed $body, Headers ...$headers): ResponseInterface
{
return InternalResponse::createWithBody($body, Code::ACCEPTED, ...$headers);
}
public static function noContent(Headers ...$headers): ResponseInterface
{
return InternalResponse::createWithoutBody(Code::NO_CONTENT, ...$headers);
}
public static function badRequest(mixed $body, Headers ...$headers): ResponseInterface
{
return InternalResponse::createWithBody($body, Code::BAD_REQUEST, ...$headers);
}
public static function unauthorized(mixed $body, Headers ...$headers): ResponseInterface
{
return InternalResponse::createWithBody($body, Code::UNAUTHORIZED, ...$headers);
}
public static function forbidden(mixed $body, Headers ...$headers): ResponseInterface
{
return InternalResponse::createWithBody($body, Code::FORBIDDEN, ...$headers);
}
public static function notFound(mixed $body, Headers ...$headers): ResponseInterface
{
return InternalResponse::createWithBody($body, Code::NOT_FOUND, ...$headers);
}
public static function conflict(mixed $body, Headers ...$headers): ResponseInterface
{
return InternalResponse::createWithBody($body, Code::CONFLICT, ...$headers);
}
public static function unprocessableEntity(mixed $body, Headers ...$headers): ResponseInterface
{
return InternalResponse::createWithBody($body, Code::UNPROCESSABLE_ENTITY, ...$headers);
}
public static function internalServerError(mixed $body, Headers ...$headers): ResponseInterface
{
return InternalResponse::createWithBody($body, Code::INTERNAL_SERVER_ERROR, ...$headers);
}
}