Total Complexity | 8 |
Total Lines | 66 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
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 |
|
61 | } |
||
62 | |||
63 | /** |
||
64 | * @param $type |
||
65 | * @return MenuItem|null |
||
66 | */ |
||
67 | 11 | public function getMenu($type): ?MenuItem |
|
70 | } |
||
71 | |||
72 | /** |
||
73 | * @return array |
||
74 | */ |
||
75 | 12 | public function getDependencies(): array |
|
78 | } |
||
79 | } |
||
80 |