Completed
Push — master ( ca7ebd...ffd42a )
by Nikolas
03:40
created

AccessControl   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 7
c 1
b 0
f 0
lcom 1
cbo 1
dl 0
loc 27
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 AccessPolicy[] */
7
    private $policies = [];
8
9
    public function add(AccessPolicy $policy) {
10
        $this->policies[] = $policy;
11
    }
12
13
    public function isPermitted($actionId) {
14
        foreach ($this->policies as $policy) {
15
            if (!$policy->isPermitted($actionId)) {
16
                return false;
17
            }
18
        }
19
        return true;
20
    }
21
22
    public function isExecutionPermitted($actionId, array $parameters) {
23
        foreach ($this->policies as $policy) {
24
            if (!$policy->isExecutionPemitted($actionId, $parameters)) {
25
                return false;
26
            }
27
        }
28
        return true;
29
    }
30
}