Skip to content
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

Merged
merged 1 commit into from
Apr 8, 2020
Merged

Conversation

demeritcowboy
Copy link
Contributor

@demeritcowboy demeritcowboy commented Apr 7, 2020

Use bool instead of boolean as per standard.
Simplify complicated expression.

@civibot
Copy link

civibot bot commented Apr 7, 2020

(Standard links)

@civibot civibot bot added the master label Apr 7, 2020
@@ -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']}%)" : '';
Copy link
Member

@colemanw colemanw Apr 7, 2020

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:

Suggested change
$count = (bool) CRM_Utils_Array::value('count', $values, 0) ? $values['count'] . " ({$values['percentage']}%)" : '';
$count = !empty($values['count']) ? $values['count'] . " ({$values['percentage']}%)" : '';

Copy link
Contributor Author

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.

@demeritcowboy demeritcowboy changed the title [NFC] Use bool instead of boolean [REF] Use bool instead of boolean Apr 7, 2020
@colemanw
Copy link
Member

colemanw commented Apr 7, 2020

Much better 🥇

@seamuslee001 seamuslee001 merged commit 3716b16 into civicrm:master Apr 8, 2020
@demeritcowboy demeritcowboy deleted the boo2 branch April 8, 2020 01:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants