Completed
Push — master ( d1eae8...f6867f )
by Luc
14s
created

CompositeVoter::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace CultuurNet\UDB3\Offer\Security\Permission;
4
5
use CultuurNet\UDB3\Role\ValueObjects\Permission;
6
use ValueObjects\StringLiteral\StringLiteral;
7
8
class CompositeVoter implements PermissionVoterInterface
9
{
10
    /**
11
     * @var PermissionVoterInterface[]
12
     */
13
    private $voters;
14
15
    /**
16
     * @param PermissionVoterInterface[] ...$voters
17
     */
18
    public function __construct(PermissionVoterInterface ...$voters)
19
    {
20
        $this->voters = $voters;
0 ignored issues
show
Documentation Bug introduced by
It seems like $voters of type array<integer,array<inte...issionVoterInterface>>> is incompatible with the declared type array<integer,object<Cul...missionVoterInterface>> of property $voters.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
21
    }
22
23
    /**
24
     * @param Permission $permission
25
     * @param StringLiteral $offerId
26
     * @param StringLiteral $userId
27
     * @return bool
28
     */
29
    public function isAllowed(
30
        Permission $permission,
31
        StringLiteral $offerId,
32
        StringLiteral $userId
33
    ) {
34
        foreach ($this->voters as $voter) {
35
            if ($voter->isAllowed($permission, $offerId, $userId)) {
36
                return true;
37
            }
38
        }
39
        return false;
40
    }
41
}
42