Completed
Pull Request — master (#27)
by
unknown
05:26
created

ProductBundle::setName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace solutionDrive\SyliusProductBundlesPlugin\Entity;
6
7
use Doctrine\Common\Collections\ArrayCollection;
8
use Doctrine\Common\Collections\Collection;
9
use Sylius\Component\Core\Model\ProductInterface;
10
11
class ProductBundle implements ProductBundleInterface
12
{
13
    /** @var int */
14
    private $id;
15
16
    /** @var ProductBundleSlotInterface[]|Collection|ArrayCollection */
17
    private $slots;
18
19
    /** @var ProductBundleSlotInterface|null */
20
    private $presentationSlot;
21
22
    /** @var ProductInterface|null */
23
    private $product;
24
25
    /**
26
     * ProductBundle constructor.
27
     */
28
    public function __construct()
29
    {
30
        $this->slots = new ArrayCollection();
31
    }
32
33
    /**
34
     * @return int
35
     */
36
    public function getId(): ?int
37
    {
38
        return $this->id;
39
    }
40
41
    /**
42
     * @param ProductBundleSlotInterface $slot
43
     */
44
    public function addSlot(ProductBundleSlotInterface $slot): void
45
    {
46
        $this->slots->add($slot);
47
    }
48
49
    /**
50
     * @return ProductBundleSlotInterface[]|Collection|ArrayCollection
51
     */
52
    public function getSlots(): Collection
53
    {
54
        return $this->slots;
55
    }
56
57
    /**
58
     * @return ProductInterface
59
     */
60
    public function getProduct(): ?ProductInterface
61
    {
62
        return $this->product;
63
    }
64
65
    /**
66
     * @param ProductInterface $product
67
     */
68
    public function setProduct(ProductInterface $product): void
69
    {
70
        $this->product = $product;
71
    }
72
73
    public function getProductId(): ?int
74
    {
75
        if (null === $this->product) {
76
            return null;
77
        }
78
79
        return $this->product->getId();
80
    }
81
82
    public function setPresentationSlot(ProductBundleSlotInterface $slot): void
83
    {
84
        $this->presentationSlot = $slot;
85
    }
86
87
    public function getPresentationSlot(): ?ProductBundleSlotInterface
88
    {
89
        return $this->presentationSlot;
90
    }
91
}
92