Test Failed
Push — main ( 2036f5...f2d0d3 )
by Proyecto
07:50
created

GroupUseCases::removeRole()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
namespace ProyectoTAU\TAU\Module\Administration\Group\Domain;
4
5
use ProyectoTAU\TAU\Module\Administration\Role\Domain\Role;
6
7
trait GroupUseCases
8
{
9
    private $members = [];
10
    private $plays = [];
11
12
    public function addUser($user)
13
    {
14
        $this->members[$user->getId()] = $user; // TODO: use ID in other relations !!!
15
        // TODO: Raise AddUserToGroupDomainEvent($user, $this)
16
        //$user->addGroup($this); //TODO: this causes an infinite loop
17
    }
18
19
    public function removeUser($user)
20
    {
21
        unset($this->members[$user->getId()]);
22
        // TODO: Raise RemoveUserToGroupDomainEvent($user, $this)
23
    }
24
25
    public function getUsers(): array
26
    {
27
        return $this->members;
28
    }
29
30
    public function addRole($role)
31
    {
32
        $this->plays[$role->getId()] = $role;
33
        // TODO: Raise AddRoleToGroupDomainEvent($role, $this)
34
    }
35
36
    public function removeRole(Role $role)
37
    {
38
        unset($this->plays[$role->getId()]);
39
        // TODO: Raise RemoveRoleFromGroupDomainEvent($role, $this)
40
    }
41
42
    public function getRoles()
43
    {
44
        return $this->plays;
45
    }
46
}
47