Conditions | 3 |
Paths | 2 |
Total Lines | 68 |
Code Lines | 52 |
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 |
||
62 | function contactGetElements(&$block) |
||
63 | { |
||
64 | /** @var XoopsModuleHandler $moduleHandler */ |
||
65 | $moduleHandler = xoops_getHandler('module'); |
||
66 | $xoopsModule = $moduleHandler->getByDirname('contact'); |
||
67 | /** @var XoopsConfigHandler $configHandler */ |
||
68 | $configHandler = xoops_getHandler('config'); |
||
69 | $xoopsModuleConfig = $configHandler->getConfigsByCat(0, $xoopsModule->mid()); |
||
70 | |||
71 | xoops_loadLanguage('main', 'contact'); |
||
72 | |||
73 | require_once XOOPS_ROOT_PATH . '/modules/contact/class/contact.php'; |
||
74 | |||
75 | $block['lng_username'] = 'name'; |
||
76 | |||
77 | /*Modules Options*/ |
||
78 | if ($xoopsModuleConfig['form_dept'] == 1) { |
||
79 | // show a drop down with the correct departments listed |
||
80 | $departmentlist = array(); |
||
81 | $departments = xoops_getModuleOption('contact_dept', 'contact'); |
||
82 | foreach ($departments as $val) { |
||
83 | list($name, $email) = explode(',', $val, 2); //split the name and email |
||
84 | array_push($departmentlist, $name); |
||
85 | } |
||
86 | $block['depart'] = $xoopsModuleConfig['form_dept']; |
||
87 | $block['departments'] = $departmentlist; |
||
88 | } |
||
89 | $block['recaptcha'] = $xoopsModuleConfig['recaptchause']; |
||
90 | $block['recaptchakey'] = $xoopsModuleConfig['recaptchakey']; |
||
91 | $block['url'] = $xoopsModuleConfig['form_url']; |
||
92 | $block['icq'] = $xoopsModuleConfig['form_icq']; |
||
93 | $block['skype'] = $xoopsModuleConfig['form_skype']; |
||
94 | $block['company'] = $xoopsModuleConfig['form_company']; |
||
95 | $block['location'] = $xoopsModuleConfig['form_location']; |
||
96 | $block['phone'] = $xoopsModuleConfig['form_phone']; |
||
97 | $block['address'] = $xoopsModuleConfig['form_address']; |
||
98 | $block['info'] = $xoopsModuleConfig['contact_info']; |
||
99 | $block['contact_default'] = $xoopsModuleConfig['contact_default']; |
||
100 | $block['map'] = $xoopsModuleConfig['embed_maps']; |
||
101 | /*end Modules options*/ |
||
102 | |||
103 | /* get language vars*/ |
||
104 | $block['lng_username'] = _MD_CONTACT_NAME; |
||
105 | $block['lng_email'] = _MD_CONTACT_MAIL; |
||
106 | $block['lng_url'] = _MD_CONTACT_URL; |
||
107 | $block['lng_company'] = _MD_CONTACT_COMPANY; |
||
108 | $block['lng_icq'] = _MD_CONTACT_ICQ_NAME; |
||
109 | $block['lng_address'] = _MD_CONTACT_ADDRESS; |
||
110 | $block['lng_location'] = _MD_CONTACT_LOCATION; |
||
111 | $block['lng_phone'] = _MD_CONTACT_PHONE; |
||
112 | $block['lng_skypename'] = _MD_CONTACT_SKYPE_NAME; |
||
113 | $block['lng_department'] = _MD_CONTACT_DEPARTMENT; |
||
114 | $block['lng_subject'] = _MD_CONTACT_SUBJECT; |
||
115 | $block['lng_message'] = _MD_CONTACT_MESSAGE; |
||
116 | $block['lng_submit'] = _MD_CONTACT_SUBMIT; |
||
117 | |||
118 | $block['lng_username_info'] = _MD_CONTACT_NAME_INFO; |
||
119 | $block['lng_email_info'] = _MD_CONTACT_MAIL_INFO; |
||
120 | $block['lng_url_info'] = _MD_CONTACT_URL_INFO; |
||
121 | $block['lng_company_info'] = _MD_CONTACT_COMPANY_INFO; |
||
122 | $block['lng_address_info'] = _MD_CONTACT_ADDRESS_INFO; |
||
123 | $block['lng_location_info'] = _MD_CONTACT_LOCATION_INFO; |
||
124 | $block['lng_phone_info'] = _MD_CONTACT_PHONE_INFO; |
||
125 | $block['lng_icq_info'] = _MD_CONTACT_ICQ_INFO; |
||
126 | $block['lng_skypename_info'] = _MD_CONTACT_SKYPE_NAME_INFO; |
||
127 | $block['lng_subject_info'] = _MD_CONTACT_SUBJECT_INFO; |
||
128 | $block['lng_message_info'] = _MD_CONTACT_MESSAGE_INFO; |
||
129 | } |
||
130 |
Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a
@return
annotation as described here.