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

RoleConstraintVoter::isAllowed()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 8
nc 1
nop 3
1
<?php
2
3
namespace CultuurNet\UDB3\Offer\Security\Permission;
4
5
use CultuurNet\UDB3\Offer\Security\UserPermissionMatcherInterface;
6
use CultuurNet\UDB3\Role\ValueObjects\Permission;
7
use ValueObjects\StringLiteral\StringLiteral;
8
9
class RoleConstraintVoter implements PermissionVoterInterface
10
{
11
    /**
12
     * @var UserPermissionMatcherInterface
13
     */
14
    private $userPermissionMatcher;
15
16
    /**
17
     * @param UserPermissionMatcherInterface $userPermissionMatcher
18
     */
19
    public function __construct(UserPermissionMatcherInterface $userPermissionMatcher)
20
    {
21
        $this->userPermissionMatcher = $userPermissionMatcher;
22
    }
23
24
    /**
25
     * @param Permission $permission
26
     * @param StringLiteral $offerId
27
     * @param StringLiteral $userId
28
     * @return bool
29
     */
30
    public function isAllowed(
31
        Permission $permission,
32
        StringLiteral $offerId,
33
        StringLiteral $userId
34
    ) {
35
        return $this->userPermissionMatcher->itMatchesOffer(
36
            $userId,
37
            $permission,
38
            $offerId
39
        );
40
    }
41
}
42