Conditions | 22 |
Paths | > 20000 |
Total Lines | 49 |
Code Lines | 39 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 506 |
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 |
||
42 | function additionalDetailsLead($fields) { |
||
43 | static $mod_strings; |
||
44 | if(empty($mod_strings)) { |
||
45 | global $current_language; |
||
46 | $mod_strings = return_module_language($current_language, 'Leads'); |
||
47 | } |
||
48 | |||
49 | $overlib_string = ''; |
||
50 | if(!empty($fields['ID'])) { |
||
51 | $overlib_string .= '<input type="hidden" value="'. $fields['ID']; |
||
52 | $overlib_string .= '">'; |
||
53 | } |
||
54 | |||
55 | $overlib_string .= '<h2><img src="index.php?entryPoint=getImage&themeName=' . SugarThemeRegistry::current()->name .'&imageName=Leads.gif"/> '.$mod_strings['LBL_CONTACT'].'</h2>'; |
||
|
|||
56 | |||
57 | if(!empty($fields['PRIMARY_ADDRESS_STREET']) || !empty($fields['PRIMARY_ADDRESS_CITY']) || |
||
58 | !empty($fields['PRIMARY_ADDRESS_STATE']) || !empty($fields['PRIMARY_ADDRESS_POSTALCODE']) || |
||
59 | !empty($fields['PRIMARY_ADDRESS_COUNTRY'])) |
||
60 | $overlib_string .= '<b>' . $mod_strings['LBL_PRIMARY_ADDRESS'] . '</b><br>'; |
||
61 | if(!empty($fields['PRIMARY_ADDRESS_STREET'])) $overlib_string .= $fields['PRIMARY_ADDRESS_STREET'] . '<br>'; |
||
62 | if(!empty($fields['PRIMARY_ADDRESS_CITY'])) $overlib_string .= $fields['PRIMARY_ADDRESS_CITY'] . ', '; |
||
63 | if(!empty($fields['PRIMARY_ADDRESS_STATE'])) $overlib_string .= $fields['PRIMARY_ADDRESS_STATE'] . ' '; |
||
64 | if(!empty($fields['PRIMARY_ADDRESS_POSTALCODE'])) $overlib_string .= $fields['PRIMARY_ADDRESS_POSTALCODE'] . ' '; |
||
65 | if(!empty($fields['PRIMARY_ADDRESS_COUNTRY'])) $overlib_string .= $fields['PRIMARY_ADDRESS_COUNTRY'] . '<br>'; |
||
66 | if(strlen($overlib_string) > 0 && !(strrpos($overlib_string, '<br>') == strlen($overlib_string) - 4)) |
||
67 | $overlib_string .= '<br>'; |
||
68 | if(!empty($fields['PHONE_MOBILE'])) $overlib_string .= '<b>'. $mod_strings['LBL_MOBILE_PHONE'] . '</b> <span class="phone">' . $fields['PHONE_MOBILE'] . '</span><br>'; |
||
69 | if(!empty($fields['PHONE_HOME'])) $overlib_string .= '<b>'. $mod_strings['LBL_HOME_PHONE'] . '</b> <span class="phone">' . $fields['PHONE_HOME'] . '</span><br>'; |
||
70 | if(!empty($fields['PHONE_OTHER'])) $overlib_string .= '<b>'. $mod_strings['LBL_OTHER_PHONE'] . '</b> <span class="phone">' . $fields['PHONE_OTHER'] . '</span><br>'; |
||
71 | if(!empty($fields['LEAD_SOURCE'])) $overlib_string .= '<b>'. $mod_strings['LBL_LEAD_SOURCE'] . '</b> ' . $fields['LEAD_SOURCE'] . '<br>'; |
||
72 | |||
73 | if(!empty($fields['EMAIL2'])) |
||
74 | $overlib_string .= '<b>'. $mod_strings['LBL_OTHER_EMAIL_ADDRESS'] . '</b> ' . |
||
75 | "<a href=index.php?module=Emails&action=Compose&contact_id={$fields['ID']}&" . |
||
76 | "parent_type=Contacts&parent_id={$fields['ID']}&to_addrs_ids={$fields['ID']}&to_addrs_names" . |
||
77 | "={$fields['FIRST_NAME']} {$fields['LAST_NAME']}&to_addrs_emails={$fields['EMAIL2']}&" . |
||
78 | "to_email_addrs=" . urlencode("{$fields['FIRST_NAME']} {$fields['LAST_NAME']} <{$fields['EMAIL2']}>") . |
||
79 | "&return_module=Contacts&return_action=ListView'>{$fields['EMAIL2']}</a><br>"; |
||
80 | |||
81 | if(!empty($fields['DESCRIPTION'])) { |
||
82 | $overlib_string .= '<b>'. $mod_strings['LBL_DESCRIPTION'] . '</b> ' . substr($fields['DESCRIPTION'], 0, 300); |
||
83 | if(strlen($fields['DESCRIPTION']) > 300) $overlib_string .= '...'; |
||
84 | } |
||
85 | |||
86 | return array('fieldToAddTo' => 'NAME', |
||
87 | 'string' => $overlib_string, |
||
88 | 'editLink' => "index.php?action=EditView&module=Leads&return_module=Leads&record={$fields['ID']}", |
||
89 | 'viewLink' => "index.php?action=DetailView&module=Leads&return_module=Leads&record={$fields['ID']}"); |
||
90 | } |
||
91 | |||
94 |
Since your code implements the magic setter
_set
, this function will be called for any write access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.Since the property has write access only, you can use the @property-write annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.