Completed
Push — master ( 7d29c5...8ac802 )
by Jakub
20s
created

m3_add_start_date   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 55
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 0
dl 55
loc 55
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A effectively_installed() 4 4 1
A depends_on() 7 7 1
A update_schema() 10 10 1
A revert_schema() 10 10 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\ads\migrations\v20x;
12
13 View Code Duplication
class m3_add_start_date extends \phpbb\db\migration\migration
1 ignored issue
show
Duplication introduced by
This class 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...
14
{
15
	/**
16
	 * {@inheritDoc}
17
	 */
18
	public function effectively_installed()
19
	{
20
		return $this->db_tools->sql_column_exists($this->table_prefix . 'ads', 'ad_start_date');
21
	}
22
23
	/**
24
	 * {@inheritDoc}
25
	 */
26
	public static function depends_on()
27
	{
28
		return [
29
			'\phpbb\ads\migrations\v10x\m1_initial_schema',
30
			'\phpbb\ads\migrations\v10x\m4_indexes',
31
		];
32
	}
33
34
	/**
35
	 * Add the start date option to ads table
36
	 *
37
	 * @return array Array of table schema
38
	 * @access public
39
	 */
40
	public function update_schema()
41
	{
42
		return [
43
			'add_columns' => [
44
				$this->table_prefix . 'ads' => [
45
					'ad_start_date' => ['TIMESTAMP', 0],
46
				],
47
			],
48
		];
49
	}
50
51
	/**
52
	 * Drop the start date option from ads table
53
	 *
54
	 * @return array Array of table schema
55
	 * @access public
56
	 */
57
	public function revert_schema()
58
	{
59
		return [
60
			'drop_columns' => [
61
				$this->table_prefix . 'ads' => [
62
					'ad_start_date',
63
				],
64
			],
65
		];
66
	}
67
}
68