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 — master ( d1c731...ca9b69 )
by Axel
02:45
created

PolicyRuleManager   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 95.65%

Importance

Changes 13
Bugs 6 Features 4
Metric Value
wmc 5
c 13
b 6
f 4
lcom 1
cbo 3
dl 0
loc 52
ccs 22
cts 23
cp 0.9565
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getRule() 0 12 2
A processRuleAttributes() 0 11 2
1
<?php
2
3
namespace PhpAbac\Manager;
4
5
use PhpAbac\Abac;
6
use PhpAbac\Model\PolicyRule;
7
use PhpAbac\Model\PolicyRuleAttribute;
8
9
class PolicyRuleManager
10
{
11
    /** @var \PhpAbac\Manager\AttributeManager **/
12
    private $attributeManager;
13
    /** @var array **/
14
    private $rules;
15
16
    /**
17
     * @param \PhpAbac\Manager\AttributeManager $attributeManager
18
     * @param array $rules
19
     */
20 2
    public function __construct(AttributeManager $attributeManager, $rules)
21
    {
22 2
        $this->attributeManager = $attributeManager;
23 2
        $this->rules = $rules;
24 2
    }
25
26
    /**
27
     * @param string $ruleName
28
     *
29
     * @return PolicyRule
30
     *
31
     * @throws \InvalidArgumentException
32
     */
33 2
    public function getRule($ruleName)
34
    {
35 2
        if(!isset($this->rules[$ruleName])) {
0 ignored issues
show
Coding Style introduced by
Expected 1 space after IF keyword; 0 found
Loading history...
36
            throw new \InvalidArgumentException('The given rule "' . $ruleName . '" is not configured');
37
        }
38
        $rule =
39 2
            (new PolicyRule())
40 2
            ->setName($ruleName)
41 2
        ;
42 2
        $this->processRuleAttributes($rule);
43 2
        return $rule;
44
    }
45
    
46
    /**
47
     * @param PolicyRule $rule
48
     */
49 2
    private function processRuleAttributes(PolicyRule $rule) {
50 2
        foreach($this->rules[$rule->getName()]['attributes'] as $attributeName => $attribute) {
0 ignored issues
show
Coding Style introduced by
Expected 1 space after FOREACH keyword; 0 found
Loading history...
51 2
            $rule->addPolicyRuleAttribute(
52 2
                (new PolicyRuleAttribute())
53 2
                ->setAttribute($this->attributeManager->getAttribute($attributeName))
54 2
                ->setComparison($attribute['comparison'])
55 2
                ->setComparisonType($attribute['comparison_type'])
56 2
                ->setValue($attribute['value'])
57 2
            );
58 2
        }
59 2
    }
60
}
61