clock   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 91
Duplicated Lines 10.99 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 10
loc 91
ccs 22
cts 22
cp 1
rs 10
c 0
b 0
f 0
wmc 7
lcom 1
cbo 1

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A get_template_side() 0 8 3
A get_template_acp() 10 10 1
A install() 0 5 1
A uninstall() 0 5 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
/**
3
*
4
* @package Board3 Portal v2.1
5
* @copyright (c) 2013 Board3 Group ( www.board3.de )
6
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
7
*
8
*/
9
10
namespace board3\portal\modules;
11
12
/**
13
* @package Clock
14
*/
15
class clock extends module_base
16
{
17
	/**
18
	* Allowed columns: Just sum up your options (Exp: left + right = 10)
19
	* top		1
20
	* left		2
21
	* center	4
22
	* right		8
23
	* bottom	16
24
	*/
25
	public $columns = 10;
26
27
	/**
28
	* Default modulename
29
	*/
30
	public $name = 'CLOCK';
31
32
	/**
33
	* Default module-image:
34
	* file must be in "{T_THEME_PATH}/images/portal/"
35
	*/
36
	public $image_src = 'portal_clock.png';
37
38
	/**
39
	* module-language file
40
	* file must be in "language/{$user->lang}/mods/portal/"
41
	*/
42
	public $language = 'portal_clock_module';
43
44
	/** @var \phpbb\config\config */
45
	protected $config;
46
47
	/** @var \phpbb\template\template */
48
	protected $template;
49
50
	/**
51
	 * Constructor for clock module
52
	 *
53
	 * @param \phpbb\config\config $config phpBB config
54
	 * @param \phpbb\template\template $template phpBB template
55
	 */
56 49
	public function __construct($config, $template)
57
	{
58 49
		$this->config = $config;
59 49
		$this->template = $template;
60 49
	}
61
62
	/**
63
	* {@inheritdoc}
64
	*/
65 4
	public function get_template_side($module_id)
66
	{
67 4
		if (isset($this->config['board3_clock_src_' . $module_id]) && !empty($this->config['board3_clock_src_' . $module_id]))
68 4
		{
69 1
			$this->template->assign_var('B3P_CLOCK_SRC', $this->config['board3_clock_src_' . $module_id]);
70 1
		}
71 4
		return 'clock_side.html';
72
	}
73
74
	/**
75
	* {@inheritdoc}
76
	*/
77 1 View Code Duplication
	public function get_template_acp($module_id)
78
	{
79
		return array(
80 1
			'title'	=> 'ACP_PORTAL_CLOCK_SETTINGS',
81
			'vars'	=> array(
82 1
				'legend1'	=> 'ACP_PORTAL_CLOCK_SETTINGS',
83 1
				'board3_clock_src_' . $module_id	=> array('lang' => 'ACP_PORTAL_CLOCK_SRC', 'validate' => 'string', 'type' => 'text:50:200', 'explain' => true, 'submit_type' => 'custom', 'submit' => 'check_file_src'),
84 1
			),
85 1
		);
86
	}
87
88
	/**
89
	 * {@inheritdoc}
90
	 */
91 1
	public function install($module_id)
92
	{
93 1
		$this->config->set('board3_clock_src_' . $module_id, '');
94 1
		return true;
95
	}
96
97
	/**
98
	 * {@inheritdoc}
99
	 */
100 1
	public function uninstall($module_id, $db)
101
	{
102 1
		$this->config->delete('board3_clock_src_' . $module_id);
103 1
		return true;
104
	}
105
}
106