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.
Completed
Push — master ( 17ed34...f4bd34 )
by Omar El
03:18
created

Redirector::root()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 9
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 9
loc 9
rs 9.6666
cc 2
eloc 5
nc 2
nop 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
    private function __construct(){}
19
20
    /**
21
     * Redirect to the given location
22
     *
23
     * @param string $location
24
     */
25 View Code Duplication
    public static function to($location, $query = ""){
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
26
27
        if(!empty($query)){
28
            $query = '?' . http_build_query((array)$query, null, '&');
29
        }
30
31
        $response = new Response('', 302, ["Location" => $location . $query]);
32
        $response->send();
33
    }
34
35
    /**
36
     * Redirect to the given location from the root
37
     *
38
     * @param string $location
39
     */
40 View Code Duplication
    public static function root($location = "", $query = ""){
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
41
42
        if(!empty($query)){
43
            $query = '?' . http_build_query((array)$query, null, '&');
44
        }
45
46
        $response = new Response('', 302, ["Location" => PUBLIC_ROOT . $location . $query]);
47
        $response->send();
48
    }
49
50
    /**
51
     * Redirect to the dashboard
52
     */
53
    public static function dashboard(){
54
        self::to(PUBLIC_ROOT . "User");
55
    }
56
57
    /**
58
     * Redirect to the login page
59
     * $redirect_url is to send the user back to where he/she came from after login
60
     *
61
     * @param string|null $redirect_url
62
     */
63
    public static function login($redirect_url = null){
64
        if(!empty($redirect_url)){
65
            self::to(PUBLIC_ROOT . "?redirect=" . urlencode($redirect_url));
66
        }else{
67
            self::to(PUBLIC_ROOT);
68
        }
69
    }
70
71
} 
72