/** * Create a response thats redirects to given $url. * * @param string $url A string or array-based URL pointing to another location within the app, * or an absolute URL * @param int $statusCode HTTP status code (eg: 301) * @return Response */ public static function redirect(string $url, int $statusCode = 302) { $response = new Response(); $response->statusCode($statusCode); if (strpos($url, '#') !== false) { $url = Router::getInstance()->url(substr($url, 1)); } if (!$response->location()) { $response->location($url); } return $response; }