Completed
Push — master ( 71b70e...42cf72 )
by Kamil
19:08
created

OrderItem::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 6
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
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\Model;
13
14
use Sylius\Component\Cart\Model\CartItem;
15
use Sylius\Component\Order\Model\OrderItemInterface as BaseOrderItemInterface;
16
17
/**
18
 * @author Paweł Jędrzejewski <[email protected]>
19
 */
20
class OrderItem extends CartItem implements OrderItemInterface
21
{
22
    /**
23
     * @var ProductVariantInterface
24
     */
25
    protected $variant;
26
27
    /**
28
     * {@inheritdoc}
29
     */
30
    public function getProduct()
31
    {
32
        return $this->variant->getProduct();
33
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38
    public function getVariant()
39
    {
40
        return $this->variant;
41
    }
42
43
    /**
44
     * {@inheritdoc}
45
     */
46
    public function setVariant(ProductVariantInterface $variant)
47
    {
48
        $this->variant = $variant;
49
    }
50
51
    /**
52
     * {@inheritdoc}
53
     */
54
    public function equals(BaseOrderItemInterface $item)
55
    {
56
        return parent::equals($item) || ($item instanceof self
57
            && $item->getVariant() === $this->variant
58
        );
59
    }
60
}
61