v310_m2_data::update_data()   B
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 82
Code Lines 58

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 58
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 82
rs 8.9163

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
/**
3
 *
4
 * PayPal Donation extension for the phpBB Forum Software package.
5
 *
6
 * @copyright (c) 2015-2020 Skouat
7
 * @license GNU General Public License, version 2 (GPL-2.0)
8
 *
9
 */
10
11
namespace skouat\ppde\migrations\v31x;
12
13
class v310_m2_data extends \phpbb\db\migration\migration
14
{
15
	public static function depends_on()
16
	{
17
		return ['\skouat\ppde\migrations\v31x\v310_m1_schema'];
18
	}
19
20
	public function update_data()
21
	{
22
		return [
23
			// Global Settings
24
			['config.add', ['ppde_enable', false]],
25
			['config.add', ['ppde_header_link', false]],
26
			['config.add', ['ppde_account_id', '']],
27
			['config.add', ['ppde_default_currency', 1]],
28
			['config.add', ['ppde_default_value', 0]],
29
			['config.add', ['ppde_dropbox_enable', false]],
30
			['config.add', ['ppde_dropbox_value', '1,2,3,4,5,10,20,25,50,100']],
31
32
			// IPN Settings
33
			['config.add', ['ppde_ipn_enable', false]],
34
			['config.add', ['ppde_ipn_autogroup_enable', false]],
35
			['config.add', ['ppde_ipn_donorlist_enable', false]],
36
			['config.add', ['ppde_ipn_group_id', 2]],
37
			['config.add', ['ppde_ipn_group_as_default', false]],
38
			['config.add', ['ppde_ipn_balance', 0]],
39
			['config.add', ['ppde_ipn_logging', false]],
40
			['config.add', ['ppde_ipn_notification_enable', false]],
41
			['config.add', ['ppde_curl_detected', false]],
42
			['config.add', ['ppde_curl_version', '']],
43
			['config.add', ['ppde_curl_ssl_version', '']],
44
			['config.add', ['ppde_fsock_detected', false]],
45
46
			// Sandbox Settings
47
			['config.add', ['ppde_sandbox_enable', false]],
48
			['config.add', ['ppde_sandbox_founder_enable', true]],
49
			['config.add', ['ppde_sandbox_address', '']],
50
51
			// Statistics Settings
52
			['config.add', ['ppde_stats_index_enable', false]],
53
			['config.add', ['ppde_goal', 0]],
54
			['config.add', ['ppde_goal_enable', false]],
55
			['config.add', ['ppde_raised', 0]],
56
			['config.add', ['ppde_raised_ipn', 0]],
57
			['config.add', ['ppde_raised_enable', false]],
58
			['config.add', ['ppde_used', 0]],
59
			['config.add', ['ppde_used_enable', false]],
60
61
			// Overview Settings
62
			['config.add', ['ppde_anonymous_donors_count', 0]],
63
			['config.add', ['ppde_anonymous_donors_count_ipn', 0]],
64
			['config.add', ['ppde_known_donors_count', 0]],
65
			['config.add', ['ppde_known_donors_count_ipn', 0]],
66
			['config.add', ['ppde_transactions_count', 0]],
67
			['config.add', ['ppde_transactions_count_ipn', 0]],
68
69
			//Misc Settings
70
			['config.add', ['ppde_install_date', time()]],
71
			['config.add', ['ppde_first_start', true]],
72
73
			// Add new permissions
74
			['permission.add', ['a_ppde_manage', true]],
75
			['permission.add', ['u_ppde_use', true]],
76
			['permission.add', ['u_ppde_view_donorlist', true]],
77
78
			// Assign permissions to roles
79
			['permission.permission_set', ['ROLE_ADMIN_FULL', ['a_ppde_manage']]],
80
			['permission.permission_set', ['ROLE_USER_FULL', ['u_ppde_use']]],
81
			['permission.permission_set', ['ROLE_USER_FULL', ['u_ppde_view_donorlist']]],
82
83
			// Add new module
84
			['module.add', [
85
				'acp',
86
				'ACP_CAT_DOT_MODS',
87
				'PPDE_ACP_DONATION',
88
				[
89
					'module_enabled'  => 1,
90
					'module_display'  => 1,
91
					'module_langname' => 'PPDE_ACP_DONATION',
92
					'module_auth'     => 'ext_skouat/ppde && acl_a_ppde_manage',
93
				],
94
			]],
95
96
			['module.add', [
97
				'acp',
98
				'PPDE_ACP_DONATION',
99
				[
100
					'module_basename' => '\skouat\ppde\acp\ppde_module',
101
					'modes'           => ['overview', 'settings', 'donation_pages', 'currency', 'transactions'],
102
				],
103
			]],
104
		];
105
	}
106
}
107