AccessControl   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A add() 0 3 1
A isPermitted() 0 8 3
A isExecutionPermitted() 0 8 3
1
<?php
2
namespace rtens\domin\execution\access;
3
4
class AccessControl {
5
6
    /** @var AccessRestriction[] */
7
    private $restrictions = [];
8
9
    public function add(AccessRestriction $restriction) {
10
        $this->restrictions[] = $restriction;
11
    }
12
13
    public function isPermitted($actionId) {
14
        foreach ($this->restrictions as $policy) {
15
            if ($policy->isRestricted($actionId)) {
16
                return false;
17
            }
18
        }
19
        return true;
20
    }
21
22
    public function isExecutionPermitted($actionId, array $parameters) {
23
        foreach ($this->restrictions as $policy) {
24
            if ($policy->isExecutionRestricted($actionId, $parameters)) {
25
                return false;
26
            }
27
        }
28
        return true;
29
    }
30
}