ModuleRepository   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 50%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 1
cbo 1
dl 0
loc 45
ccs 5
cts 10
cp 0.5
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A register() 0 4 1
A getRegistered() 0 4 1
A isRegistered() 0 4 1
1
<?php
2
3
namespace Laraflock\Dashboard\Repositories\Module;
4
5
use Illuminate\Support\Collection;
6
7
class ModuleRepository implements ModuleRepositoryInterface
8
{
9
10
    /**
11
     * @var Collection
12
     */
13
    protected $modules;
14
15 40
    public function __construct()
16
    {
17 40
        $this->modules = new Collection();
18 40
    }
19
20
    /**
21
     * Registers a dashboard module into the ecosystem
22
     *
23
     * @param ModuleInterface $module
24
     * @return bool
25
     */
26
    public function register(ModuleInterface $module)
27
    {
28
        $this->modules->put(get_class($module), $module);
29
    }
30
31
    /**
32
     * Loads all registered dashboard modules
33
     *
34
     * @return array
35
     */
36 10
    public function getRegistered()
37
    {
38 10
        return $this->modules;
39
    }
40
41
    /**
42
     * Verify whether a module has been registered
43
     *
44
     * @param ModuleInterface $module
45
     * @return mixed
46
     */
47
    public function isRegistered(ModuleInterface $module)
48
    {
49
        return $this->modules->offsetExists(get_class($module));
50
    }
51
}