1 | <?php |
||
5 | class Redirect |
||
6 | { |
||
7 | /** |
||
8 | * Redirect to the specified url. |
||
9 | * |
||
10 | * @param string $url |
||
11 | * @return void |
||
12 | */ |
||
13 | public static function to($url) |
||
17 | |||
18 | /** |
||
19 | * Redirect to the previous url. |
||
20 | * |
||
21 | * @return void |
||
22 | */ |
||
23 | public static function back() |
||
27 | |||
28 | /** |
||
29 | * Create a new redirect. |
||
30 | * |
||
31 | * @param string $location |
||
32 | * @return void |
||
33 | */ |
||
34 | public static function createRedirect($location) |
||
38 | } |
||
39 |
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: