Completed
Pull Request — master (#7)
by
unknown
02:02
created

KeycloakResourceRoles::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 2
crap 1
1
<?php
2
/**
3
 * Created by IntelliJ IDEA.
4
 * User: jgreen
5
 * Date: 10/08/2017
6
 * Time: 11:45 AM
7
 */
8
9
namespace Stevenmaguire\OAuth2\Client\Provider;
10
11
class KeycloakResourceRoles
12
{
13
14
    protected $resourceName = null;
15
    protected $roles = null;
16
17
    /**
18
     * KeycloakResourceRoles constructor.
19
     * @param string $resourceName Name of the resource
20
     * @param array $roles List of roles
21
     */
22 2
    public function __construct($resourceName, array $roles)
23
    {
24 2
        $this->resourceName = $resourceName;
25 2
        $this->roles = $roles;
26 2
    }
27
28
    /**
29
     * @return string
30
     */
31
    public function getResourceName()
32
    {
33
        return $this->resourceName;
34
    }
35
36
    public function hasRoleNamed($name)
37
    {
38
        return $this->roles != null && in_array($name, $this->roles);
39
    }
40
41 2
    public function getRoles()
42
    {
43 2
        return $this->roles;
44
    }
45
}
46