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

GodUserVoter::isAllowed()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 3
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 GodUserVoter implements PermissionVoterInterface
9
{
10
    /**
11
     * @var array
12
     */
13
    private $godUserIds;
14
15
    /**
16
     * @param string[] $godUserIds
17
     */
18
    public function __construct(array $godUserIds)
19
    {
20
        $this->godUserIds = $godUserIds;
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
        return in_array($userId->toNative(), $this->godUserIds);
35
    }
36
}
37