Conditions | 45 |
Paths | > 20000 |
Total Lines | 153 |
Code Lines | 81 |
Lines | 51 |
Ratio | 33.33 % |
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 |
||
95 | function migrate($OSCOM_PayPal) { |
||
96 | View Code Duplication | if ( defined('MODULE_PAYMENT_PAYPAL_STANDARD_GATEWAY_SERVER') ) { |
|
97 | $server = (MODULE_PAYMENT_PAYPAL_STANDARD_GATEWAY_SERVER == 'Live') ? 'LIVE' : 'SANDBOX'; |
||
98 | |||
99 | if ( defined('MODULE_PAYMENT_PAYPAL_STANDARD_ID') ) { |
||
100 | if ( tep_not_null(MODULE_PAYMENT_PAYPAL_STANDARD_ID) ) { |
||
101 | if ( !defined('OSCOM_APP_PAYPAL_' . $server . '_SELLER_EMAIL') || !tep_not_null(constant('OSCOM_APP_PAYPAL_' . $server . '_SELLER_EMAIL')) ) { |
||
102 | $OSCOM_PayPal->saveParameter('OSCOM_APP_PAYPAL_' . $server . '_SELLER_EMAIL', MODULE_PAYMENT_PAYPAL_STANDARD_ID); |
||
103 | } |
||
104 | } |
||
105 | |||
106 | $OSCOM_PayPal->deleteParameter('MODULE_PAYMENT_PAYPAL_STANDARD_ID'); |
||
107 | } |
||
108 | |||
109 | if ( defined('MODULE_PAYMENT_PAYPAL_STANDARD_PRIMARY_ID') ) { |
||
110 | if ( tep_not_null(MODULE_PAYMENT_PAYPAL_STANDARD_PRIMARY_ID) ) { |
||
111 | if ( !defined('OSCOM_APP_PAYPAL_' . $server . '_SELLER_EMAIL_PRIMARY') || !tep_not_null(constant('OSCOM_APP_PAYPAL_' . $server . '_SELLER_EMAIL_PRIMARY')) ) { |
||
112 | $OSCOM_PayPal->saveParameter('OSCOM_APP_PAYPAL_' . $server . '_SELLER_EMAIL_PRIMARY', MODULE_PAYMENT_PAYPAL_STANDARD_PRIMARY_ID); |
||
113 | } |
||
114 | } |
||
115 | |||
116 | $OSCOM_PayPal->deleteParameter('MODULE_PAYMENT_PAYPAL_STANDARD_PRIMARY_ID'); |
||
117 | } |
||
118 | } |
||
119 | |||
120 | if ( defined('MODULE_PAYMENT_PAYPAL_STANDARD_PAGE_STYLE') ) { |
||
121 | $OSCOM_PayPal->deleteParameter('MODULE_PAYMENT_PAYPAL_STANDARD_PAGE_STYLE'); |
||
122 | } |
||
123 | |||
124 | if ( defined('MODULE_PAYMENT_PAYPAL_STANDARD_TRANSACTION_METHOD') ) { |
||
125 | $OSCOM_PayPal->saveParameter('OSCOM_APP_PAYPAL_PS_TRANSACTION_METHOD', (MODULE_PAYMENT_PAYPAL_STANDARD_TRANSACTION_METHOD == 'Sale') ? '1' : '0'); |
||
126 | $OSCOM_PayPal->deleteParameter('MODULE_PAYMENT_PAYPAL_STANDARD_TRANSACTION_METHOD'); |
||
127 | } |
||
128 | |||
129 | if ( defined('MODULE_PAYMENT_PAYPAL_STANDARD_PREPARE_ORDER_STATUS_ID') ) { |
||
130 | $OSCOM_PayPal->saveParameter('OSCOM_APP_PAYPAL_PS_PREPARE_ORDER_STATUS_ID', MODULE_PAYMENT_PAYPAL_STANDARD_PREPARE_ORDER_STATUS_ID); |
||
131 | $OSCOM_PayPal->deleteParameter('MODULE_PAYMENT_PAYPAL_STANDARD_PREPARE_ORDER_STATUS_ID'); |
||
132 | } |
||
133 | |||
134 | if ( defined('MODULE_PAYMENT_PAYPAL_STANDARD_ORDER_STATUS_ID') ) { |
||
135 | $OSCOM_PayPal->saveParameter('OSCOM_APP_PAYPAL_PS_ORDER_STATUS_ID', MODULE_PAYMENT_PAYPAL_STANDARD_ORDER_STATUS_ID); |
||
136 | $OSCOM_PayPal->deleteParameter('MODULE_PAYMENT_PAYPAL_STANDARD_ORDER_STATUS_ID'); |
||
137 | } |
||
138 | |||
139 | if ( defined('MODULE_PAYMENT_PAYPAL_STANDARD_ZONE') ) { |
||
140 | $OSCOM_PayPal->saveParameter('OSCOM_APP_PAYPAL_PS_ZONE', MODULE_PAYMENT_PAYPAL_STANDARD_ZONE); |
||
141 | $OSCOM_PayPal->deleteParameter('MODULE_PAYMENT_PAYPAL_STANDARD_ZONE'); |
||
142 | } |
||
143 | |||
144 | if ( defined('MODULE_PAYMENT_PAYPAL_STANDARD_SORT_ORDER') ) { |
||
145 | $OSCOM_PayPal->saveParameter('OSCOM_APP_PAYPAL_PS_SORT_ORDER', MODULE_PAYMENT_PAYPAL_STANDARD_SORT_ORDER, 'Sort Order', 'Sort order of display (lowest to highest).'); |
||
146 | $OSCOM_PayPal->deleteParameter('MODULE_PAYMENT_PAYPAL_STANDARD_SORT_ORDER'); |
||
147 | } |
||
148 | |||
149 | if ( defined('MODULE_PAYMENT_PAYPAL_STANDARD_TRANSACTIONS_ORDER_STATUS_ID') ) { |
||
150 | $OSCOM_PayPal->deleteParameter('MODULE_PAYMENT_PAYPAL_STANDARD_TRANSACTIONS_ORDER_STATUS_ID'); |
||
151 | } |
||
152 | |||
153 | View Code Duplication | if ( defined('MODULE_PAYMENT_PAYPAL_STANDARD_STATUS') ) { |
|
154 | $status = '-1'; |
||
155 | |||
156 | if ( (MODULE_PAYMENT_PAYPAL_STANDARD_STATUS == 'True') && defined('MODULE_PAYMENT_PAYPAL_STANDARD_GATEWAY_SERVER') ) { |
||
157 | if ( MODULE_PAYMENT_PAYPAL_STANDARD_GATEWAY_SERVER == 'Live' ) { |
||
158 | $status = '1'; |
||
159 | } else { |
||
160 | $status = '0'; |
||
161 | } |
||
162 | } |
||
163 | |||
164 | $OSCOM_PayPal->saveParameter('OSCOM_APP_PAYPAL_PS_STATUS', $status); |
||
165 | $OSCOM_PayPal->deleteParameter('MODULE_PAYMENT_PAYPAL_STANDARD_STATUS'); |
||
166 | } |
||
167 | |||
168 | if ( defined('MODULE_PAYMENT_PAYPAL_STANDARD_GATEWAY_SERVER') ) { |
||
169 | $OSCOM_PayPal->deleteParameter('MODULE_PAYMENT_PAYPAL_STANDARD_GATEWAY_SERVER'); |
||
170 | } |
||
171 | |||
172 | View Code Duplication | if ( defined('MODULE_PAYMENT_PAYPAL_STANDARD_VERIFY_SSL') ) { |
|
173 | if ( !defined('OSCOM_APP_PAYPAL_VERIFY_SSL') ) { |
||
174 | $OSCOM_PayPal->saveParameter('OSCOM_APP_PAYPAL_VERIFY_SSL', (MODULE_PAYMENT_PAYPAL_STANDARD_VERIFY_SSL == 'True') ? '1' : '0'); |
||
175 | } |
||
176 | |||
177 | $OSCOM_PayPal->deleteParameter('MODULE_PAYMENT_PAYPAL_STANDARD_VERIFY_SSL'); |
||
178 | } |
||
179 | |||
180 | View Code Duplication | if ( defined('MODULE_PAYMENT_PAYPAL_STANDARD_PROXY') ) { |
|
181 | if ( !defined('OSCOM_APP_PAYPAL_PROXY') ) { |
||
182 | $OSCOM_PayPal->saveParameter('OSCOM_APP_PAYPAL_PROXY', MODULE_PAYMENT_PAYPAL_STANDARD_PROXY); |
||
183 | } |
||
184 | |||
185 | $OSCOM_PayPal->deleteParameter('MODULE_PAYMENT_PAYPAL_STANDARD_PROXY'); |
||
186 | } |
||
187 | |||
188 | if ( defined('MODULE_PAYMENT_PAYPAL_STANDARD_DEBUG_EMAIL') ) { |
||
189 | $OSCOM_PayPal->deleteParameter('MODULE_PAYMENT_PAYPAL_STANDARD_DEBUG_EMAIL'); |
||
190 | } |
||
191 | |||
192 | if ( defined('MODULE_PAYMENT_PAYPAL_STANDARD_EWP_STATUS') ) { |
||
193 | if ( !defined('OSCOM_APP_PAYPAL_PS_EWP_STATUS') ) { |
||
194 | $OSCOM_PayPal->saveParameter('OSCOM_APP_PAYPAL_PS_EWP_STATUS', (MODULE_PAYMENT_PAYPAL_STANDARD_EWP_STATUS == 'True') ? '1' : '-1'); |
||
195 | } |
||
196 | |||
197 | $OSCOM_PayPal->deleteParameter('MODULE_PAYMENT_PAYPAL_STANDARD_EWP_STATUS'); |
||
198 | } |
||
199 | |||
200 | if ( defined('MODULE_PAYMENT_PAYPAL_STANDARD_EWP_PRIVATE_KEY') ) { |
||
201 | if ( !defined('OSCOM_APP_PAYPAL_PS_EWP_PRIVATE_KEY') ) { |
||
202 | $OSCOM_PayPal->saveParameter('OSCOM_APP_PAYPAL_PS_EWP_PRIVATE_KEY', MODULE_PAYMENT_PAYPAL_STANDARD_EWP_PRIVATE_KEY); |
||
203 | } |
||
204 | |||
205 | $OSCOM_PayPal->deleteParameter('MODULE_PAYMENT_PAYPAL_STANDARD_EWP_PRIVATE_KEY'); |
||
206 | } |
||
207 | |||
208 | if ( defined('MODULE_PAYMENT_PAYPAL_STANDARD_EWP_PUBLIC_KEY') ) { |
||
209 | if ( !defined('OSCOM_APP_PAYPAL_PS_EWP_PUBLIC_CERT') ) { |
||
210 | $OSCOM_PayPal->saveParameter('OSCOM_APP_PAYPAL_PS_EWP_PUBLIC_CERT', MODULE_PAYMENT_PAYPAL_STANDARD_EWP_PUBLIC_KEY); |
||
211 | } |
||
212 | |||
213 | $OSCOM_PayPal->deleteParameter('MODULE_PAYMENT_PAYPAL_STANDARD_EWP_PUBLIC_KEY'); |
||
214 | } |
||
215 | |||
216 | if ( defined('MODULE_PAYMENT_PAYPAL_STANDARD_EWP_CERT_ID') ) { |
||
217 | if ( !defined('OSCOM_APP_PAYPAL_PS_EWP_PUBLIC_CERT_ID') ) { |
||
218 | $OSCOM_PayPal->saveParameter('OSCOM_APP_PAYPAL_PS_EWP_PUBLIC_CERT_ID', MODULE_PAYMENT_PAYPAL_STANDARD_EWP_CERT_ID); |
||
219 | } |
||
220 | |||
221 | $OSCOM_PayPal->deleteParameter('MODULE_PAYMENT_PAYPAL_STANDARD_EWP_CERT_ID'); |
||
222 | } |
||
223 | |||
224 | if ( defined('MODULE_PAYMENT_PAYPAL_STANDARD_EWP_PAYPAL_KEY') ) { |
||
225 | if ( !defined('OSCOM_APP_PAYPAL_PS_EWP_PAYPAL_CERT') ) { |
||
226 | $OSCOM_PayPal->saveParameter('OSCOM_APP_PAYPAL_PS_EWP_PAYPAL_CERT', MODULE_PAYMENT_PAYPAL_STANDARD_EWP_PAYPAL_KEY); |
||
227 | } |
||
228 | |||
229 | $OSCOM_PayPal->deleteParameter('MODULE_PAYMENT_PAYPAL_STANDARD_EWP_PAYPAL_KEY'); |
||
230 | } |
||
231 | |||
232 | if ( defined('MODULE_PAYMENT_PAYPAL_STANDARD_EWP_WORKING_DIRECTORY') ) { |
||
233 | if ( !defined('OSCOM_APP_PAYPAL_PS_EWP_WORKING_DIRECTORY') ) { |
||
234 | $OSCOM_PayPal->saveParameter('OSCOM_APP_PAYPAL_PS_EWP_WORKING_DIRECTORY', MODULE_PAYMENT_PAYPAL_STANDARD_EWP_WORKING_DIRECTORY); |
||
235 | } |
||
236 | |||
237 | $OSCOM_PayPal->deleteParameter('MODULE_PAYMENT_PAYPAL_STANDARD_EWP_WORKING_DIRECTORY'); |
||
238 | } |
||
239 | |||
240 | if ( defined('MODULE_PAYMENT_PAYPAL_STANDARD_EWP_OPENSSL') ) { |
||
241 | if ( !defined('OSCOM_APP_PAYPAL_PS_EWP_OPENSSL') ) { |
||
242 | $OSCOM_PayPal->saveParameter('OSCOM_APP_PAYPAL_PS_EWP_OPENSSL', MODULE_PAYMENT_PAYPAL_STANDARD_EWP_OPENSSL); |
||
243 | } |
||
244 | |||
245 | $OSCOM_PayPal->deleteParameter('MODULE_PAYMENT_PAYPAL_STANDARD_EWP_OPENSSL'); |
||
246 | } |
||
247 | } |
||
248 | } |
||
250 |
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.