Module   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 66
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 8
dl 0
loc 66
ccs 17
cts 17
cp 1
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getConfig() 0 3 1
A getMenu() 0 3 1
A getMenuTypes() 0 3 1
A baseConfig() 0 3 1
A getDependencies() 0 3 1
A __construct() 0 7 3
1
<?php
2
3
namespace Modulatr\Loader;
4
5
use Modulatr\Loader\Menu\MenuItem;
6
7
/**
8
 * Class Module
9
 *
10
 * @package Modulatr\Loader
11
 */
12
abstract class Module implements ModuleContract
13
{
14
15
    /**
16
     * @var array
17
     */
18
    protected $config;
19
20
    /**
21
     * @var array
22
     */
23
    protected $menus = [];
24
25
    /**
26
     * @param array $config
27
     */
28 12
    public function __construct($config = [])
29
    {
30 12
        $this->config = array_merge($this->baseConfig(), $config);
31 12
        foreach ($this->getMenuTypes() as $type) {
32 11
            $methodName = $type . 'Menu';
33 11
            if (method_exists($this, $methodName)) {
34 11
                $this->menus[$type] = $this->{$methodName}();
35
            }
36
        }
37 12
    }
38
39
    /**
40
     * @return array
41
     */
42 12
    public function baseConfig(): array
43
    {
44 12
        return [];
45
    }
46
47
    /**
48
     * @return array
49
     */
50 1
    public function getMenuTypes(): array
51
    {
52 1
        return [];
53
    }
54
55
    /**
56
     * @return array
57
     */
58 1
    public function getConfig(): array
59
    {
60 1
        return $this->config;
61
    }
62
63
    /**
64
     * @param $type
65
     * @return MenuItem|null
66
     */
67 11
    public function getMenu($type): ?MenuItem
68
    {
69 11
        return $this->menus[$type] ?? null;
70
    }
71
72
    /**
73
     * @return array
74
     */
75 12
    public function getDependencies(): array
76
    {
77 12
        return [];
78
    }
79
}
80