GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Redirector   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 1
dl 0
loc 55
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 2 1
A to() 0 9 2
A root() 0 3 1
A dashboard() 0 3 1
A login() 0 7 2
1
<?php
2
3
/**
4
 * The redirector class.
5
 *
6
 * Provides multiple options for redirection
7
 *
8
 * @license    http://opensource.org/licenses/MIT The MIT License (MIT)
9
 * @author     Omar El Gabry <[email protected]>
10
 */
11
12
class Redirector{
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
13
14
    /**
15
     * Constructor
16
     *
17
     */
18
    public function __construct(){
19
    }
20
21
    /**
22
     * Redirect to the given location
23
     *
24
     * @param string $location
25
     */
26
    public function to($location, $query = ""){
27
28
        if(!empty($query)){
29
            $query = '?' . http_build_query((array)$query, null, '&');
30
        }
31
32
        $response = new Response('', 302, ["Location" => $location . $query]);
33
        return $response;
34
    }
35
36
    /**
37
     * Redirect to the given location from the root
38
     *
39
     * @param string $location
40
     */
41
    public function root($location = "", $query = ""){
42
        return $this->to(PUBLIC_ROOT . $location, $query);
43
    }
44
45
    /**
46
     * Redirect to the dashboard
47
     */
48
    public function dashboard(){
49
        return $this->to(PUBLIC_ROOT . "User");
50
    }
51
52
    /**
53
     * Redirect to the login page
54
     * $redirect_url is to send the user back to where he/she came from after login
55
     *
56
     * @param string|null $redirect_url
57
     */
58
    public function login($redirect_url = null){
59
        if(!empty($redirect_url)){
60
            return $this->to(PUBLIC_ROOT . "?redirect=" . urlencode($redirect_url));
61
        }else{
62
            return $this->to(PUBLIC_ROOT);
63
        }
64
    }
65
66
} 
67