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.
Test Failed
Push — master ( bab0de...1a0dda )
by Haven
10:01
created

Validator::failed()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php 
2
3
namespace App\Validation;
4
5
use Respect\Validation\Validator as Respect;
6
use Respect\Validation\Exceptions\NestedValidationException;
7
8
/**
9
* 
10
*/
11
class Validator
12
{
13
	protected $errors;
14
	
15
	public function validate($request,array $rules)
0 ignored issues
show
Coding Style introduced by
validate uses the super-global variable $_SESSION 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...
16
	{
17
		foreach ($rules as $field => $rule) {
18
			try {
19
				$rule->setName(ucfirst($field))->assert($request->getParam($field));
20
			} catch (NestedValidationException $e) {
21
				$this->errors[$field] = $e->getMessages();
22
			}
23
			
24
		}
25
26
		$_SESSION['errors'] = $this->errors;
27
		return $this;
28
	}
29
30
	public function failed()
31
	{
32
		return !empty($this->errors);
33
	}
34
}