Passed
Push — main ( 21c65b...2786e4 )
by Proyecto
08:22
created

InMemoryGroupRepository   A

Complexity

Total Complexity 12

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 12
eloc 13
c 1
b 0
f 0
dl 0
loc 60
ccs 32
cts 32
cp 1
rs 10

12 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 3 1
A clear() 0 3 1
A read() 0 3 1
A readAll() 0 3 1
A addRoleToGroup() 0 3 1
A addUserToGroup() 0 3 1
A removeUserFromGroup() 0 3 1
A delete() 0 3 1
A update() 0 3 1
A removeRoleFromGroup() 0 3 1
A getUsersFromGroup() 0 3 1
A getRolesFromGroup() 0 3 1
1
<?php
2
3
namespace ProyectoTAU\TAU\Module\Administration\Group\Infrastructure;
4
5
use ProyectoTAU\TAU\Common\InMemoryRepository;
6
use ProyectoTAU\TAU\Module\Administration\User\Domain\User;
7
use ProyectoTAU\TAU\Module\Administration\Group\Domain\Group;
8
use ProyectoTAU\TAU\Module\Administration\Role\Domain\Role;
9
use ProyectoTAU\TAU\Module\Administration\Group\Domain\GroupRepository;
10
11
class InMemoryGroupRepository implements GroupRepository
12
{
13 40
    public function clear(): void
14
    {
15 40
        InMemoryRepository::getInstance()->clearGroup();
16 40
    }
17
18 40
    public function create(Group $group): void
19
    {
20 40
        InMemoryRepository::getInstance()->createGroup(clone $group);
21 40
    }
22
23 31
    public function read($id): Group
24
    {
25 31
        return InMemoryRepository::getInstance()->readGroup($id);
26
    }
27
28 2
    public function readAll(): array
29
    {
30 2
        return InMemoryRepository::getInstance()->readAllGroups();
0 ignored issues
show
Bug introduced by
The method readAllGroups() does not exist on ProyectoTAU\TAU\Common\Repository. Did you maybe mean readGroup()? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

30
        return InMemoryRepository::getInstance()->/** @scrutinizer ignore-call */ readAllGroups();

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
31
    }
32
33 2
    public function update($id, $name, $desc): void
34
    {
35 2
        InMemoryRepository::getInstance()->updateGroup($id, $name, $desc);
36 2
    }
37
38 2
    public function delete($id): void
39
    {
40 2
        InMemoryRepository::getInstance()->deleteGroup($id);
41 2
    }
42
43 11
    public function addUserToGroup(User $user, Group $group): void
44
    {
45 11
        InMemoryRepository::getInstance()->addUserToGroup($user, $group);
46 11
    }
47
48 2
    public function removeUserFromGroup(User $user, Group $group): void
49
    {
50 2
        InMemoryRepository::getInstance()->removeUserFromGroup($user, $group);
51 2
    }
52
53 10
    public function getUsersFromGroup(Group $group): array
54
    {
55 10
        return InMemoryRepository::getInstance()->getUsersFromGroup($group);
56
    }
57
58 6
    public function addRoleToGroup(Role $role, Group $group): void
59
    {
60 6
        InMemoryRepository::getInstance()->addRoleToGroup($role, $group);
61 6
    }
62
63 2
    public function removeRoleFromGroup(Role $role, Group $group): void
64
    {
65 2
        InMemoryRepository::getInstance()->removeRoleFromGroup($role, $group);
66 2
    }
67
68 4
    public function getRolesFromGroup(Group $group): array
69
    {
70 4
        return InMemoryRepository::getInstance()->getRolesFromGroup($group);
71
    }
72
}
73