Conditions | 1 |
Paths | 1 |
Total Lines | 58 |
Code Lines | 47 |
Lines | 58 |
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 |
||
72 | View Code Duplication | function install() { |
|
73 | $OSCOM_Db = Registry::get('Db'); |
||
74 | |||
75 | $OSCOM_Db->save('configuration', [ |
||
76 | 'configuration_title' => 'Enable Flat Shipping', |
||
77 | 'configuration_key' => 'MODULE_SHIPPING_FLAT_STATUS', |
||
78 | 'configuration_value' => 'True', |
||
79 | 'configuration_description' => 'Do you want to offer flat rate shipping?', |
||
80 | 'configuration_group_id' => '6', |
||
81 | 'sort_order' => '1', |
||
82 | 'set_function' => 'tep_cfg_select_option(array(\'True\', \'False\'), ', |
||
83 | 'date_added' => 'now()' |
||
84 | ]); |
||
85 | |||
86 | $OSCOM_Db->save('configuration', [ |
||
87 | 'configuration_title' => 'Shipping Cost', |
||
88 | 'configuration_key' => 'MODULE_SHIPPING_FLAT_COST', |
||
89 | 'configuration_value' => '5.00', |
||
90 | 'configuration_description' => 'The shipping cost for all orders using this shipping method.', |
||
91 | 'configuration_group_id' => '6', |
||
92 | 'sort_order' => '1', |
||
93 | 'date_added' => 'now()' |
||
94 | ]); |
||
95 | |||
96 | $OSCOM_Db->save('configuration', [ |
||
97 | 'configuration_title' => 'Tax Class', |
||
98 | 'configuration_key' => 'MODULE_SHIPPING_FLAT_TAX_CLASS', |
||
99 | 'configuration_value' => '0', |
||
100 | 'configuration_description' => 'Use the following tax class on the shipping fee.', |
||
101 | 'configuration_group_id' => '6', |
||
102 | 'sort_order' => '1', |
||
103 | 'use_function' => 'tep_get_tax_class_title', |
||
104 | 'set_function' => 'tep_cfg_pull_down_tax_classes(', |
||
105 | 'date_added' => 'now()' |
||
106 | ]); |
||
107 | |||
108 | $OSCOM_Db->save('configuration', [ |
||
109 | 'configuration_title' => 'Shipping Zone', |
||
110 | 'configuration_key' => 'MODULE_SHIPPING_FLAT_ZONE', |
||
111 | 'configuration_value' => '0', |
||
112 | 'configuration_description' => 'If a zone is selected, only enable this shipping method for that zone.', |
||
113 | 'configuration_group_id' => '6', |
||
114 | 'sort_order' => '1', |
||
115 | 'use_function' => 'tep_get_zone_class_title', |
||
116 | 'set_function' => 'tep_cfg_pull_down_zone_classes(', |
||
117 | 'date_added' => 'now()' |
||
118 | ]); |
||
119 | |||
120 | $OSCOM_Db->save('configuration', [ |
||
121 | 'configuration_title' => 'Sort Order', |
||
122 | 'configuration_key' => 'MODULE_SHIPPING_FLAT_SORT_ORDER', |
||
123 | 'configuration_value' => '0', |
||
124 | 'configuration_description' => 'Sort order of display. Lowest is displayed first.', |
||
125 | 'configuration_group_id' => '6', |
||
126 | 'sort_order' => '0', |
||
127 | 'date_added' => 'now()' |
||
128 | ]); |
||
129 | } |
||
130 | |||
140 |
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.