Passed
Push — develop ( 9d1625...a2d90c )
by Daniel
18:14
created

hot_topics::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 11
dl 0
loc 5
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
 *
5
 * @package sitemaker
6
 * @copyright (c) 2021 Daniel A. (blitze)
7
 * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
8
 *
9
 */
10
11
namespace blitze\sitemaker\blocks;
12
13
use blitze\sitemaker\services\blocks\driver\block;
14
15
/**
16
 * Hot Topics Block
17
 */
18
class hot_topics extends forum_topics
19
{
20
	/** @var \phpbb\config\config */
21
	protected $config;
22
23
	/**
24
	 * Constructor
25
	 *
26
	 * @param \phpbb\auth\auth							$auth				Permission object
27
	 * @param \phpbb\content_visibility					$content_visibility	Content visibility object
28
	 * @param \phpbb\language\language					$translator			Language object
29
	 * @param \phpbb\user								$user				User object
30
	 * @param \Urodoz\Truncate\TruncateService			$truncator			Truncator service
31
	 * @param \blitze\sitemaker\services\date_range		$date_range			Date Range Object
32
	 * @param \blitze\sitemaker\services\forum\data		$forum_data			Forum Data object
33
	 * @param \blitze\sitemaker\services\forum\options	$forum_options		Forum Data object
34
	 * @param string									$phpbb_root_path	Path to the phpbb includes directory.
35
	 * @param string									$php_ext			php file extension
36
	 * @param \phpbb\config\config						$config				phpBB configuration
37
	 */
38
	public function __construct(\phpbb\auth\auth $auth, \phpbb\content_visibility $content_visibility, \phpbb\language\language $translator, \phpbb\user $user, \Urodoz\Truncate\TruncateService $truncator, \blitze\sitemaker\services\date_range $date_range, \blitze\sitemaker\services\forum\data $forum_data, \blitze\sitemaker\services\forum\options $forum_options, $phpbb_root_path, $php_ext, \phpbb\config\config $config)
39
	{
40
		parent::__construct($auth, $content_visibility, $translator, $user, $truncator, $date_range, $forum_data, $forum_options, $phpbb_root_path, $php_ext);
41
42
		$this->config = $config;
43
	}
44
45
	/**
46
	 * {@inheritdoc}
47
	 */
48
	public function get_config(array $settings)
49
	{
50
		$config = parent::get_config($settings);
51
		unset($config['topic_type']);
52
53
		return $config;
54
	}
55
56
	/**
57
	 * @return string
58
	 */
59
	protected function get_block_title()
60
	{
61
		return 'HOT_TOPICS';
62
	}
63
64
	/**
65
	 * {@inheritdoc}
66
	 */
67
	protected function build_query()
68
	{
69
		parent::build_query();
70
71
		$this->forum_data->fetch_custom([
72
			'WHERE'	=> array('t.topic_posts_approved >' . $this->config['hot_threshold'])
73
		]);
74
	}
75
}
76