Conditions | 3 |
Paths | 4 |
Total Lines | 58 |
Code Lines | 24 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
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:
If many parameters/temporary variables are present:
1 | <?php |
||
23 | function xoops_module_update_contact($module, $version) |
||
|
|||
24 | { |
||
25 | $xoopsDB = XoopsDatabaseFactory::getDatabaseConnection(); |
||
26 | |||
27 | if ($version < 180) { |
||
28 | $sql = "CREATE TABLE " . $xoopsDB->prefix('contact') . " ( |
||
29 | contact_id int(10) unsigned NOT NULL auto_increment, |
||
30 | contact_uid int(10) NOT NULL, |
||
31 | contact_cid int(10) NOT NULL, |
||
32 | contact_create int(10) NOT NULL, |
||
33 | contact_subject varchar(255) NOT NULL, |
||
34 | contact_name varchar(255) NOT NULL, |
||
35 | contact_mail varchar(255) NOT NULL, |
||
36 | contact_url varchar(255) NOT NULL, |
||
37 | contact_icq varchar(255) NOT NULL, |
||
38 | contact_company varchar(255) NOT NULL, |
||
39 | contact_location varchar(255) NOT NULL, |
||
40 | contact_department varchar(60) NOT NULL, |
||
41 | contact_ip varchar(20) NOT NULL, |
||
42 | contact_phone varchar(20) NOT NULL, |
||
43 | contact_message text NOT NULL, |
||
44 | contact_address text NOT NULL, |
||
45 | contact_reply tinyint(1) NOT NULL, |
||
46 | PRIMARY KEY (contact_id) |
||
47 | ) ENGINE=MyISAM;"; |
||
48 | $xoopsDB->query($sql); |
||
49 | } |
||
50 | |||
51 | if ($version < 181) { |
||
52 | // Add contact_platform |
||
53 | $sql = "ALTER TABLE `" . $xoopsDB->prefix('contact') . "` ADD `contact_platform` ENUM('Android','Ios','Web') NOT NULL DEFAULT 'Web'"; |
||
54 | $xoopsDB->query($sql); |
||
55 | // Add contact_type |
||
56 | $sql = "ALTER TABLE `" . $xoopsDB->prefix('contact') . "` ADD `contact_type` ENUM('Contact','Phone','Mail') NOT NULL DEFAULT 'Contact'"; |
||
57 | $xoopsDB->query($sql); |
||
58 | // Add index contact_uid |
||
59 | $sql = "ALTER TABLE `" . $xoopsDB->prefix('contact') . "` ADD INDEX `contact_uid` ( `contact_uid` )"; |
||
60 | $xoopsDB->query($sql); |
||
61 | // Add index contact_cid |
||
62 | $sql = "ALTER TABLE `" . $xoopsDB->prefix('contact') . "` ADD INDEX `contact_cid` ( `contact_cid` )"; |
||
63 | $xoopsDB->query($sql); |
||
64 | // Add index contact_create |
||
65 | $sql = "ALTER TABLE `" . $xoopsDB->prefix('contact') . "` ADD INDEX `contact_create` ( `contact_create` )"; |
||
66 | $xoopsDB->query($sql); |
||
67 | // Add index contact_mail |
||
68 | $sql = "ALTER TABLE `" . $xoopsDB->prefix('contact') . "` ADD INDEX `contact_mail` ( `contact_mail` )"; |
||
69 | $xoopsDB->query($sql); |
||
70 | // Add index contact_phone |
||
71 | $sql = "ALTER TABLE `" . $xoopsDB->prefix('contact') . "` ADD INDEX `contact_phone` ( `contact_phone` )"; |
||
72 | $xoopsDB->query($sql); |
||
73 | // Add index contact_platform |
||
74 | $sql = "ALTER TABLE `" . $xoopsDB->prefix('contact') . "` ADD INDEX `contact_platform` ( `contact_platform` )"; |
||
75 | $xoopsDB->query($sql); |
||
76 | // Add index contact_type |
||
77 | $sql = "ALTER TABLE `" . $xoopsDB->prefix('contact') . "` ADD INDEX `contact_type` ( `contact_type` )"; |
||
78 | $xoopsDB->query($sql); |
||
79 | } |
||
80 | } |
||
81 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.