-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Improve code structure in relation to else / if statements. #14576
Improve code structure in relation to else / if statements. #14576
Conversation
@@ -98,10 +98,9 @@ protected function _getLatestItem() | |||
{ | |||
if ($this->_latestItem == null) { | |||
$items = array_values($this->_criticalCollection->getItems()); | |||
$this->_latestItem = false; | |||
if (count($items)) { | |||
$this->_latestItem = $items[0]; |
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.
Ternary operator would fit better here.
} | ||
return $this->_groupRepository->getById($groupId)->getCode(); |
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.
Ternary operator would fit better here.
} else { | ||
$this->subscriptionHandler->processDisabled(); | ||
} | ||
$enabled ? $this->subscriptionHandler->processEnabled() : $this->subscriptionHandler->processDisabled(); |
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.
Ternary operator is NOT really suitable here as it decreases code readability. it is better to be used in assignments only.
Hi @nuzil. Thank you for your contribution. |
Description
This PR improves code structure for usage of if / else statements
Fixed Issues (if relevant)
No, code improvements
Manual testing scenarios
No, code improvements
Contribution checklist