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 — 3.0 ( c52ac9...9f183d )
by Vermeulen
02:46
created

Http::obtainGetKey()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 11

Duplication

Lines 15
Ratio 100 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 15
loc 15
rs 9.4285
cc 1
eloc 11
nc 1
nop 3
1
<?php
2
3
namespace BFW\Helpers;
4
5
/**
6
 * Helpers for http requests/responses
7
 */
8
class Http
9
{
10
    /**
11
     * Return the class name of the secure helper.
12
     * Allow to extends the secure helper used by method here
13
     * 
14
     * @return string
15
     */
16
    protected static function getSecureHelpersName()
17
    {
18
        return '\BFW\Helpers\Secure';
19
    }
20
21
    /**
22
     * Create a http redirect and kill the script
23
     * 
24
     * @param string $page The page where is the redirect
25
     * @param boolean $permanent (default false) If the redirect is permanent
26
     * @param boolean $callExit (default false) If at true, the exit function
27
     *  will be called.
28
     * 
29
     * @return void
30
     */
31
    public static function redirect(
32
        $page,
33
        $permanent = false,
34
        $callExit = false
35
    ) {
36
        $httpStatus = 302;
37
        if ($permanent === true) {
38
            $httpStatus = 301;
39
        }
40
41
        http_response_code($httpStatus);
42
        header('Location: '.$page);
43
        
44
        if ($callExit === true) {
45
            exit;
46
        }
47
    }
48
49
    /**
50
     * Get a securised value for a key in $_POST array
51
     * 
52
     * @param string $key The key where is the value to securize
53
     * @param string $type The type of data
54
     * @param boolean $htmlentities (default: false) If use htmlentities
55
     *  function to a better security
56
     * 
57
     * @return mixed
58
     */
59 View Code Duplication
    public static function obtainPostKey(
1 ignored issue
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...
60
        $key,
61
        $type,
62
        $htmlentities = false
63
    ) {
64
        $currentClass = get_called_class();
65
        $secure       = $currentClass::getSecureHelpersName();
66
        
67
        return $secure::getSecurisedKeyInArray(
68
            $_POST,
69
            $key,
70
            $type,
71
            $htmlentities
72
        );
73
    }
74
75
    /**
76
     * Get a securised value for a key in $_GET array
77
     * 
78
     * @param string $key The key where is the value to securize
79
     * @param string $type The type of data
80
     * @param boolean $htmlentities (default: false) If use htmlentities
81
     *  function to a better security
82
     * 
83
     * @return mixed
84
     */
85 View Code Duplication
    public static function obtainGetKey(
1 ignored issue
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...
86
        $key,
87
        $type,
88
        $htmlentities = false
89
    ) {
90
        $currentClass = get_called_class();
91
        $secure       = $currentClass::getSecureHelpersName();
92
        
93
        return $secure::getSecurisedKeyInArray(
94
            $_GET,
95
            $key,
96
            $type,
97
            $htmlentities
98
        );
99
    }
100
    
101
    /**
102
     * Obtain many securised keys from $_POST array in one time
103
     * 
104
     * @see \BFW\Helpers\Secure::getSecurisedManyKeys
105
     * 
106
     * @param array &$arraySrc The source array
107
     * @param array $keysList The key list to obtain.
108
     * @param boolean $throwOnError (defaut true) If a key not exist, throw an
109
     *  exception. If false, the value will be null into returned array
110
     * 
111
     * @return array
112
     * 
113
     * @throws Exception If a key is not found and if $throwOnError is true
114
     */
115 View Code Duplication
    public static function obtainManyPostKeys($keysList, $throwOnError = true)
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...
116
    {
117
        $currentClass = get_called_class();
118
        $secure       = $currentClass::getSecureHelpersName();
119
        
120
        return $secure::getSecurisedManyKeys($_POST, $keysList, $throwOnError);
121
    }
122
    
123
    /**
124
     * Obtain many securised keys from $_GET array in one time
125
     * 
126
     * @see \BFW\Helpers\Secure::getSecurisedManyKeys
127
     * 
128
     * @param array $keysList The key list to obtain.
129
     * @param boolean $throwOnError (defaut true) If a key not exist, throw an
130
     *  exception. If false, the value will be null into returned array
131
     * 
132
     * @return array
133
     * 
134
     * @throws Exception If a key is not found and if $throwOnError is true
135
     */
136 View Code Duplication
    public static function obtainManyGetKeys($keysList, $throwOnError = true)
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...
137
    {
138
        $currentClass = get_called_class();
139
        $secure       = $currentClass::getSecureHelpersName();
140
        
141
        return $secure::getSecurisedManyKeys($_GET, $keysList, $throwOnError);
142
    }
143
}
144