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 — dev ( b6442a...4385af )
by w3l
06:19
created

Get::chkGet()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 6
Ratio 100 %
Metric Value
dl 6
loc 6
rs 9.4285
cc 2
eloc 4
nc 2
nop 1
1
<?php
2
namespace w3l\Holt45;
3 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...
4
	
5
	/**
6
	 * Check $_GET
7
	 *
8
	 * @example if(chk_get("s") == "a") instead of if(isset($_GET["s"]) && $_GET["s"] == "a")
9
	 *
10
	 * @param string $key Get-key.
11
	 * @return bool|string
12
	 */
13
	public static function chkGet($key) {
0 ignored issues
show
Coding Style introduced by
chkGet uses the super-global variable $_GET which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
14
		if (!isset($_GET[$key])) {
15
			return false;
16
		}
17
		return $_GET[$key];
18
	}
19
	
20
	/**
21
	 * Assign value from $_GET
22
	 *
23
	 * @example $var = assign_from_get("a") instead of $var = ((!empty($_GET["s"])) ? $_GET["s"] : "");
24
	 *
25
	 * @param string $key Get-key.
26
	 * @return string
27
	 */
28
	public static function assignFromGet($key) {
0 ignored issues
show
Coding Style introduced by
assignFromGet uses the super-global variable $_GET which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
29
		return ((!isset($_GET[$key])) ? "" : $_GET[$key]);
30
	}
31
	
32
	/**
33
	 * Check multiple $_GET-keys
34
	 *
35
	 * @example if(chk_get_all(array("a","b"))) instead of if(!empty($_GET["a"]) && !empty($_GET["b"]))
36
	 *
37
	 * @param array $keys Get-keys.
38
	 * @return bool
39
	 */
40
	public static function chkGetAll($keys) {
0 ignored issues
show
Coding Style introduced by
chkGetAll uses the super-global variable $_GET which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
41
		$keys_set = true;
42
43
		foreach($keys AS $key) {
44
		
45
			if (empty($_GET[$key])) {
46
				$keys_set = false;
47
			}
48
		}
49
		return $keys_set;
50
	}
51
}