1 | <?php |
||
31 | trait MessageHelper |
||
32 | { |
||
33 | /** |
||
34 | * Gets an associative array of the request body content. |
||
35 | * |
||
36 | * @param \Psr\Http\Message\ServerRequestInterface $request The request |
||
37 | * @return array<string,mixed> The associative array of request body content |
||
38 | */ |
||
39 | 2 | protected function getParsedBodyArray(Request $request): array |
|
44 | |||
45 | /** |
||
46 | * Cleanly writes the body to the response. |
||
47 | * |
||
48 | * @param \Psr\Http\Message\ResponseInterface $response The HTTP response |
||
49 | * @param mixed $body The body to write |
||
50 | * @return \Psr\Http\Message\ResponseInterface The same or new response |
||
51 | */ |
||
52 | 1 | protected function write(Response $response, $body): Response |
|
57 | |||
58 | /** |
||
59 | * Checks the `If-Modified-Since` header, maybe sending 304 Not Modified. |
||
60 | * |
||
61 | * @param \Psr\Http\Message\ServerRequestInterface $request The HTTP request |
||
62 | * @param \Psr\Http\Message\ResponseInterface $response The HTTP response |
||
63 | * @param int $timestamp The timestamp for comparison |
||
64 | * @return \Psr\Http\Message\ResponseInterface The same or new response |
||
65 | */ |
||
66 | 3 | protected function ifModSince(Request $request, Response $response, int $timestamp): Response |
|
74 | |||
75 | /** |
||
76 | * Checks the `If-None-Match` header, maybe sending 304 Not Modified. |
||
77 | * |
||
78 | * @param \Psr\Http\Message\ServerRequestInterface $request The HTTP request |
||
79 | * @param \Psr\Http\Message\ResponseInterface $response The HTTP response |
||
80 | * @param string $etag The ETag for comparison |
||
81 | * @return \Psr\Http\Message\ResponseInterface The same or new response |
||
82 | */ |
||
83 | 3 | protected function ifNoneMatch(Request $request, Response $response, string $etag): Response |
|
91 | |||
92 | /** |
||
93 | * Redirects the user to another URL. |
||
94 | * |
||
95 | * @param \Psr\Http\Message\ResponseInterface $response The HTTP response |
||
96 | * @return \Psr\Http\Message\ResponseInterface The new response |
||
97 | */ |
||
98 | 1 | protected function redirect(Response $response, int $code, string $url): Response |
|
102 | |||
103 | /** |
||
104 | * Gets a pagination factory |
||
105 | * |
||
106 | * @return \Caridea\Http\PaginationFactory The pagination factory |
||
107 | */ |
||
108 | 1 | protected function paginationFactory(): PaginationFactory |
|
112 | } |
||
113 |