| Total Complexity | 4 |
| Total Lines | 45 |
| Duplicated Lines | 0 % |
| Changes | 5 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 9 | trait ResponseUrlTrait |
||
| 10 | { |
||
| 11 | abstract protected function request(): \WebServCo\Framework\Interfaces\RequestInterface; |
||
| 12 | |||
| 13 | /** |
||
| 14 | * Redirect to an application location (Request target). |
||
| 15 | * This method returns a Response object that needs to be in turn returned to the application. |
||
| 16 | */ |
||
| 17 | final protected function getRedirectResponse(string $location, bool $addSuffix = true): Response |
||
| 25 | } |
||
| 26 | |||
| 27 | /** |
||
| 28 | * Redirect to the current URL. |
||
| 29 | * This method returns a Response object that needs to be in turn returned to the application. |
||
| 30 | * |
||
| 31 | * @param array<int,string> $removeParameters |
||
| 32 | */ |
||
| 33 | final protected function getReloadResponse(array $removeParameters = []): Response |
||
| 34 | { |
||
| 35 | $url = $this->request()->getUrl($removeParameters); |
||
| 36 | return $this->getRedirectUrlResponse($url); |
||
| 37 | } |
||
| 38 | |||
| 39 | /** |
||
| 40 | * Redirect to a full URL. |
||
| 41 | * This method returns a Response object that needs to be in turn returned to the application. |
||
| 42 | * |
||
| 43 | * "303 See Other (since HTTP/1.1) |
||
| 44 | * The response to the request can be found under another URI using the GET method. |
||
| 45 | * When received in response to a POST (or PUT/DELETE), the client should presume that the server has received |
||
| 46 | * the data and should issue a new GET request to the given URI." |
||
| 47 | */ |
||
| 48 | final protected function getRedirectUrlResponse(string $url, int $statusCode = 303): Response |
||
| 54 | ); |
||
| 55 | } |
||
| 57 |