m2_initial_data   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 14
c 0
b 0
f 0
dl 0
loc 56
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A depends_on() 0 3 1
A update_data() 0 4 1
A add_autogroups_type_data() 0 23 2
1
<?php
2
/**
3
*
4
* Auto Groups extension for the phpBB Forum Software package.
5
*
6
* @copyright (c) 2014 phpBB Limited <https://www.phpbb.com>
7
* @license GNU General Public License, version 2 (GPL-2.0)
8
*
9
*/
10
11
namespace phpbb\autogroups\migrations\v10x;
12
13
/**
14
 * Migration stage 2: Initial data
15
 */
16
class m2_initial_data 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...
17
{
18
	/**
19
	 * Assign migration file dependencies for this migration
20
	 *
21
	 * @return array Array of migration files
22
	 * @static
23
	 * @access public
24
	 */
25
	public static function depends_on()
26
	{
27
		return array('\phpbb\autogroups\migrations\v10x\m1_initial_schema');
28
	}
29
30
	/**
31
	 * Add or update data in the database
32
	 *
33
	 * @return array Array of table data
34
	 * @access public
35
	 */
36
	public function update_data()
37
	{
38
		return array(
39
			array('custom', array(array($this, 'add_autogroups_type_data'))),
40
		);
41
	}
42
43
	/**
44
	 * Add auto group types to the database
45
	 *
46
	 * @return void
47
	 * @access public
48
	 */
49
	public function add_autogroups_type_data()
50
	{
51
		// Load the insert buffer class to perform a buffered multi insert
52
		$insert_buffer = new \phpbb\db\sql_insert_buffer($this->db, $this->table_prefix . 'autogroups_types');
0 ignored issues
show
Bug introduced by
The type phpbb\db\sql_insert_buffer 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...
53
54
		// Auto group types array
55
		$types = array(
56
			'birthdays',
57
			'membership',
58
			'posts',
59
			'warnings',
60
		);
61
62
		// Insert data
63
		foreach ($types as $type)
64
		{
65
			$insert_buffer->insert(array(
66
				'autogroups_type_name'	=> 'phpbb.autogroups.type.' . $type,
67
			));
68
		}
69
70
		// Flush the buffer
71
		$insert_buffer->flush();
72
	}
73
}
74