Total Complexity | 4 |
Total Lines | 34 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
12 | final class One implements AssertionInterface |
||
13 | { |
||
14 | /** |
||
15 | * @var AssertionInterface[] |
||
16 | */ |
||
17 | private readonly array $asserts; |
||
|
|||
18 | |||
19 | /** |
||
20 | * Check if at least one assert is true. |
||
21 | */ |
||
22 | 7 | public function __construct(AssertionInterface ...$asserts) |
|
23 | { |
||
24 | 7 | $this->asserts = $asserts; |
|
25 | 7 | } |
|
26 | |||
27 | /** |
||
28 | * Assert that at least one of the given assert is correct (OR logic). |
||
29 | * |
||
30 | * @param \Ecodev\Felix\Acl\Acl $acl |
||
31 | * @param RoleInterface $role |
||
32 | * @param ResourceInterface $resource |
||
33 | * @param string $privilege |
||
34 | * |
||
35 | * @return bool |
||
36 | */ |
||
37 | 7 | public function assert(Acl $acl, ?RoleInterface $role = null, ?ResourceInterface $resource = null, $privilege = null) |
|
38 | { |
||
39 | 7 | foreach ($this->asserts as $assert) { |
|
40 | 6 | if ($assert->assert($acl, $role, $resource, $privilege)) { |
|
41 | 4 | return true; |
|
42 | } |
||
43 | } |
||
44 | |||
45 | 3 | return false; |
|
46 | } |
||
48 |