From b9c824abc2b395f473fd4b7a488791da8254dd60 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Mon, 14 Jul 2014 13:37:56 -0400 Subject: [PATCH] Replace switch with a hash table. --- trustcommerce.php | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/trustcommerce.php b/trustcommerce.php index 6b029cd..d81c5a2 100644 --- a/trustcommerce.php +++ b/trustcommerce.php @@ -217,27 +217,19 @@ class org_fsf_payment_trustcommerce extends CRM_Core_Payment { * @public */ function _getRecurPaymentFields($fields) { - $payments = $this->_getParam('frequency_interval'); - $cycle = $this->_getParam('frequency_unit'); - /* Translate billing cycle from CiviCRM -> TC */ - switch($cycle) { - case 'day': - $cycle = 'd'; - break; - case 'week': - $cycle = 'w'; - break; - case 'month': - $cycle = 'm'; - break; - case 'year': - $cycle = 'y'; - break; - } - + $cycle_map = array( + 'day' => 'd', + 'week' => 'w', + 'month' => 'm', + 'year' => 'y' + ); + $cycle = $cycle_map[$this->_getParam('frequency_unit')]; + + /* Translate frequency interval from CiviCRM -> TC * Payments are the same, HOWEVER a payment of 1 (forever) should be 0 in TC */ + $payments = $this->_getParam('frequency_interval'); if($payments == 1) { $payments = 0; } -- 2.25.1