diff --git a/app/code/Magento/Quote/Model/Quote/Item/AbstractItem.php b/app/code/Magento/Quote/Model/Quote/Item/AbstractItem.php index 058411abe720b..cb01e38c462c0 100644 --- a/app/code/Magento/Quote/Model/Quote/Item/AbstractItem.php +++ b/app/code/Magento/Quote/Model/Quote/Item/AbstractItem.php @@ -3,10 +3,12 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ + namespace Magento\Quote\Model\Quote\Item; -use Magento\Quote\Model\Quote\Item; +use Magento\Catalog\Model\Product\Configuration\Item\Option\OptionInterface; use Magento\Framework\Api\AttributeValueFactory; +use Magento\Quote\Model\Quote\Item; /** * Quote item abstract model @@ -24,15 +26,15 @@ * @method float getBaseDiscountAmount() * @method \Magento\Quote\Model\Quote\Item\AbstractItem setBaseDiscountAmount(float $amount) * @method float getDiscountPercent() - * @method \Magento\Quote\Model\Quote\Item\AbstractItem setDiscountPercent() + * @method \Magento\Quote\Model\Quote\Item\AbstractItem setDiscountPercent(float $percent) * @method float getOriginalDiscountAmount() - * @method \Magento\Quote\Model\Quote\Item\AbstractItem setOriginalDiscountAmount() + * @method \Magento\Quote\Model\Quote\Item\AbstractItem setOriginalDiscountAmount(float $amount) * @method float getBaseOriginalDiscountAmount() - * @method \Magento\Quote\Model\Quote\Item\AbstractItem setBaseOriginalDiscountAmount() + * @method \Magento\Quote\Model\Quote\Item\AbstractItem setBaseOriginalDiscountAmount(float $amount) * @method float getDiscountCalculationPrice() - * @method \Magento\Quote\Model\Quote\Item\AbstractItem setDiscountCalculationPrice() + * @method \Magento\Quote\Model\Quote\Item\AbstractItem setDiscountCalculationPrice(float $amount) * @method float getBaseDiscountCalculationPrice() - * @method \Magento\Quote\Model\Quote\Item\AbstractItem setBaseDiscountCalculationPrice($price) + * @method \Magento\Quote\Model\Quote\Item\AbstractItem setBaseDiscountCalculationPrice(float $price) * @method int[] getAppliedRuleIds() * @method \Magento\Quote\Model\Quote\Item\AbstractItem setAppliedRuleIds(array $ruleIds) * @method float getBaseTaxAmount() @@ -47,8 +49,8 @@ * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @since 100.0.2 */ -abstract class AbstractItem extends \Magento\Framework\Model\AbstractExtensibleModel implements - \Magento\Catalog\Model\Product\Configuration\Item\ItemInterface +abstract class AbstractItem extends \Magento\Framework\Model\AbstractExtensibleModel + implements \Magento\Catalog\Model\Product\Configuration\Item\ItemInterface { /** * @var Item|null @@ -68,7 +70,7 @@ abstract class AbstractItem extends \Magento\Framework\Model\AbstractExtensibleM /** * List of custom options * - * @var array + * @var OptionInterface[] */ protected $_optionsByCode; @@ -187,7 +189,7 @@ public function beforeSave() /** * Set parent item * - * @param Item $parentItem + * @param Item $parentItem * @return $this */ public function setParentItem($parentItem) @@ -222,7 +224,7 @@ public function getChildren() /** * Add child item * - * @param \Magento\Quote\Model\Quote\Item\AbstractItem $child + * @param \Magento\Quote\Model\Quote\Item\AbstractItem $child * @return $this */ public function addChild($child) @@ -235,7 +237,7 @@ public function addChild($child) /** * Adds message(s) for quote item. Duplicated messages are not added. * - * @param mixed $messages + * @param mixed $messages * @return $this */ public function setMessage($messages) @@ -255,7 +257,7 @@ public function setMessage($messages) /** * Add message of quote item to array of messages * - * @param string $message + * @param string $message * @return $this */ public function addMessage($message) @@ -267,7 +269,7 @@ public function addMessage($message) /** * Get messages array of quote item * - * @param bool $string flag for converting messages to string + * @param bool $string flag for converting messages to string * @return array|string */ public function getMessage($string = true) @@ -624,18 +626,12 @@ public function __clone() */ public function isChildrenCalculated() { - if ($this->getParentItem()) { - $calculate = $this->getParentItem()->getProduct()->getPriceType(); - } else { - $calculate = $this->getProduct()->getPriceType(); - } + $calculate = $this->getParentItem() + ? $this->getParentItem()->getProduct()->getPriceType() + : $this->getProduct()->getPriceType(); - if (null !== $calculate && - (int)$calculate === \Magento\Catalog\Model\Product\Type\AbstractType::CALCULATE_CHILD - ) { - return true; - } - return false; + return $calculate !== null + && (int)$calculate === \Magento\Catalog\Model\Product\Type\AbstractType::CALCULATE_CHILD; } /** @@ -648,18 +644,12 @@ public function isChildrenCalculated() */ public function isShipSeparately() { - if ($this->getParentItem()) { - $shipmentType = $this->getParentItem()->getProduct()->getShipmentType(); - } else { - $shipmentType = $this->getProduct()->getShipmentType(); - } + $shipmentType = $this->getParentItem() + ? $this->getParentItem()->getProduct()->getShipmentType() + : $this->getProduct()->getShipmentType(); - if (null !== $shipmentType && - (int)$shipmentType === \Magento\Catalog\Model\Product\Type\AbstractType::SHIPMENT_SEPARATELY - ) { - return true; - } - return false; + return null !== $shipmentType && + (int)$shipmentType === \Magento\Catalog\Model\Product\Type\AbstractType::SHIPMENT_SEPARATELY; } /**