From a8504da493e98f8d339de42cfa25abbc0e343afc Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Thu, 23 Apr 2020 13:58:55 -0400 Subject: [PATCH] REF - Code cleaup: replace clunky coalesce conditionals with simple coalesce expressions using ?? --- CRM/Core/BAO/OptionValue.php | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/CRM/Core/BAO/OptionValue.php b/CRM/Core/BAO/OptionValue.php index d12967b938..0cbb6177ee 100644 --- a/CRM/Core/BAO/OptionValue.php +++ b/CRM/Core/BAO/OptionValue.php @@ -55,18 +55,10 @@ class CRM_Core_BAO_OptionValue extends CRM_Core_DAO_OptionValue { * @param array $params */ public static function setDefaults(&$params) { - if (CRM_Utils_Array::value('label', $params, NULL) === NULL) { - $params['label'] = $params['name']; - } - if (CRM_Utils_Array::value('name', $params, NULL) === NULL) { - $params['name'] = CRM_Utils_String::titleToVar($params['label']); - } - if (CRM_Utils_Array::value('weight', $params, NULL) === NULL) { - $params['weight'] = self::getDefaultWeight($params); - } - if (CRM_Utils_Array::value('value', $params, NULL) === NULL) { - $params['value'] = self::getDefaultValue($params); - } + $params['label'] = $params['label'] ?? $params['name']; + $params['name'] = $params['name'] ?? CRM_Utils_String::titleToVar($params['label']); + $params['weight'] = $params['weight'] ?? self::getDefaultWeight($params); + $params['value'] = $params['value'] ?? self::getDefaultValue($params); } /** -- 2.25.1