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

InMemoryModuleRepository   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 9
eloc 10
c 1
b 0
f 0
dl 0
loc 45
ccs 24
cts 24
cp 1
rs 10

9 Methods

Rating   Name   Duplication   Size   Complexity  
A clear() 0 3 1
A read() 0 3 1
A create() 0 3 1
A getRolesFromModule() 0 3 1
A delete() 0 3 1
A readAll() 0 3 1
A addRoleToModule() 0 3 1
A removeRoleFromModule() 0 3 1
A update() 0 3 1
1
<?php
2
3
namespace ProyectoTAU\TAU\Module\Administration\Module\Infrastructure;
4
5
use ProyectoTAU\TAU\Common\InMemoryRepository;
6
use ProyectoTAU\TAU\Module\Administration\Role\Domain\Role;
7
use ProyectoTAU\TAU\Module\Administration\Module\Domain\Module;
8
use ProyectoTAU\TAU\Module\Administration\Module\Domain\ModuleRepository;
9
10
class InMemoryModuleRepository implements ModuleRepository
11
{
12 22
    public function clear(): void
13
    {
14 22
        InMemoryRepository::getInstance()->clearModule();
15 22
    }
16
17 22
    public function create(Module $module): void
18
    {
19 22
        InMemoryRepository::getInstance()->createModule(clone $module);
20 22
    }
21
22 16
    public function read($id): Module
23
    {
24 16
        return InMemoryRepository::getInstance()->readModule($id);
25
    }
26
27 2
    public function readAll(): array
28
    {
29 2
        return InMemoryRepository::getInstance()->readAllModules();
0 ignored issues
show
Bug introduced by
The method readAllModules() does not exist on ProyectoTAU\TAU\Common\Repository. Since it exists in all sub-types, consider adding an abstract or default implementation to ProyectoTAU\TAU\Common\Repository. ( Ignorable by Annotation )

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

29
        return InMemoryRepository::getInstance()->/** @scrutinizer ignore-call */ readAllModules();
Loading history...
30
    }
31
32 2
    public function update($id, $name, $desc): void
33
    {
34 2
        InMemoryRepository::getInstance()->updateModule($id, $name, $desc);
35 2
    }
36
37 2
    public function delete($id): void
38
    {
39 2
        InMemoryRepository::getInstance()->deleteModule($id);
40 2
    }
41
42 6
    public function addRoleToModule(Role $role, Module $module): void
43
    {
44 6
        InMemoryRepository::getInstance()->addRoleToModule($role, $module);
45 6
    }
46
47 2
    public function removeRoleFromModule(Role $role, Module $module): void
48
    {
49 2
        InMemoryRepository::getInstance()->removeRoleFromModule($role, $module);
50 2
    }
51
52 4
    public function getRolesFromModule(Module $module): array
53
    {
54 4
        return InMemoryRepository::getInstance()->getRolesFromModule($module);
55
    }
56
}
57