for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Sylius\Component\Core\Cart\Modifier;
use Sylius\Component\Order\Model\OrderItemInterface;
use Sylius\Component\Order\Modifier\OrderItemQuantityModifierInterface;
/**
* @author Jan Góralski <[email protected]>
final class LimitingOrderItemQuantityModifier implements OrderItemQuantityModifierInterface
{
* @var OrderItemQuantityModifierInterface
private $decoratedOrderItemQuantityModifier;
* @var int
private $limit;
* @param OrderItemQuantityModifierInterface $decoratedOrderItemQuantityModifier
* @param int $limit
public function __construct(OrderItemQuantityModifierInterface $decoratedOrderItemQuantityModifier, $limit)
$decoratedOrderItemQuantityModifier
20
Very long variable names usually make code harder to read. It is therefore recommended not to make variable names too verbose.
$this->decoratedOrderItemQuantityModifier = $decoratedOrderItemQuantityModifier;
$this->limit = $limit;
}
* {@inheritdoc}
public function modify(OrderItemInterface $orderItem, $targetQuantity)
$targetQuantity = min($targetQuantity, $this->limit);
$this->decoratedOrderItemQuantityModifier->modify($orderItem, $targetQuantity);
Very long variable names usually make code harder to read. It is therefore recommended not to make variable names too verbose.