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

GodUserVoter   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 1
dl 0
loc 29
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A isAllowed() 0 7 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 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