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.

Post::chkPostAll()   A
last analyzed

Complexity

Conditions 4
Paths 6

Size

Total Lines 15
Code Lines 8

Duplication

Lines 15
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 4
eloc 8
nc 6
nop 1
dl 15
loc 15
rs 9.2
c 1
b 0
f 0
1
<?php
2
/**
3
 * Post.php
4
 */
5
namespace w3l\Holt45;
6
7
/**
8
 * Check/assign from superglobal $_POST
9
 */
10 View Code Duplication
trait Post
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 $_POST
14
     *
15
     * Example:
16
     * ```php
17
     * if(chkPost("s") == "a") instead of if(isset($_POST["s"]) && $_POST["s"] == "a")
18
     * ```
19
     *
20
     * @param string $postKey Post-key.
21
     * @return bool|string
22
     */
23
    public static function chkPost($postKey)
24
    {
25
        return filter_input(INPUT_POST, $postKey);
26
    }
27
28
    /**
29
     * Assign value from $_POST
30
     *
31
     * Example:
32
     * ```php
33
     * $var = assignFromPost("a") instead of $var = ((!empty($_POST["s"])) ? $_POST["s"] : "");
34
     * ```
35
     *
36
     * @param string $postKey Post-key.
37
     * @return string
38
     */
39
    public static function assignFromPost($postKey)
40
    {
41
        return (string)filter_input(INPUT_POST, $postKey);
42
    }
43
44
    /**
45
     * Check if multiple $_POST-keys are not empty
46
     *
47
     * Example:
48
     * ```php
49
     * if(chkPostAll(array("a","b"))) instead of if(!empty($_POST["a"]) && !empty($_POST["b"]))
50
     * ```
51
     *
52
     * @param array $keys Post-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 chkPostAll(...$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_POST, $key);
64
            if (empty($val)) {
65
                return false;
66
            }
67
        }
68
        return true;
69
    }
70
}
71