Skip to content

Commit

Permalink
Minor Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
lbajsarowicz committed Aug 18, 2020
1 parent 4930963 commit 4b0fdfc
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions app/code/Magento/Quote/Model/ChangeQuoteControl.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

declare(strict_types=1);

namespace Magento\Quote\Model;
Expand All @@ -12,13 +11,10 @@
use Magento\Quote\Api\ChangeQuoteControlInterface;
use Magento\Quote\Api\Data\CartInterface;

/**
* {@inheritdoc}
*/
class ChangeQuoteControl implements ChangeQuoteControlInterface
{
/**
* @var UserContextInterface $userContext
* @var UserContextInterface
*/
private $userContext;

Expand All @@ -31,25 +27,20 @@ public function __construct(UserContextInterface $userContext)
}

/**
* {@inheritdoc}
* @inheritdoc
*/
public function isAllowed(CartInterface $quote): bool
{
switch ($this->userContext->getUserType()) {
case UserContextInterface::USER_TYPE_CUSTOMER:
$isAllowed = ($quote->getCustomerId() == $this->userContext->getUserId());
break;
return ($quote->getCustomerId() == $this->userContext->getUserId());
case UserContextInterface::USER_TYPE_GUEST:
$isAllowed = ($quote->getCustomerId() === null);
break;
return ($quote->getCustomerId() === null);
case UserContextInterface::USER_TYPE_ADMIN:
case UserContextInterface::USER_TYPE_INTEGRATION:
$isAllowed = true;
break;
default:
$isAllowed = false;
return true;
}

return $isAllowed;
return false;
}
}

0 comments on commit 4b0fdfc

Please sign in to comment.