m9_views_clicks   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 73
Duplicated Lines 0 %

Importance

Changes 6
Bugs 0 Features 0
Metric Value
eloc 24
c 6
b 0
f 0
dl 0
loc 73
rs 10
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A update_schema() 0 9 1
A depends_on() 0 7 1
A update_data() 0 5 1
A effectively_installed() 0 3 1
A revert_schema() 0 9 1
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\v10x;
12
13
class m9_views_clicks extends \phpbb\db\migration\migration
0 ignored issues
show
Bug introduced by
The type phpbb\db\migration\migration was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

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_views');
21
	}
22
23
	/**
24
	 * {@inheritDoc}
25
	 */
26
	public static function depends_on()
27
	{
28
		return array(
29
			'\phpbb\ads\migrations\v10x\m1_initial_schema',
30
			'\phpbb\ads\migrations\v10x\m4_indexes',
31
			'\phpbb\ads\migrations\v10x\m5_end_date',
32
			'\phpbb\ads\migrations\v10x\m8_priority',
33
		);
34
	}
35
36
	/**
37
	 * Add the views and clicks to ads table
38
	 *
39
	 * @return array Array of table schema
40
	 * @access public
41
	 */
42
	public function update_schema()
43
	{
44
		return array(
45
			'add_columns' => array(
46
				$this->table_prefix . 'ads' => array(
47
					'ad_views'			=> array('UINT', 0),
48
					'ad_clicks'			=> array('UINT', 0),
49
					'ad_views_limit'	=> array('UINT', 0),
50
					'ad_clicks_limit'	=> array('UINT', 0),
51
				),
52
			),
53
		);
54
	}
55
56
	/**
57
	 * Drop the views and clicks from ads table
58
	 *
59
	 * @return array Array of table schema
60
	 * @access public
61
	 */
62
	public function revert_schema()
63
	{
64
		return array(
65
			'drop_columns' => array(
66
				$this->table_prefix . 'ads' => array(
67
					'ad_views',
68
					'ad_clicks',
69
					'ad_views_limit',
70
					'ad_clicks_limit',
71
				),
72
			),
73
		);
74
	}
75
76
	/**
77
	 * Add phpbb_ads_enable_views and phpbb_ads_enable_clicks config
78
	 *
79
	 * @return array Array of data update instructions
80
	 */
81
	public function update_data()
82
	{
83
		return array(
84
			array('config.add', array('phpbb_ads_enable_views', 0)),
85
			array('config.add', array('phpbb_ads_enable_clicks', 0)),
86
		);
87
	}
88
}
89