Total Complexity | 11 |
Total Lines | 104 |
Duplicated Lines | 0 % |
Coverage | 88.46% |
Changes | 0 |
1 | <?php |
||
21 | abstract class Group implements GroupInterface |
||
22 | { |
||
23 | /** |
||
24 | * @var mixed |
||
25 | */ |
||
26 | protected $id; |
||
27 | |||
28 | /** |
||
29 | * @var string |
||
30 | */ |
||
31 | protected $name; |
||
32 | |||
33 | /** |
||
34 | * @var array |
||
35 | */ |
||
36 | protected $roles; |
||
37 | |||
38 | /** |
||
39 | * Group constructor. |
||
40 | * |
||
41 | * @param string $name |
||
42 | * @param array $roles |
||
43 | */ |
||
44 | 13 | public function __construct($name, $roles = []) |
|
48 | } |
||
49 | |||
50 | /** |
||
51 | * {@inheritdoc} |
||
52 | */ |
||
53 | 5 | public function addRole($role) |
|
54 | { |
||
55 | 5 | if (!$this->hasRole($role)) { |
|
56 | 5 | $this->roles[] = strtoupper($role); |
|
57 | } |
||
58 | |||
59 | 5 | return $this; |
|
60 | } |
||
61 | |||
62 | /** |
||
63 | * {@inheritdoc} |
||
64 | */ |
||
65 | 6 | public function getId() |
|
66 | { |
||
67 | 6 | return $this->id; |
|
68 | } |
||
69 | |||
70 | /** |
||
71 | * {@inheritdoc} |
||
72 | */ |
||
73 | 6 | public function getName() |
|
76 | } |
||
77 | |||
78 | /** |
||
79 | * {@inheritdoc} |
||
80 | */ |
||
81 | 5 | public function hasRole($role) |
|
82 | { |
||
83 | 5 | return \in_array(strtoupper($role), $this->roles, true); |
|
84 | } |
||
85 | |||
86 | /** |
||
87 | * {@inheritdoc} |
||
88 | */ |
||
89 | 6 | public function getRoles() |
|
90 | { |
||
91 | 6 | return $this->roles; |
|
92 | } |
||
93 | |||
94 | /** |
||
95 | * {@inheritdoc} |
||
96 | */ |
||
97 | 2 | public function removeRole($role) |
|
105 | } |
||
106 | |||
107 | /** |
||
108 | * {@inheritdoc} |
||
109 | */ |
||
110 | 5 | public function setName($name) |
|
111 | { |
||
112 | 5 | $this->name = $name; |
|
113 | |||
114 | 5 | return $this; |
|
115 | } |
||
116 | |||
117 | /** |
||
118 | * {@inheritdoc} |
||
119 | */ |
||
120 | public function setRoles(array $roles) |
||
125 | } |
||
126 | } |
||
127 |