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

KeycloakResourceRoles::hasRoleNamed()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 2
eloc 2
nc 2
nop 1
crap 6
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
12
class KeycloakResourceRoles
13
{
14
15
    protected $resourceName = null;
16
    protected $roles = null;
17
18
    /**
19
     * KeycloakResourceRoles constructor.
20
     * @param string $resourceName Name of the resource
21
     * @param array $roles List of roles
22
     */
23 2
    public function __construct($resourceName, array $roles)
24
    {
25 2
        $this->resourceName = $resourceName;
26 2
        $this->roles = $roles;
27 2
    }
28
29
    /**
30
     * @return string
31
     */
32
    public function getResourceName()
33
    {
34
        return $this->resourceName;
35
    }
36
37
    public function hasRoleNamed($name) {
38
        return $this->roles != null && in_array($name, $this->roles);
39
    }
40 2
    public function getRoles() {
41 2
        return $this->roles;
42
    }
43
}