Completed
Push — master ( 7d4e77...353440 )
by Matt
08:22
created

m2_acp_module   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 50
Duplicated Lines 24 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 0
dl 12
loc 50
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A depends_on() 0 4 1
A update_data() 0 18 1
A effectively_installed() 12 12 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
 * Advertisement management. An extension for the phpBB Forum Software package.
5
 *
6
 * @copyright (c) 2017 phpBB Limited <https://www.phpbb.com>
7
 * @license GNU General Public License, version 2 (GPL-2.0)
8
 *
9
 */
10
11
namespace phpbb\admanagement\migrations\v10x;
12
13
class m2_acp_module extends \phpbb\db\migration\migration
14
{
15
	/**
16
	* {@inheritDoc}
17
	*/
18 View Code Duplication
	public function effectively_installed()
1 ignored issue
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
19
	{
20
		$sql = 'SELECT module_id
21
			FROM ' . $this->table_prefix . "modules
22
			WHERE module_class = 'acp'
23
				AND module_langname = 'ACP_ADMANAGEMENT_TITLE'";
24
		$result = $this->db->sql_query($sql);
25
		$module_id = (int) $this->db->sql_fetchfield('module_id');
26
		$this->db->sql_freeresult($result);
27
28
		return $module_id;
29
	}
30
31
	/**
32
	* {@inheritDoc}
33
	*/
34
	static public function depends_on()
1 ignored issue
show
Coding Style introduced by
As per PSR2, the static declaration should come after the visibility declaration.
Loading history...
35
	{
36
		return array('\phpbb\admanagement\migrations\v10x\m1_initial_schema');
37
	}
38
39
	/**
40
	* Add the ACP module
41
	*
42
	* @return array Array of data update instructions
43
	*/
44
	public function update_data()
45
	{
46
		return array(
47
			array('module.add', array(
48
				'acp',
49
				'ACP_CAT_DOT_MODS',
50
				'ACP_ADMANAGEMENT_TITLE'
51
			)),
52
			array('module.add', array(
53
				'acp',
54
				'ACP_ADMANAGEMENT_TITLE',
55
				array(
56
					'module_basename'	=> '\phpbb\admanagement\acp\main_module',
57
					'modes'				=> array('manage'),
58
				),
59
			)),
60
		);
61
	}
62
}
63