m8_default_exemption_data   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
dl 0
loc 46
rs 10
c 1
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A update_default_exempt_groups() 0 6 1
A depends_on() 0 5 1
A update_data() 0 8 1
1
<?php
2
/**
3
*
4
* Auto Groups extension for the phpBB Forum Software package.
5
*
6
* @copyright (c) 2015 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 8: Group default exemption data
15
 */
16
class m8_default_exemption_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(
28
			'\phpbb\autogroups\migrations\v10x\m3_config_data',
29
			'\phpbb\autogroups\migrations\v10x\m7_default_exemption_schema'
30
		);
31
	}
32
33
	/**
34
	 * Add or update data in the database
35
	 *
36
	 * @return array Array of table data
37
	 * @access public
38
	 */
39
	public function update_data()
40
	{
41
		return array(
42
			// Remove deprecated config item
43
			array('config.remove', array('autogroups_default_exempt')),
44
45
			// Enable default exemption for Administrators and Global Mods
46
			array('custom', array(array($this, 'update_default_exempt_groups'))),
47
		);
48
	}
49
50
	/**
51
	 * Set Administrators and Global Moderators to default exempt
52
	 *
53
	 * @return void
54
	 * @access public
55
	 */
56
	public function update_default_exempt_groups()
57
	{
58
		$sql = 'UPDATE ' . GROUPS_TABLE . '
0 ignored issues
show
Bug introduced by
The constant phpbb\autogroups\migrations\v10x\GROUPS_TABLE was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
59
			SET autogroup_default_exempt = 1
60
			WHERE ' . $this->db->sql_in_set('group_name', array('ADMINISTRATORS', 'GLOBAL_MODERATORS'));
61
		$this->db->sql_query($sql);
62
	}
63
}
64