Completed
Push — master ( 7efdcc...e9c2cc )
by Michael
01:41
created

functions_update.php ➔ xoops_module_update_contact()   D

Complexity

Conditions 21
Paths 260

Size

Total Lines 58
Code Lines 65

Duplication

Lines 52
Ratio 89.66 %

Importance

Changes 0
Metric Value
cc 21
eloc 65
nc 260
nop 2
dl 52
loc 58
rs 4.7165
c 0
b 0
f 0

How to fix   Long Method    Complexity   

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
 You may not change or alter any portion of this comment or credits
4
 of supporting developers from this source code or any supporting source code
5
 which is considered copyrighted (c) material of the original comment or credit authors.
6
7
 This program is distributed in the hope that it will be useful,
8
 but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
*/
11
12
/**
13
 * Contact module
14
 *
15
 * @copyright   XOOPS Project (https://xoops.org)
16
 * @license     http://www.fsf.org/copyleft/gpl.html GNU public license
17
 * @author      Kazumi Ono (aka Onokazu)
18
 * @author      Trabis <[email protected]>
19
 * @author      Hossein Azizabadi (AKA Voltan)
20
 */
21
22
function xoops_module_update_contact(XoopsModule $module, $version)
0 ignored issues
show
Unused Code introduced by
The parameter $module is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
23
{
24
    $xoopsDB = XoopsDatabaseFactory::getDatabaseConnection();
25
26 View Code Duplication
    if ($version < 180) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
27
        $sql = 'CREATE TABLE ' . $xoopsDB->prefix('contact') . ' (
28
        contact_id int(10) unsigned NOT NULL auto_increment,
29
        contact_uid int(10) NOT NULL,
30
        contact_cid int(10) NOT NULL,
31
        contact_create int(10) NOT NULL,
32
        contact_subject varchar(255) NOT NULL,
33
        contact_name varchar(255) NOT NULL,
34
        contact_mail varchar(255) NOT NULL,
35
        contact_url varchar(255) NOT NULL,
36
        contact_icq varchar(255) NOT NULL,
37
        contact_company varchar(255) NOT NULL,
38
        contact_location varchar(255) NOT NULL,
39
        contact_department varchar(60) NOT NULL,
40
        contact_ip varchar(20) NOT NULL,
41
        contact_phone varchar(20) NOT NULL,
42
        contact_message text NOT NULL,
43
        contact_address text NOT NULL,
44
        contact_reply tinyint(1) NOT NULL,
45
        PRIMARY KEY  (contact_id)
46
        ) ENGINE=MyISAM;';
47
        $xoopsDB->query($sql);
48
    }
49
50 View Code Duplication
    if ($version < 181) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
51
        // Add contact_platform
52
        $sql = 'ALTER TABLE `' . $xoopsDB->prefix('contact') . "` ADD `contact_platform` ENUM('Android','Ios','Web') NOT NULL DEFAULT 'Web'";
53
        $xoopsDB->query($sql);
54
        // Add contact_type
55
        $sql = 'ALTER TABLE `' . $xoopsDB->prefix('contact') . "` ADD `contact_type` ENUM('Contact','Phone','Mail') NOT NULL DEFAULT 'Contact'";
56
        $xoopsDB->query($sql);
57
        // Add index contact_uid
58
        $sql = 'ALTER TABLE `' . $xoopsDB->prefix('contact') . '` ADD INDEX `contact_uid` ( `contact_uid` )';
59
        $xoopsDB->query($sql);
60
        // Add index contact_cid
61
        $sql = 'ALTER TABLE `' . $xoopsDB->prefix('contact') . '` ADD INDEX `contact_cid` ( `contact_cid` )';
62
        $xoopsDB->query($sql);
63
        // Add index contact_create
64
        $sql = 'ALTER TABLE `' . $xoopsDB->prefix('contact') . '` ADD INDEX `contact_create` ( `contact_create` )';
65
        $xoopsDB->query($sql);
66
        // Add index contact_mail
67
        $sql = 'ALTER TABLE `' . $xoopsDB->prefix('contact') . '` ADD INDEX `contact_mail` ( `contact_mail` )';
68
        $xoopsDB->query($sql);
69
        // Add index contact_phone
70
        $sql = 'ALTER TABLE `' . $xoopsDB->prefix('contact') . '` ADD INDEX `contact_phone` ( `contact_phone` )';
71
        $xoopsDB->query($sql);
72
        // Add index contact_platform
73
        $sql = 'ALTER TABLE `' . $xoopsDB->prefix('contact') . '` ADD INDEX `contact_platform` ( `contact_platform` )';
74
        $xoopsDB->query($sql);
75
        // Add index contact_type
76
        $sql = 'ALTER TABLE `' . $xoopsDB->prefix('contact') . '` ADD INDEX `contact_type` ( `contact_type` )';
77
        $xoopsDB->query($sql);
78
    }
79
}
80