Completed
Push — symfony3 ( 06e2ee...17e915 )
by Kamil
46:11 queued 26:57
created

LimitingOrderItemQuantityModifier::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 2
1
<?php
2
3
/*
4
 * This file is part of the Sylius package.
5
 *
6
 * (c) Paweł Jędrzejewski
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Sylius\Component\Core\Cart\Modifier;
13
14
use Sylius\Component\Order\Model\OrderItemInterface;
15
use Sylius\Component\Order\Modifier\OrderItemQuantityModifierInterface;
16
17
/**
18
 * @author Jan Góralski <[email protected]>
19
 */
20
final class LimitingOrderItemQuantityModifier implements OrderItemQuantityModifierInterface
21
{
22
    /**
23
     * @var OrderItemQuantityModifierInterface
24
     */
25
    private $decoratedOrderItemQuantityModifier;
26
27
    /**
28
     * @var int
29
     */
30
    private $limit;
31
32
    /**
33
     * @param OrderItemQuantityModifierInterface $decoratedOrderItemQuantityModifier
34
     * @param int $limit
35
     */
36
    public function __construct(OrderItemQuantityModifierInterface $decoratedOrderItemQuantityModifier, $limit)
0 ignored issues
show
Comprehensibility Naming introduced by
The variable name $decoratedOrderItemQuantityModifier exceeds the maximum configured length of 20.

Very long variable names usually make code harder to read. It is therefore recommended not to make variable names too verbose.

Loading history...
37
    {
38
        $this->decoratedOrderItemQuantityModifier = $decoratedOrderItemQuantityModifier;
39
        $this->limit = $limit;
40
    }
41
42
    /**
43
     * {@inheritdoc}
44
     */
45
    public function modify(OrderItemInterface $orderItem, $targetQuantity)
46
    {
47
        $targetQuantity = min($targetQuantity, $this->limit);
48
49
        $this->decoratedOrderItemQuantityModifier->modify($orderItem, $targetQuantity);
50
    }
51
}
52