Role   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 66
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 66
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setPermissions() 0 3 1
A __construct() 0 6 1
A setGroup() 0 3 1
1
<?php
2
3
namespace ThallesDella\GateKeeper\Roles;
4
5
use ArrayObject;
6
7
/**
8
 * Gate Keeper | Class Role [ ROLE SYSTEM ]
9
 *
10
 * @category GateKeeper\Roles
11
 * @package  ThallesDella\GateKeeper\Roles
12
 * @author   Thalles D. koester <[email protected]>
13
 * @license  https://choosealicense.com/licenses/mit/ MIT
14
 * @link     https://github.com/thallesdella/gate-keeper
15
 */
16
class Role
17
{
18
    /**
19
     * Role name
20
     *
21
     * @var string
22
     */
23
    public $role;
24
    
25
    /**
26
     * Role level
27
     *
28
     * @var int
29
     */
30
    public $level;
31
    
32
    /**
33
     * Role permissions
34
     *
35
     * @var ArrayObject
36
     */
37
    public $permissions;
38
    
39
    /**
40
     * Role group name
41
     *
42
     * @var string
43
     */
44
    public $group;
45
    
46
    /**
47
     * Role constructor.
48
     *
49
     * @param string $role  Role name
50
     * @param int    $level Level of the role
51
     */
52
    public function __construct(string $role, int $level)
53
    {
54
        $this->role = $role;
55
        $this->level = $level;
56
        $this->permissions = new ArrayObject();
57
        $this->group = null;
58
    }
59
    
60
    /**
61
     * Set role permissions
62
     *
63
     * @param array $permissions New permissions
64
     *
65
     * @return void
66
     */
67
    public function setPermissions(array $permissions): void
68
    {
69
        $this->permissions->exchangeArray($permissions);
70
    }
71
    
72
    /**
73
     * Set role group
74
     *
75
     * @param string $groupName New group to be associated with the role
76
     *
77
     * @return void
78
     */
79
    public function setGroup(string $groupName): void
80
    {
81
        $this->group = $groupName;
82
    }
83
    
84
}