| Total Complexity | 4 |
| Total Lines | 34 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 12 | final class All implements AssertionInterface |
||
| 13 | { |
||
| 14 | /** |
||
| 15 | * @var AssertionInterface[] |
||
| 16 | */ |
||
| 17 | private readonly array $asserts; |
||
|
|
|||
| 18 | |||
| 19 | /** |
||
| 20 | * Check if all asserts are true. |
||
| 21 | */ |
||
| 22 | 7 | public function __construct(AssertionInterface ...$asserts) |
|
| 23 | { |
||
| 24 | 7 | $this->asserts = $asserts; |
|
| 25 | 7 | } |
|
| 26 | |||
| 27 | /** |
||
| 28 | * Assert that all given assert are correct (AND 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 false; |
|
| 42 | } |
||
| 43 | } |
||
| 44 | |||
| 45 | 3 | return true; |
|
| 46 | } |
||
| 48 |