REF - Cleanup overly-verbose conditionals
authorcolemanw <coleman@civicrm.org>
Wed, 29 Nov 2023 16:56:28 +0000 (11:56 -0500)
committercolemanw <coleman@civicrm.org>
Thu, 30 Nov 2023 00:09:05 +0000 (19:09 -0500)
CRM/Activity/BAO/Activity.php
CRM/Case/BAO/Case.php
CRM/Contact/BAO/ContactType.php
CRM/Contact/BAO/Relationship.php
CRM/Core/BAO/Address.php
CRM/Core/Config.php
CRM/Core/Payment.php
CRM/Mailing/Page/View.php
CRM/Member/StatusOverrideTypes.php

index d74f4fd2aa46d6de8f82418a33ce8ddc0530228b..1b9722d5cc7286cb33db6a3309ed4b4ce122200b 100644 (file)
@@ -2297,13 +2297,9 @@ INNER JOIN  civicrm_option_group grp ON (grp.id = option_group_id AND grp.name =
    * @return bool
    */
   public static function checkEditInboundEmailsPermissions() {
-    if (CRM_Core_Permission::check('edit inbound email basic information')
-      || CRM_Core_Permission::check('edit inbound email basic information and content')
-    ) {
-      return TRUE;
-    }
-
-    return FALSE;
+    return CRM_Core_Permission::check([
+      ['edit inbound email basic information', /* OR */ 'edit inbound email basic information and content'],
+    ]);
   }
 
   /**
index ddb2f68c4e1b215335bfce8d89d73d4364030e3f..c0d1a23dbe18abc0dc8daf2985721c797a36a3c8 100644 (file)
@@ -2704,13 +2704,9 @@ WHERE id IN (' . implode(',', $copiedActivityIds) . ')';
       return FALSE;
     }
 
-    if (CRM_Core_Permission::check('access my cases and activities') ||
-      CRM_Core_Permission::check('access all cases and activities')
-    ) {
-      return TRUE;
-    }
-
-    return FALSE;
+    return CRM_Core_Permission::check([
+      ['access my cases and activities', /* OR */ 'access all cases and activities'],
+    ]);
   }
 
   /**
index de18235c96444c5494890dc4cf03081e514382fc..0059f499e4afed03ff37d62a1666271290dc0342 100644 (file)
@@ -693,11 +693,7 @@ LIMIT 1";
 
     $relationshipCount = CRM_Core_DAO::singleValueQuery($relationshipQuery);
 
-    if (!empty($relationshipCount)) {
-      return TRUE;
-    }
-
-    return FALSE;
+    return (bool) $relationshipCount;
   }
 
   /**
index 9d231e0fe40ec2ab77bbde6e0cbbc2d2ba4a63c1..2afef78d8717f14f9ab5fb16a7f0b7f10def2538 100644 (file)
@@ -1590,13 +1590,7 @@ contact_id_a IN ( %1 ) OR contact_id_b IN ( %1 ) AND id IN (" . implode(',', $re
       return TRUE;
     }
 
-    $recordsFound = (int) CRM_Core_DAO::singleValueQuery("SELECT COUNT(*) FROM civicrm_relationship WHERE relationship_type_id IN ( " . implode(',', $membershipTypeRelationshipTypeIDs) . " ) AND contact_id_a IN ( %1, %2 ) AND contact_id_b IN ( %1, %2 ) AND id NOT IN (" . implode(',', $relIds) . ")", $relParamas);
-
-    if ($recordsFound) {
-      return FALSE;
-    }
-
-    return TRUE;
+    return !CRM_Core_DAO::singleValueQuery("SELECT COUNT(*) FROM civicrm_relationship WHERE relationship_type_id IN ( " . implode(',', $membershipTypeRelationshipTypeIDs) . " ) AND contact_id_a IN ( %1, %2 ) AND contact_id_b IN ( %1, %2 ) AND id NOT IN (" . implode(',', $relIds) . ")", $relParamas);
   }
 
   /**
index aa219d505506012452fbd642d142f57d30f7bfcd..d73e543dc89e3fc298151ee585bf2951d872d8a2 100644 (file)
@@ -777,11 +777,7 @@ ORDER BY civicrm_address.is_primary DESC, civicrm_address.location_type_id DESC,
 
     $parsingSupportedLocales = ['en_US', 'en_CA', 'fr_CA'];
 
-    if (in_array($locale, $parsingSupportedLocales)) {
-      return TRUE;
-    }
-
-    return FALSE;
+    return in_array($locale, $parsingSupportedLocales);
   }
 
   /**
index 2018a486fb1ec7f10e5c8508a32b09e883610681..86353a8a497199b613a314d8abe448b623ee42f3 100644 (file)
@@ -431,11 +431,7 @@ class CRM_Core_Config extends CRM_Core_Config_MagicMerge {
       $path = $_GET[$urlVar] ?? NULL;
     }
 
-    if ($path && preg_match('/^civicrm\/upgrade(\/.*)?$/', $path)) {
-      return TRUE;
-    }
-
-    return FALSE;
+    return ($path && preg_match('/^civicrm\/upgrade(\/.*)?$/', $path));
   }
 
   /**
index f1e11d30a723b7516564378b4b9ce5c9050649de..373f8d1c631273cd6d583c28426251cc3c22a6b2 100644 (file)
@@ -1560,15 +1560,11 @@ abstract class CRM_Core_Payment {
       return FALSE;
     }
 
-    if (isset($_GET['payment_date']) &&
+    return (isset($_GET['payment_date']) &&
       isset($_GET['merchant_return_link']) &&
       ($_GET['payment_status'] ?? NULL) == 'Completed' &&
       $paymentProcessor['payment_processor_type'] == "PayPal_Standard"
-    ) {
-      return TRUE;
-    }
-
-    return FALSE;
+    );
   }
 
   /**
index 2f775981776dc181bea54951bf1c40f1f05f02f6..ef39231236443a7c4c4a6f74790aa899f702185e 100644 (file)
@@ -44,14 +44,9 @@ class CRM_Mailing_Page_View extends CRM_Core_Page {
     }
 
     // if user is an admin, return true
-    if (CRM_Core_Permission::check('administer CiviCRM') ||
-      CRM_Core_Permission::check('approve mailings') ||
-      CRM_Core_Permission::check('access CiviMail')
-    ) {
-      return TRUE;
-    }
-
-    return FALSE;
+    return CRM_Core_Permission::check([
+      ['administer CiviCRM', /* OR */ 'approve mailings', /* OR */ 'access CiviMail'],
+    ]);
   }
 
   /**
index 57451fafa1e0ef2c6df44f7806eb59b638c2e3b7..c75439703a05470bceafa7d0d184a02b388b7bdc 100644 (file)
@@ -65,35 +65,19 @@ class CRM_Member_StatusOverrideTypes {
    * @return bool
    */
   public static function isOverridden($overrideType) {
-    if ($overrideType == self::NO) {
-      return FALSE;
-    }
-
-    return TRUE;
+    return $overrideType != self::NO;
   }
 
   public static function isNo($overrideType) {
-    if ($overrideType != self::NO) {
-      return FALSE;
-    }
-
-    return TRUE;
+    return $overrideType == self::NO;
   }
 
   public static function isPermanent($overrideType) {
-    if ($overrideType != self::PERMANENT) {
-      return FALSE;
-    }
-
-    return TRUE;
+    return $overrideType == self::PERMANENT;
   }
 
   public static function isUntilDate($overrideType) {
-    if ($overrideType != self::UNTIL_DATE) {
-      return FALSE;
-    }
-
-    return TRUE;
+    return $overrideType == self::UNTIL_DATE;
   }
 
 }