Conditions | 21 |
Paths | 260 |
Total Lines | 58 |
Code Lines | 65 |
Lines | 52 |
Ratio | 89.66 % |
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 |
||
22 | function xoops_module_update_contact(XoopsModule $module, $version) |
||
|
|||
23 | { |
||
24 | $xoopsDB = XoopsDatabaseFactory::getDatabaseConnection(); |
||
25 | |||
26 | View Code Duplication | if ($version < 180) { |
|
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) { |
|
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 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.