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

KeycloakResourceRoles   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 60%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 0
dl 0
loc 32
ccs 6
cts 10
cp 0.6
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getResourceName() 0 4 1
A hasRoleNamed() 0 3 2
A getRoles() 0 3 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
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
}