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.

SecurityListener::preCommand()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 1
Metric Value
c 3
b 0
f 1
dl 0
loc 12
rs 9.4286
cc 3
eloc 6
nc 3
nop 1
1
<?php
2
3
/**
4
 *
5
 * Copyright 2014 Simon Mönch.
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace APL\Security;
12
13
use APL\Event\PreCommandEvent;
14
use APL\Exception\SecurityException;
15
16
/**
17
 *
18
 * @author Simon Mönch
19
 * @author David Badura <[email protected]>
20
 */
21
class SecurityListener
22
{
23
    /**
24
     *
25
     * @var PolicyInterface[]
26
     */
27
    protected $polices = array();
28
29
    /**
30
     *
31
     * @param PolicyInterface $policy
32
     */
33
    public function addPolicy(PolicyInterface $policy)
34
    {
35
        $this->polices[] = $policy;
36
    }
37
38
    /**
39
     *
40
     * @param PreCommandEvent $event
41
     */
42
    public function preCommand(PreCommandEvent $event)
43
    {
44
        $command = $event->getCommand();
45
46
        foreach ($this->polices as $policy) {
47
            if ($policy->check($command)) {
48
                continue;
49
            }
50
51
            throw new SecurityException($command, $policy);
52
        }
53
    }
54
}
55