-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRedirectController.php
67 lines (57 loc) · 1.59 KB
/
RedirectController.php
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
<?php
declare(strict_types=1);
namespace Snicco\Component\HttpRouting\Controller;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use Snicco\Component\HttpRouting\Http\Response\RedirectResponse;
use function array_slice;
/**
* @psalm-internal Snicco\Component\HttpRouting
*
* @interal
*/
final class RedirectController extends Controller
{
/**
* @param mixed ...$args
*
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*
* @psalm-suppress MixedArgument
*/
public function to(...$args): RedirectResponse
{
[$location, $status_code, $query] = array_slice($args, -3);
return $this->respondWith()
->redirectTo($location, $status_code, $query);
}
/**
* @param mixed ...$args
*
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*
* @psalm-suppress MixedArgument
*/
public function away(...$args): RedirectResponse
{
[$location, $status_code] = array_slice($args, -2);
return $this->respondWith()
->externalRedirect($location, $status_code);
}
/**
* @param mixed ...$args
*
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*
* @psalm-suppress MixedArgument
*/
public function toRoute(...$args): RedirectResponse
{
[$route, $arguments, $status_code] = array_slice($args, -3);
return $this->respondWith()
->redirectToRoute($route, $arguments, $status_code);
}
}