Completed
Push — master ( 8555c7...3d8b58 )
by Angus
02:42
created

MY_Security   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 10
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
1
<?php defined('BASEPATH') OR exit('No direct script access allowed');
2
3
class MY_Security extends CI_Security {
4
	public function __construct() {
5
		parent::__construct();
6
	}
7
8
	//FIXME: This is pretty much just a quick hack. Not too sure if this causes any security issues.
9
	public function csrf_show_error() {
0 ignored issues
show
Coding Style introduced by
csrf_show_error uses the super-global variable $_SERVER 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...
10
		header("Location: {$_SERVER['REQUEST_URI']}");
11
	}
12
}
13