Passed
Push — master ( 360e2b...e8c113 )
by Dark❶
04:59 queued 04:44
created

acp_main::__construct()   A

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-2020, 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 \phpbb\config\config */
0 ignored issues
show
introduced by
Either use statement or full name must be used.
Loading history...
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 phpEx */
38
	protected $phpEx;
39
40
	/**
41
	 * Constructor.
42
	 *
43
	 * @param \phpbb\language\language				$language					Language object
0 ignored issues
show
introduced by
Either use statement or full name must be used.
Loading history...
44
	 * @param \phpbb\log\log						$log						Log object
0 ignored issues
show
introduced by
Either use statement or full name must be used.
Loading history...
45
	 * @param \phpbb\request\request				$request					Request object
0 ignored issues
show
introduced by
Either use statement or full name must be used.
Loading history...
46
	 * @param \phpbb\template\template				$template					Template object
0 ignored issues
show
introduced by
Either use statement or full name must be used.
Loading history...
47
	 * @param \phpbb\user							$user						User object
0 ignored issues
show
introduced by
Either use statement or full name must be used.
Loading history...
48
	 * @param \phpbb\config\config					$config						Config object
0 ignored issues
show
introduced by
Either use statement or full name must be used.
Loading history...
49
	 * @param string								$phpbb_root_path			phpBB root path
50
	 * @param string								$phpbb_adm_relative_path	phpBB adm relative path
51
	 * @param string								$phpEx						phpBB phpEx
52
	 */
53
	public function __construct(language $language, log $log, request $request, template $template, user $user, config $config, $phpbb_root_path, $phpbb_adm_relative_path, $phpEx)
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->phpEx					= $phpEx;
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
		// Is the form being submitted to us?
72
		if ($this->request->is_set_post('submit'))
73
		{
74
			$this->check_form_on_submit();
75
76
			// Set the options the user configured
77
78
			$this->success_form_on_submit();
79
		}
80
81
		$main_adm_path = $this->phpbb_root_path . $this->phpbb_adm_relative_path . 'index.' . $this->phpEx;
82
83
		// Set output variables for display in the template
84
		$this->template->assign_vars([
85
			'MAS_PHPBB_LK_AV'	=> append_sid($main_adm_path, 'i=acp_board&amp;mode=avatar#allow_avatar'),
86
			'MAS_PHPBB_LK_OL'	=> append_sid($main_adm_path, 'i=acp_board&amp;mode=load#load_onlinetrack'),
87
			'MAS_PHPBB_AVATAR'	=> $this->config['allow_avatar'],
88
			'MAS_PHPBB_ONLINE'	=> $this->config['load_onlinetrack'],
89
			// General
90
			'MAS_AVATAR'		=> $this->config['dark1_mas_avatar'],
91
			'MAS_ONLINE'		=> $this->config['dark1_mas_online'],
92
			'MAS_COLOR_OFFLINE'	=> $this->config['dark1_mas_col_off'],
93
			'MAS_COLOR_ONLINE'	=> $this->config['dark1_mas_col_on'],
94
			// MemberList
95
			'MAS_ML_AVATAR'		=> $this->config['dark1_mas_ml_av'],
96
			'MAS_ML_AV_SIZE'	=> $this->config['dark1_mas_ml_av_sz'],
97
			'MAS_ML_ONLINE'		=> $this->config['dark1_mas_ml_ol'],
98
			// ViewOnline
99
			'MAS_VO_PG_AVATAR'	=> $this->config['dark1_mas_vo_pg_av'],
100
			'MAS_VO_PG_AV_SIZE'	=> $this->config['dark1_mas_vo_pg_av_sz'],
101
			'MAS_VO_SB_AVATAR'	=> $this->config['dark1_mas_vo_sb_av'],
102
			'MAS_VO_SB_AV_SIZE'	=> $this->config['dark1_mas_vo_sb_av_sz'],
103
			// ViewForum
104
			'MAS_VF_FP_AVATAR'	=> $this->config['dark1_mas_vf_fp_av'],
105
			'MAS_VF_FP_AV_SIZE'	=> $this->config['dark1_mas_vf_fp_av_sz'],
106
			'MAS_VF_FP_ONLINE'	=> $this->config['dark1_mas_vf_fp_ol'],
107
			'MAS_VF_LP_AVATAR'	=> $this->config['dark1_mas_vf_lp_av'],
108
			'MAS_VF_LP_AV_SIZE'	=> $this->config['dark1_mas_vf_lp_av_sz'],
109
			'MAS_VF_LP_ONLINE'	=> $this->config['dark1_mas_vf_lp_ol'],
110
			// Search
111
			'MAS_SH_FP_AVATAR'	=> $this->config['dark1_mas_sh_fp_av'],
112
			'MAS_SH_FP_AV_SIZE'	=> $this->config['dark1_mas_sh_fp_av_sz'],
113
			'MAS_SH_FP_ONLINE'	=> $this->config['dark1_mas_sh_fp_ol'],
114
			'MAS_SH_LP_AVATAR'	=> $this->config['dark1_mas_sh_lp_av'],
115
			'MAS_SH_LP_AV_SIZE'	=> $this->config['dark1_mas_sh_lp_av_sz'],
116
			'MAS_SH_LP_ONLINE'	=> $this->config['dark1_mas_sh_lp_ol'],
117
			'MAS_SH_UP_AVATAR'	=> $this->config['dark1_mas_sh_up_av'],
118
			'MAS_SH_UP_AV_SIZE'	=> $this->config['dark1_mas_sh_up_av_sz'],
119
			'MAS_SH_UP_ONLINE'	=> $this->config['dark1_mas_sh_up_ol'],
120
			// Review
121
			'MAS_RV_AVATAR'		=> $this->config['dark1_mas_rv_av'],
122
			'MAS_RV_AV_SIZE'	=> $this->config['dark1_mas_rv_av_sz'],
123
			'MAS_RV_ONLINE'		=> $this->config['dark1_mas_rv_ol'],
124
			// Friendlist
125
			'MAS_FL_AVATAR'		=> $this->config['dark1_mas_fl_av'],
126
			'MAS_FL_AV_SIZE'	=> $this->config['dark1_mas_fl_av_sz'],
127
			'MAS_FL_ONLINE'		=> $this->config['dark1_mas_fl_ol'],
128
		]);
129
	}
130
}
131