CRM-14106 - Regex targeting the first part of if statements
[civicrm-core.git] / CRM / Contribute / BAO / Contribution / Utils.php
index 13ad6d9ecda5e7c1766c830a7c9647178861dd87..536105ba5046ab790fb4ab8b0d8a99af046b3ba1 100644 (file)
@@ -65,7 +65,7 @@ class CRM_Contribute_BAO_Contribution_Utils {
     if (isset($paymentParams['financial_type'])) {
       $contributionType->id = $paymentParams['financial_type'];
     }
-    elseif (CRM_Utils_Array::value('pledge_id', $form->_values)) {
+    elseif (!empty($form->_values['pledge_id'])) {
       $contributionType->id = CRM_Core_DAO::getFieldValue('CRM_Pledge_DAO_Pledge',
         $form->_values['pledge_id'],
         'financial_type_id'
@@ -200,7 +200,7 @@ class CRM_Contribute_BAO_Contribution_Utils {
       }
     }
     elseif ($form->_values['is_monetary'] && $form->_amount > 0.0) {
-      if (CRM_Utils_Array::value('is_recur', $paymentParams) &&
+      if (!empty($paymentParams['is_recur']) &&
         $form->_contributeMode == 'direct'
       ) {
 
@@ -240,10 +240,10 @@ class CRM_Contribute_BAO_Contribution_Utils {
 
     if (is_a($result, 'CRM_Core_Error')) {
       //make sure to cleanup db for recurring case.
-      if (CRM_Utils_Array::value('contributionID', $paymentParams)) {
+      if (!empty($paymentParams['contributionID'])) {
         CRM_Contribute_BAO_Contribution::deleteContribution($paymentParams['contributionID']);
       }
-      if (CRM_Utils_Array::value('contributionRecurID', $paymentParams)) {
+      if (!empty($paymentParams['contributionRecurID'])) {
         CRM_Contribute_BAO_ContributionRecur::deleteRecurContribution($paymentParams['contributionRecurID']);
       }
 
@@ -279,9 +279,8 @@ class CRM_Contribute_BAO_Contribution_Utils {
 
       // check if pending was set to true by payment processor
       $pending = FALSE;
-      if (CRM_Utils_Array::value('contribution_status_pending',
-          $form->_params
-        )) {
+      if (!empty($form->_params
+['contribution_status_pending'])) {
         $pending = TRUE;
       }
       if (!(!empty($paymentParams['is_recur']) && $form->_contributeMode == 'direct')) {
@@ -418,7 +417,7 @@ INNER JOIN   civicrm_contact contact ON ( contact.id = contrib.contact_id )
     }
     $created = TRUE;
 
-    if (CRM_Utils_Array::value('cms_create_account', $params)) {
+    if (!empty($params['cms_create_account'])) {
       $params['contactID'] = $contactID;
       if (!CRM_Core_BAO_CMSUser::create($params, $mail)) {
         CRM_Core_Error::statusBounce(ts('Your profile is not saved and Account is not created.'));
@@ -602,10 +601,10 @@ INNER JOIN   civicrm_contact contact ON ( contact.id = contrib.contact_id )
 
       if ($riskInfo['google-order-number']['VALUE'] == $apiParams[2]['google-order-number']['VALUE']) {
         foreach ($riskInfo['risk-information']['billing-address'] as $field => $info) {
-          if (CRM_Utils_Array::value($field, $mapper['location'])) {
+          if (!empty($mapper['location'][$field])) {
             $params['address'][1][$mapper['location'][$field]] = $info['VALUE'];
           }
-          elseif (CRM_Utils_Array::value($field, $mapper['contact'])) {
+          elseif (!empty($mapper['contact'][$field])) {
             if ($newOrder && CRM_Utils_Array::value('structured-name', $newOrder['buyer-billing-address'])) {
               foreach ($newOrder['buyer-billing-address']['structured-name'] as $namePart => $nameValue) {
                 $params[$mapper['contact'][$namePart]] = $nameValue['VALUE'];
@@ -615,7 +614,7 @@ INNER JOIN   civicrm_contact contact ON ( contact.id = contrib.contact_id )
               $params[$mapper['contact'][$field]] = $info['VALUE'];
             }
           }
-          elseif (CRM_Utils_Array::value($field, $mapper['transaction'])) {
+          elseif (!empty($mapper['transaction'][$field])) {
             $transaction[$mapper['transaction'][$field]] = $info['VALUE'];
           }
         }
@@ -661,7 +660,7 @@ INNER JOIN   civicrm_contact contact ON ( contact.id = contrib.contact_id )
         }
 
         foreach ($localMapper as $localKey => $localVal) {
-          if (CRM_Utils_Array::value($localKey, $mapper['transaction'])) {
+          if (!empty($mapper['transaction'][$localKey])) {
             $transaction[$mapper['transaction'][$localKey]] = $localVal;
           }
         }
@@ -693,7 +692,7 @@ INNER JOIN   civicrm_contact contact ON ( contact.id = contrib.contact_id )
     $dedupeParams['check_permission'] = FALSE;
     $dupeIds = CRM_Dedupe_Finder::dupesByParams($dedupeParams, 'Individual');
     // if we find more than one contact, use the first one
-    if (CRM_Utils_Array::value(0, $dupeIds)) {
+    if (!empty($dupeIds[0])) {
       $params['contact_id'] = $dupeIds[0];
     }
     $contact = CRM_Contact_BAO_Contact::create($params);