Code Duplication    Length = 67-67 lines in 2 locations

catalog/includes/apps/braintree/OSCOM_Braintree.php 1 location

@@ 247-313 (lines=67) @@
244
      return $result;
245
    }
246
247
    function getInputParameters($module) {
248
      $result = array();
249
250
      if ( $module == 'G' ) {
251
        $cut = 'OSCOM_APP_PAYPAL_BRAINTREE_';
252
      } else {
253
        $cut = 'OSCOM_APP_PAYPAL_BRAINTREE_' . $module . '_';
254
      }
255
256
      $cut_length = strlen($cut);
257
258
      foreach ( $this->getParameters($module) as $key ) {
259
        $p = strtolower(substr($key, $cut_length));
260
261
        if ( $module == 'G' ) {
262
          $cfg_class = 'OSCOM_Braintree_Cfg_' . $p;
263
264
          if ( !class_exists($cfg_class) ) {
265
            $this->loadLanguageFile('cfg_params/' . $p . '.php');
266
267
            include(DIR_FS_CATALOG . 'includes/apps/braintree/cfg_params/' . $p . '.php');
268
          }
269
        } else {
270
          $cfg_class = 'OSCOM_Braintree_' . $module . '_Cfg_' . $p;
271
272
          if ( !class_exists($cfg_class) ) {
273
            $this->loadLanguageFile('modules/' . $module . '/cfg_params/' . $p . '.php');
274
275
            include(DIR_FS_CATALOG . 'includes/apps/braintree/modules/' . $module . '/cfg_params/' . $p . '.php');
276
          }
277
        }
278
279
        $cfg = new $cfg_class();
280
281
        if ( !defined($key) ) {
282
          $this->saveParameter($key, $cfg->default, isset($cfg->title) ? $cfg->title : null, isset($cfg->description) ? $cfg->description : null, isset($cfg->set_func) ? $cfg->set_func : null);
283
        }
284
285
        if ( !isset($cfg->app_configured) || ($cfg->app_configured !== false) ) {
286
          if ( isset($cfg->sort_order) && is_numeric($cfg->sort_order) ) {
287
            $counter = (int)$cfg->sort_order;
288
          } else {
289
            $counter = count($result);
290
          }
291
292
          while ( true ) {
293
            if ( isset($result[$counter]) ) {
294
              $counter++;
295
296
              continue;
297
            }
298
299
            $set_field = $cfg->getSetField();
300
301
            if ( !empty($set_field) ) {
302
              $result[$counter] = $set_field;
303
            }
304
305
            break;
306
          }
307
        }
308
      }
309
310
      ksort($result, SORT_NUMERIC);
311
312
      return $result;
313
    }
314
315
    function makeApiCall($url, $parameters = null, $headers = null, $opts = null) {
316
      $server = parse_url($url);

catalog/includes/apps/paypal/OSCOM_PayPal.php 1 location

@@ 293-359 (lines=67) @@
290
      return $result;
291
    }
292
293
    function getInputParameters($module) {
294
      $result = array();
295
296
      if ( $module == 'G' ) {
297
        $cut = 'OSCOM_APP_PAYPAL_';
298
      } else {
299
        $cut = 'OSCOM_APP_PAYPAL_' . $module . '_';
300
      }
301
302
      $cut_length = strlen($cut);
303
304
      foreach ( $this->getParameters($module) as $key ) {
305
        $p = strtolower(substr($key, $cut_length));
306
307
        if ( $module == 'G' ) {
308
          $cfg_class = 'OSCOM_PayPal_Cfg_' . $p;
309
310
          if ( !class_exists($cfg_class) ) {
311
            $this->loadLanguageFile('cfg_params/' . $p . '.php');
312
313
            include(DIR_FS_CATALOG . 'includes/apps/paypal/cfg_params/' . $p . '.php');
314
          }
315
        } else {
316
          $cfg_class = 'OSCOM_PayPal_' . $module . '_Cfg_' . $p;
317
318
          if ( !class_exists($cfg_class) ) {
319
            $this->loadLanguageFile('modules/' . $module . '/cfg_params/' . $p . '.php');
320
321
            include(DIR_FS_CATALOG . 'includes/apps/paypal/modules/' . $module . '/cfg_params/' . $p . '.php');
322
          }
323
        }
324
325
        $cfg = new $cfg_class();
326
327
        if ( !defined($key) ) {
328
          $this->saveParameter($key, $cfg->default, isset($cfg->title) ? $cfg->title : null, isset($cfg->description) ? $cfg->description : null, isset($cfg->set_func) ? $cfg->set_func : null);
329
        }
330
331
        if ( !isset($cfg->app_configured) || ($cfg->app_configured !== false) ) {
332
          if ( isset($cfg->sort_order) && is_numeric($cfg->sort_order) ) {
333
            $counter = (int)$cfg->sort_order;
334
          } else {
335
            $counter = count($result);
336
          }
337
338
          while ( true ) {
339
            if ( isset($result[$counter]) ) {
340
              $counter++;
341
342
              continue;
343
            }
344
345
            $set_field = $cfg->getSetField();
346
347
            if ( !empty($set_field) ) {
348
              $result[$counter] = $set_field;
349
            }
350
351
            break;
352
          }
353
        }
354
      }
355
356
      ksort($result, SORT_NUMERIC);
357
358
      return $result;
359
    }
360
361
// APP calls require $server to be "live" or "sandbox"
362
    function getApiResult($module, $call, $extra_params = null, $server = null, $is_ipn = false) {