| Conditions | 1 |
| Paths | 1 |
| Total Lines | 77 |
| Code Lines | 62 |
| Lines | 77 |
| Ratio | 100 % |
| 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 |
||
| 106 | View Code Duplication | function install() { |
|
| 107 | $OSCOM_Db = Registry::get('Db'); |
||
| 108 | |||
| 109 | $OSCOM_Db->save('configuration', [ |
||
| 110 | 'configuration_title' => 'Enable Google AdWords Conversion Module', |
||
| 111 | 'configuration_key' => 'MODULE_HEADER_TAGS_GOOGLE_ADWORDS_CONVERSION_STATUS', |
||
| 112 | 'configuration_value' => 'True', |
||
| 113 | 'configuration_description' => 'Do you want to allow the Google AdWords Conversion Module on your checkout success page?', |
||
| 114 | 'configuration_group_id' => '6', |
||
| 115 | 'sort_order' => '1', |
||
| 116 | 'set_function' => 'tep_cfg_select_option(array(\'True\', \'False\'), ', |
||
| 117 | 'date_added' => 'now()' |
||
| 118 | ]); |
||
| 119 | |||
| 120 | $OSCOM_Db->save('configuration', [ |
||
| 121 | 'configuration_title' => 'Conversion ID', |
||
| 122 | 'configuration_key' => 'MODULE_HEADER_TAGS_GOOGLE_ADWORDS_CONVERSION_ID', |
||
| 123 | 'configuration_value' => '', |
||
| 124 | 'configuration_description' => 'The Google AdWords Conversion ID', |
||
| 125 | 'configuration_group_id' => '6', |
||
| 126 | 'sort_order' => '0', |
||
| 127 | 'date_added' => 'now()' |
||
| 128 | ]); |
||
| 129 | |||
| 130 | $OSCOM_Db->save('configuration', [ |
||
| 131 | 'configuration_title' => 'Tracking Notification Layout', |
||
| 132 | 'configuration_key' => 'MODULE_HEADER_TAGS_GOOGLE_ADWORDS_CONVERSION_FORMAT', |
||
| 133 | 'configuration_value' => '1', |
||
| 134 | 'configuration_description' => 'A small message will appear on your site telling customers that their visits on your site are being tracked. We recommend you use it.', |
||
| 135 | 'configuration_group_id' => '6', |
||
| 136 | 'sort_order' => '0', |
||
| 137 | 'set_function' => 'tep_cfg_google_adwords_conversion_set_format(', |
||
| 138 | 'use_function' => 'tep_cfg_google_adwords_conversion_get_format', |
||
| 139 | 'date_added' => 'now()' |
||
| 140 | ]); |
||
| 141 | |||
| 142 | $OSCOM_Db->save('configuration', [ |
||
| 143 | 'configuration_title' => 'Page Background Color', |
||
| 144 | 'configuration_key' => 'MODULE_HEADER_TAGS_GOOGLE_ADWORDS_CONVERSION_COLOR', |
||
| 145 | 'configuration_value' => 'ffffff', |
||
| 146 | 'configuration_description' => 'Enter a HTML color to match the color of your website background page.', |
||
| 147 | 'configuration_group_id' => '6', |
||
| 148 | 'sort_order' => '0', |
||
| 149 | 'date_added' => 'now()' |
||
| 150 | ]); |
||
| 151 | |||
| 152 | $OSCOM_Db->save('configuration', [ |
||
| 153 | 'configuration_title' => 'Conversion Label', |
||
| 154 | 'configuration_key' => 'MODULE_HEADER_TAGS_GOOGLE_ADWORDS_CONVERSION_LABEL', |
||
| 155 | 'configuration_value' => '', |
||
| 156 | 'configuration_description' => 'The alphanumeric code generated by Google for your AdWords Conversion', |
||
| 157 | 'configuration_group_id' => '6', |
||
| 158 | 'sort_order' => '0', |
||
| 159 | 'date_added' => 'now()' |
||
| 160 | ]); |
||
| 161 | |||
| 162 | $OSCOM_Db->save('configuration', [ |
||
| 163 | 'configuration_title' => 'Javascript Placement', |
||
| 164 | 'configuration_key' => 'MODULE_HEADER_TAGS_GOOGLE_ADWORDS_CONVERSION_JS_PLACEMENT', |
||
| 165 | 'configuration_value' => 'Footer', |
||
| 166 | 'configuration_description' => 'Should the Google AdWords Conversion javascript be loaded in the header or footer?', |
||
| 167 | 'configuration_group_id' => '6', |
||
| 168 | 'sort_order' => '0', |
||
| 169 | 'set_function' => 'tep_cfg_select_option(array(\'Header\', \'Footer\'), ', |
||
| 170 | 'date_added' => 'now()' |
||
| 171 | ]); |
||
| 172 | |||
| 173 | $OSCOM_Db->save('configuration', [ |
||
| 174 | 'configuration_title' => 'Sort Order', |
||
| 175 | 'configuration_key' => 'MODULE_HEADER_TAGS_GOOGLE_ADWORDS_CONVERSION_SORT_ORDER', |
||
| 176 | 'configuration_value' => '0', |
||
| 177 | 'configuration_description' => 'Sort order of display. Lowest is displayed first.', |
||
| 178 | 'configuration_group_id' => '6', |
||
| 179 | 'sort_order' => '0', |
||
| 180 | 'date_added' => 'now()' |
||
| 181 | ]); |
||
| 182 | } |
||
| 183 | |||
| 215 |
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.