topic_in_queue::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 8
dl 0
loc 5
ccs 0
cts 2
cp 0
crap 2
rs 10

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
 * @package sitemaker
5
 * @copyright (c) 2017 Daniel A. (blitze)
6
 * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
7
 *
8
 */
9
10
namespace blitze\content\services\notification;
11
12
/**
13
 * @property int $item_parent_id
14
 * @property int $item_id
15
 */
16
class topic_in_queue extends \phpbb\notification\type\topic_in_queue
17
{
18
	/* @var \blitze\content\services\types */
19
	protected $types;
20
21
	/**
22
	 * Notification Type Base Constructor
23
	 *
24
	 * @param \phpbb\db\driver\driver_interface $db
25
	 * @param \phpbb\language\language          $language
26
	 * @param \phpbb\user                       $user
27
	 * @param \phpbb\auth\auth                  $auth
28
	 * @param string                            $phpbb_root_path
29
	 * @param string                            $php_ext
30
	 * @param string                            $user_notifications_table
31
	 * @param \blitze\content\services\types	$types
32
	 */
33
	public function __construct(\phpbb\db\driver\driver_interface $db, \phpbb\language\language $language, \phpbb\user $user, \phpbb\auth\auth $auth, $phpbb_root_path, $php_ext, $user_notifications_table, \blitze\content\services\types $types)
34
	{
35
		parent::__construct($db, $language, $user, $auth, $phpbb_root_path, $php_ext, $user_notifications_table);
36
37
		$this->types = $types;
38
	}
39
40
	/**
41
	* Get the url to this item
42
	*
43
	* @return string URL
44
	*/
45
	public function get_url()
46
	{
47
		if ($type = $this->types->get_forum_type($this->item_parent_id))
48
		{
49
			return append_sid($this->phpbb_root_path . 'mcp.' . $this->php_ext, "i=-blitze-content-mcp-content_module&amp;mode=content&amp;type=$type&amp;t={$this->item_id}&amp;do=view");
50
		}
51
52
		return parent::get_url();
53
	}
54
}
55