Completed
Push — develop ( dfba50...3f30aa )
by Tino
07:19
created

Migration::schemaUpdates()   B

Complexity

Conditions 5
Paths 16

Size

Total Lines 53
Code Lines 39

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 5
eloc 39
nc 16
nop 0
dl 0
loc 53
rs 8.9848
c 0
b 0
f 0

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
 * Copyright (c) by the ACP3 Developers.
5
 * See the LICENSE file at the top-level module directory for licensing details.
6
 */
7
8
namespace ACP3\Modules\ACP3\Contact\Installer;
9
10
use ACP3\Core\Modules;
11
12
class Migration extends Modules\Installer\AbstractMigration
13
{
14
    /**
15
     * {@inheritdoc}
16
     *
17
     * @return array
18
     */
19
    public function schemaUpdates()
20
    {
21
        return [
22
            31 => [
23
                "UPDATE `{pre}acl_resources` SET privilege_id = 7 WHERE `page` = 'acp_list' AND `module_id` = '{moduleId}';",
24
            ],
25
            32 => [
26
                "INSERT INTO `{pre}acl_resources` (`id`, `module_id`, `page`, `params`, `privilege_id`) VALUES('', '{moduleId}', 'sidebar', '', 1);",
27
            ],
28
            33 => [
29
                'UPDATE `{pre}seo` SET `uri`=REPLACE(`uri`, "contact/", "contact/index/") WHERE `uri` LIKE "contact/%";',
30
            ],
31
            34 => [
32
                $this->schemaHelper->moduleIsInstalled('menus') || $this->schemaHelper->moduleIsInstalled('menu_items') ? 'UPDATE `{pre}menu_items` SET `uri` = "contact/index/index/" WHERE `uri` = "contact/list/";' : '',
33
                $this->schemaHelper->moduleIsInstalled('menus') || $this->schemaHelper->moduleIsInstalled('menu_items') ? 'UPDATE `{pre}menu_items` SET `uri` = "contact/index/imprint/" WHERE `uri` = "contact/imprint/";' : '',
34
            ],
35
            35 => [
36
                'UPDATE `{pre}seo` SET `uri` = "contact/index/index/" WHERE `uri` = "contact/index/list/";',
37
            ],
38
            36 => [
39
                "INSERT INTO `{pre}settings` (`id`, `module_id`, `name`, `value`) VALUES ('', '{moduleId}', 'vat_id', '');",
40
            ],
41
            37 => [
42
                "INSERT INTO `{pre}settings` (`id`, `module_id`, `name`, `value`) VALUES ('', '{moduleId}', 'ceo', '');",
43
            ],
44
            38 => [
45
                "UPDATE `{pre}acl_resources` SET `area` = 'widget' WHERE `module_id` = '{moduleId}' AND `area` = 'sidebar';",
46
            ],
47
            39 => [
48
                "UPDATE `{pre}acl_resources` SET `privilege_id` = 3 WHERE `module_id` = '{moduleId}' AND `area` = 'admin' AND `controller` = 'index' AND `page` = 'index';",
49
                "INSERT INTO `{pre}acl_resources` (`module_id`, `area`, `controller`, `page`, `params`, `privilege_id`) VALUES ('{moduleId}', 'admin', 'index', 'settings', '', 7);",
50
            ],
51
            40 => [
52
                "INSERT INTO `{pre}settings` (`id`, `module_id`, `name`, `value`) VALUES ('', '{moduleId}', 'mobile_phone', '');",
53
                "INSERT INTO `{pre}settings` (`id`, `module_id`, `name`, `value`) VALUES ('', '{moduleId}', 'picture_credits', '');",
54
            ],
55
            41 => [
56
                'CREATE TABLE `{pre}contacts` (
57
                    `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
58
                    `date` DATETIME NOT NULL,
59
                    `mail` VARCHAR(120) NOT NULL,
60
                    `name` VARCHAR(80) NOT NULL,
61
                    `message` TEXT NOT NULL,
62
                    PRIMARY KEY (`id`)
63
                ) {ENGINE} {CHARSET};',
64
            ],
65
            42 => [
66
                'ALTER TABLE `{pre}contacts` MODIFY COLUMN `mail` VARCHAR(120) {charset} NOT NULL;',
67
                'ALTER TABLE `{pre}contacts` MODIFY COLUMN `message` TEXT {charset} NOT NULL;',
68
                'ALTER TABLE `{pre}contacts` CONVERT TO {charset};',
69
            ],
70
            43 => [
71
                "INSERT INTO `{pre}acl_resources` (`module_id`, `area`, `controller`, `page`, `params`, `privilege_id`) VALUES ('{moduleId}', 'admin', 'index', 'delete', '', 6);",
72
            ],
73
        ];
74
    }
75
76
    /**
77
     * {@inheritdoc}
78
     *
79
     * @return array
80
     */
81
    public function renameModule()
82
    {
83
        return [];
84
    }
85
}
86