Test Failed
Push — master ( 319182...81d536 )
by Joe
02:15
created

function_requirements.php ➔ function_requirements()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * @author Joe Huss <[email protected]>
4
 * @copyright 2017
5
 * @package Plugins
6
 */
7
8
/**
9
 * loads the files needed to run the given class or function
10
 *
11
 * @param $function
12
 * @return bool whether or not it found the given function/class
13
 */
14
function function_requirements($function) {
0 ignored issues
show
Coding Style introduced by
function_requirements uses the super-global variable $GLOBALS 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...
15
	return $GLOBALS['tf']->function_requirements($function);
16
}
17