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

AccessControl::add()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
eloc 2
nc 1
nop 1
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
}