main_module   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 16
c 1
b 0
f 0
dl 0
loc 47
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A main() 0 34 2
1
<?php
2
/**
3
 *
4
 * User Notification Control [UNC]. An extension for the phpBB Forum Software package.
5
 *
6
 * @copyright (c) 2020-forever, Dark❶, https://dark1.tech
7
 * @license GNU General Public License, version 2 (GPL-2.0)
8
 *
9
 */
10
11
namespace dark1\usernotificationcontrol\acp;
12
13
/**
14
 * User Notification Control [UNC] ACP module.
15
 */
16
class main_module
17
{
18
	public $page_title;
19
	public $tpl_name;
20
	public $u_action;
21
22
	/**
23
	 * Main ACP module
24
	 *
25
	 * @param int    $id   The module ID
26
	 * @param string $mode The module mode (for example: manage or settings)
27
	 * @throws \Exception
28
	 */
29
	public function main($id, $mode)
30
	{
31
		global $phpbb_container;
32
33
		// Normalize the Mode to Lowercase
34
		$mode = strtolower($mode);
35
36
		// check for valid Mode
37
		if ($phpbb_container->has('dark1.usernotificationcontrol.controller.acp.' . $mode))
38
		{
39
			// Get ACP controller for Mode
40
			$acp_controller = $phpbb_container->get('dark1.usernotificationcontrol.controller.acp.' . $mode);
41
42
			// Load the display handle in our ACP controller
43
			$acp_controller->set_data($id, $mode, $this->u_action);
44
45
			// Get data from our ACP controller
46
			$acp_get_data = $acp_controller->get_data();
47
48
			// Load a template from adm/style for our ACP page
49
			$this->tpl_name = $acp_get_data['tpl_name'];
50
51
			// Set the page title for our ACP page
52
			$this->page_title = $acp_get_data['page_title'];
53
54
			// Load the setup in our ACP controller
55
			$acp_controller->setup();
56
57
			// Load the handle in our ACP controller
58
			$acp_controller->handle();
59
		}
60
		else
61
		{
62
			trigger_error('FORM_INVALID', E_USER_WARNING);
63
		}
64
	}
65
}
66