GroupUseCases::removeUser()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 1
crap 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 9
    public function addUser($user)
13
    {
14 9
        $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 9
    }
18
19 3
    public function removeUser($user)
20
    {
21 3
        unset($this->members[$user->getId()]);
22
        // TODO: Raise RemoveUserToGroupDomainEvent($user, $this)
23 3
    }
24
25 6
    public function getUsers(): array
26
    {
27 6
        return $this->members;
28
    }
29
30 7
    public function addRole($role)
31
    {
32 7
        $this->plays[$role->getId()] = $role;
33
        // TODO: Raise AddRoleToGroupDomainEvent($role, $this)
34 7
    }
35
36 3
    public function removeRole(Role $role)
37
    {
38 3
        unset($this->plays[$role->getId()]);
39
        // TODO: Raise RemoveRoleFromGroupDomainEvent($role, $this)
40 3
    }
41
42 3
    public function getRoles()
43
    {
44 3
        return $this->plays;
45
    }
46
}
47