Skip to content

Commit

Permalink
Improve code structure in relation to else / if statements.
Browse files Browse the repository at this point in the history
  • Loading branch information
nuzil committed Apr 6, 2018
1 parent d76b6c1 commit 4cf7e8b
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,8 @@ public function getPopupTitle()
$messageCount = count($this->_messages->getUnread());
if ($messageCount > 1) {
return __('You have %1 new system messages', $messageCount);
} else {
return __('You have %1 new system message', $messageCount);
}
return __('You have %1 new system message', $messageCount);
}

/**
Expand Down
3 changes: 1 addition & 2 deletions app/code/Magento/AdminNotification/Block/Window.php
Original file line number Diff line number Diff line change
Expand Up @@ -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];
} else {
$this->_latestItem = false;
}
}
return $this->_latestItem;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -626,9 +626,8 @@ protected function _getCustomerGroupById(
): string {
if ($allGroups !== 0) {
return ImportAdvancedPricing::VALUE_ALL_GROUPS;
} else {
return $this->_groupRepository->getById($groupId)->getCode();
}
return $this->_groupRepository->getById($groupId)->getCode();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -482,9 +482,8 @@ protected function deleteProductTierPrices(array $listSku, $table)
$this->addRowError(ValidatorInterface::ERROR_SKU_IS_EMPTY, 0);
return false;
}
} else {
return false;
}
return false;
}

/**
Expand Down
7 changes: 1 addition & 6 deletions app/code/Magento/Analytics/Model/Config/Backend/Enabled.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,7 @@ public function afterSave()
try {
if ($this->isValueChanged()) {
$enabled = $this->getData('value');

if ($enabled) {
$this->subscriptionHandler->processEnabled();
} else {
$this->subscriptionHandler->processDisabled();
}
$enabled ? $this->subscriptionHandler->processEnabled() : $this->subscriptionHandler->processDisabled();
}
} catch (\Exception $e) {
$this->_logger->error($e->getMessage());
Expand Down
3 changes: 1 addition & 2 deletions app/code/Magento/Authorization/Model/ResourceModel/Role.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ protected function _beforeSave(\Magento\Framework\Model\AbstractModel $role)
}

if (!$role->getTreeLevel()) {
$treeLevel = 0;
if ($role->getPid() > 0) {
$select = $this->getConnection()->select()->from(
$this->getMainTable(),
Expand All @@ -79,8 +80,6 @@ protected function _beforeSave(\Magento\Framework\Model\AbstractModel $role)
$binds = ['pid' => (int)$role->getPid()];

$treeLevel = $this->getConnection()->fetchOne($select, $binds);
} else {
$treeLevel = 0;
}

$role->setTreeLevel($treeLevel + 1);
Expand Down

0 comments on commit 4cf7e8b

Please sign in to comment.