From dcb148082af818050ec0d9c56b04acd37967b34c Mon Sep 17 00:00:00 2001 From: eileen Date: Tue, 21 Jul 2020 16:17:42 +1200 Subject: [PATCH] [REF] remove unnecessary variable variables For a brief but terrifying spell this arvo I delved into this function to try to understand the purpose of 'preserveDBName'. Obviously I ran screaming from the room but I thought I could disarm these few lines to slighly file down the fangs of the beast. Code is heavily covered by tests --- CRM/Contact/BAO/Individual.php | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/CRM/Contact/BAO/Individual.php b/CRM/Contact/BAO/Individual.php index 679e9229f5..af28e7a244 100644 --- a/CRM/Contact/BAO/Individual.php +++ b/CRM/Contact/BAO/Individual.php @@ -50,9 +50,9 @@ class CRM_Contact_BAO_Individual extends CRM_Contact_DAO_Contact { } $sortName = $displayName = ''; - $firstName = CRM_Utils_Array::value('first_name', $params, ''); - $middleName = CRM_Utils_Array::value('middle_name', $params, ''); - $lastName = CRM_Utils_Array::value('last_name', $params, ''); + $firstName = trim($params['first_name'] ?? ''); + $middleName = trim($params['middle_name'] ?? ''); + $lastName = trim($params['last_name'] ?? ''); $nickName = CRM_Utils_Array::value('nick_name', $params, ''); $prefix_id = CRM_Utils_Array::value('prefix_id', $params, ''); $suffix_id = CRM_Utils_Array::value('suffix_id', $params, ''); @@ -162,11 +162,6 @@ class CRM_Contact_BAO_Individual extends CRM_Contact_DAO_Contact { } } - //first trim before further processing. - foreach (['lastName', 'firstName', 'middleName'] as $fld) { - $$fld = trim($$fld); - } - if ($lastName || $firstName || $middleName) { // make sure we have values for all the name fields. $formatted = $params; -- 2.25.1