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.

Get   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 61
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 61
loc 61
rs 10
c 0
b 0
f 0
wmc 6
lcom 0
cbo 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A chkGet() 4 4 1
A assignFromGet() 4 4 1
A chkGetAll() 15 15 4

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
/**
3
 * Get.php
4
 */
5
namespace w3l\Holt45;
6
7
/**
8
 * Check/assign from superglobal $_GET
9
 */
10 View Code Duplication
trait Get
0 ignored issues
show
Duplication introduced by
This class 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...
11
{
12
    /**
13
     * Check $_GET
14
     *
15
     * Example:
16
     * ```php
17
     * if(chkGet("s") == "a") instead of if(isset($_GET["s"]) && $_GET["s"] == "a")
18
     * ```
19
     *
20
     * @param string $getKey Get-key.
21
     * @return bool|string
22
     */
23
    public static function chkGet($getKey)
24
    {
25
        return filter_input(INPUT_GET, $getKey);
26
    }
27
28
    /**
29
     * Assign value from $_GET
30
     *
31
     * Example:
32
     * ```php
33
     * $var = assignFromGet("a") instead of $var = ((!empty($_GET["s"])) ? $_GET["s"] : "");
34
     * ```
35
     *
36
     * @param string $getKey Get-key.
37
     * @return string
38
     */
39
    public static function assignFromGet($getKey)
40
    {
41
        return (string)filter_input(INPUT_GET, $getKey);
42
    }
43
44
    /**
45
     * Check if multiple $_GET-keys are not empty
46
     *
47
     * Example:
48
     * ```php
49
     * if(chkGetAll(array("a","b"))) instead of if(!empty($_GET["a"]) && !empty($_GET["b"]))
50
     * ```
51
     *
52
     * @param array $keys Get-keys.
0 ignored issues
show
Documentation introduced by
Consider making the type for parameter $keys a bit more specific; maybe use array[].
Loading history...
53
     * @return bool
54
     */
55
    public static function chkGetAll(...$keys)
56
    {
57
        // If first value is array, then create array from first value
58
        if ((array)$keys[0] === $keys[0]) {
59
            $keys = $keys[0];
60
        }
61
62
        foreach ($keys as $key) {
63
            $val = filter_input(INPUT_GET, $key);
64
            if (empty($val)) {
65
                return false;
66
            }
67
        }
68
        return true;
69
    }
70
}
71