-
-
Notifications
You must be signed in to change notification settings - Fork 814
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[REF] Use bool instead of boolean #17013
Conversation
(Standard links)
|
CRM/Report/Form/Grant/Statistics.php
Outdated
@@ -487,7 +487,7 @@ public function alterDisplay(&$rows) { | |||
"({$values['percentage']}%)"; | |||
} | |||
$totalAmt = implode(', ', $totalAmount); | |||
$count = (boolean) CRM_Utils_Array::value('count', $values, 0) ? $values['count'] . " ({$values['percentage']}%)" : ''; | |||
$count = (bool) CRM_Utils_Array::value('count', $values, 0) ? $values['count'] . " ({$values['percentage']}%)" : ''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow this line gets a 🏆 for unnecessary complexity. I had to read it 3 times before realizing that the (bool)
cast isn't affecting the assignment and $count
is actually being assigned a string value here, not a bool.
How about:
$count = (bool) CRM_Utils_Array::value('count', $values, 0) ? $values['count'] . " ({$values['percentage']}%)" : ''; | |
$count = !empty($values['count']) ? $values['count'] . " ({$values['percentage']}%)" : ''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right. I read it another 3 times and then rearranged it slightly to reverse the polarity (which always works) and remove the string concatenation.
Much better 🥇 |
Use bool instead of boolean as per standard.
Simplify complicated expression.