acp_main::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 5
nc 1
nop 9
dl 0
loc 8
rs 10
c 1
b 0
f 0

How to fix   Many Parameters   

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

1
<?php
2
/**
3
 *
4
 * Member Avatar & Status [MAS]. An extension for the phpBB Forum Software package.
5
 *
6
 * @copyright (c) 2018-forever, Dark❶ [dark1]
7
 * @license GNU General Public License, version 2 (GPL-2.0-only)
8
 *
9
 */
10
11
namespace dark1\memberavatarstatus\controller;
12
13
/**
14
 * @ignore
15
 */
16
use phpbb\language\language;
17
use phpbb\log\log;
18
use phpbb\request\request;
19
use phpbb\template\template;
20
use phpbb\user;
21
use phpbb\config\config;
22
23
/**
24
 * Member Avatar & Status [MAS] ACP controller Main.
25
 */
26
class acp_main extends acp_base
27
{
28
	/** @var config */
29
	protected $config;
30
31
	/** @var string phpBB root path */
32
	protected $phpbb_root_path;
33
34
	/** @var string phpBB adm relative path */
35
	protected $phpbb_adm_relative_path;
36
37
	/** @var string phpBB php ext */
38
	protected $php_ext;
39
40
	/**
41
	 * Constructor.
42
	 *
43
	 * @param language		$language					Language object
44
	 * @param log			$log						Log object
45
	 * @param request		$request					Request object
46
	 * @param template		$template					Template object
47
	 * @param user			$user						User object
48
	 * @param config		$config						Config object
49
	 * @param string		$phpbb_root_path			phpBB root path
50
	 * @param string		$phpbb_adm_relative_path	phpBB adm relative path
51
	 * @param string		$php_ext					phpBB php ext
52
	 */
53
	public function __construct(language $language, log $log, request $request, template $template, user $user, config $config, $phpbb_root_path, $phpbb_adm_relative_path, $php_ext)
54
	{
55
		parent::__construct($language, $log, $request, $template, $user);
56
57
		$this->config					= $config;
58
		$this->phpbb_root_path			= $phpbb_root_path;
59
		$this->phpbb_adm_relative_path	= $phpbb_adm_relative_path;
60
		$this->php_ext					= $php_ext;
61
	}
62
63
	/**
64
	 * Display the options a user can configure for Main Mode.
65
	 *
66
	 * @return void
67
	 * @access public
68
	 */
69
	public function handle()
70
	{
71
		$acp_board = append_sid($this->phpbb_root_path . $this->phpbb_adm_relative_path . 'index.' . $this->php_ext, 'i=acp_board');
72
73
		// Set output variables for display in the template
74
		$this->template->assign_vars([
75
			'MAS_PHPBB_LK_AV'	=> $acp_board.'&amp;mode=avatar#allow_avatar',
76
			'MAS_PHPBB_LK_OL'	=> $acp_board.'&amp;mode=load#load_onlinetrack',
77
			'MAS_PHPBB_AVATAR'	=> $this->config['allow_avatar'],
78
			'MAS_PHPBB_ONLINE'	=> $this->config['load_onlinetrack'],
79
			// General
80
			'MAS_AVATAR'		=> $this->config['dark1_mas_avatar'],
81
			'MAS_ONLINE'		=> $this->config['dark1_mas_online'],
82
			'MAS_COLOR_OFFLINE'	=> $this->config['dark1_mas_col_off'],
83
			'MAS_COLOR_ONLINE'	=> $this->config['dark1_mas_col_on'],
84
			// MemberList
85
			'MAS_ML_AVATAR'		=> $this->config['dark1_mas_ml_av'],
86
			'MAS_ML_AV_SIZE'	=> $this->config['dark1_mas_ml_av_sz'],
87
			'MAS_ML_ONLINE'		=> $this->config['dark1_mas_ml_ol'],
88
			// ViewOnline
89
			'MAS_VO_PG_AVATAR'	=> $this->config['dark1_mas_vo_pg_av'],
90
			'MAS_VO_PG_AV_SIZE'	=> $this->config['dark1_mas_vo_pg_av_sz'],
91
			'MAS_VO_SB_AVATAR'	=> $this->config['dark1_mas_vo_sb_av'],
92
			'MAS_VO_SB_AV_SIZE'	=> $this->config['dark1_mas_vo_sb_av_sz'],
93
			// ViewForum
94
			'MAS_VF_FP_AVATAR'	=> $this->config['dark1_mas_vf_fp_av'],
95
			'MAS_VF_FP_AV_SIZE'	=> $this->config['dark1_mas_vf_fp_av_sz'],
96
			'MAS_VF_FP_ONLINE'	=> $this->config['dark1_mas_vf_fp_ol'],
97
			'MAS_VF_LP_AVATAR'	=> $this->config['dark1_mas_vf_lp_av'],
98
			'MAS_VF_LP_AV_SIZE'	=> $this->config['dark1_mas_vf_lp_av_sz'],
99
			'MAS_VF_LP_ONLINE'	=> $this->config['dark1_mas_vf_lp_ol'],
100
			// Search
101
			'MAS_SH_FP_AVATAR'	=> $this->config['dark1_mas_sh_fp_av'],
102
			'MAS_SH_FP_AV_SIZE'	=> $this->config['dark1_mas_sh_fp_av_sz'],
103
			'MAS_SH_FP_ONLINE'	=> $this->config['dark1_mas_sh_fp_ol'],
104
			'MAS_SH_LP_AVATAR'	=> $this->config['dark1_mas_sh_lp_av'],
105
			'MAS_SH_LP_AV_SIZE'	=> $this->config['dark1_mas_sh_lp_av_sz'],
106
			'MAS_SH_LP_ONLINE'	=> $this->config['dark1_mas_sh_lp_ol'],
107
			'MAS_SH_UP_AVATAR'	=> $this->config['dark1_mas_sh_up_av'],
108
			'MAS_SH_UP_AV_SIZE'	=> $this->config['dark1_mas_sh_up_av_sz'],
109
			'MAS_SH_UP_ONLINE'	=> $this->config['dark1_mas_sh_up_ol'],
110
			// Review
111
			'MAS_RV_AVATAR'		=> $this->config['dark1_mas_rv_av'],
112
			'MAS_RV_AV_SIZE'	=> $this->config['dark1_mas_rv_av_sz'],
113
			'MAS_RV_ONLINE'		=> $this->config['dark1_mas_rv_ol'],
114
			// Friendlist
115
			'MAS_FL_AVATAR'		=> $this->config['dark1_mas_fl_av'],
116
			'MAS_FL_AV_SIZE'	=> $this->config['dark1_mas_fl_av_sz'],
117
			'MAS_FL_ONLINE'		=> $this->config['dark1_mas_fl_ol'],
118
		]);
119
	}
120
}
121