Passed
Pull Request — master (#9)
by Mariusz
02:39
created

Product   A

Complexity

Total Complexity 14

Size/Duplication

Total Lines 152
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 152
rs 10
c 0
b 0
f 0
wmc 14

13 Methods

Rating   Name   Duplication   Size   Complexity  
A isApproved() 0 3 1
A getStore() 0 3 1
A setCategory() 0 3 1
A __construct() 0 5 1
A getName() 0 3 1
A getId() 0 3 1
A setVariants() 0 5 2
A addVariant() 0 3 1
A getCategory() 0 3 1
A setStore() 0 3 1
A getVariants() 0 3 1
A setName() 0 3 1
A setApproved() 0 3 1
1
<?php
2
3
namespace Xsolve\AssociateTests\Functional\DoctrineOrm\Mock\Entity;
4
5
use Doctrine\Common\Collections\ArrayCollection;
6
use Doctrine\Common\Collections\Collection;
7
use Doctrine\ORM\Mapping\Entity;
8
use Doctrine\ORM\Mapping\Table;
9
use Doctrine\ORM\Mapping\Id;
10
use Doctrine\ORM\Mapping\Column;
11
use Doctrine\ORM\Mapping\ManyToOne;
12
use Doctrine\ORM\Mapping\OneToMany;
13
14
/**
15
 * @Entity
16
 * @Table
17
 */
18
class Product
19
{
20
    /**
21
     * @var string
22
     *
23
     * @Id
24
     * @Column(type="string", length=64)
25
     */
26
    protected $id;
27
28
    /**
29
     * @var string
30
     *
31
     * @Column(type="string", length=128)
32
     */
33
    protected $name;
34
35
    /**
36
     * @var bool
37
     *
38
     * @Column(type="boolean")
39
     */
40
    protected $approved;
41
42
    /**
43
     * @var Store
44
     *
45
     * @ManyToOne(targetEntity="Store", inversedBy="products")
46
     */
47
    protected $store;
48
49
    /**
50
     * @var Category
51
     *
52
     * @ManyToOne(targetEntity="Category", inversedBy="products")
53
     */
54
    protected $category;
55
56
    /**
57
     * @var Collection|Variant[]
58
     *
59
     * @OneToMany(targetEntity="Variant", mappedBy="product")
60
     */
61
    protected $variants;
62
63
    /**
64
     * @param string $id
65
     */
66
    public function __construct(string $id)
67
    {
68
        $this->id = $id;
69
70
        $this->variants = new ArrayCollection();
71
    }
72
73
    /**
74
     * @return string
75
     */
76
    public function getId(): string
77
    {
78
        return $this->id;
79
    }
80
81
    /**
82
     * @param string $name
83
     */
84
    public function setName(string $name)
85
    {
86
        $this->name = $name;
87
    }
88
89
    /**
90
     * @return string
91
     */
92
    public function getName(): string
93
    {
94
        return $this->name;
95
    }
96
97
    /**
98
     * @param bool $approved
99
     */
100
    public function setApproved(bool $approved)
101
    {
102
        $this->approved = $approved;
103
    }
104
105
    /**
106
     * @return bool
107
     */
108
    public function isApproved(): bool
109
    {
110
        return $this->approved;
111
    }
112
113
    /**
114
     * @param Store $store
115
     */
116
    public function setStore(Store $store)
117
    {
118
        $this->store = $store;
119
    }
120
121
    /**
122
     * @return Store
123
     */
124
    public function getStore(): Store
125
    {
126
        return $this->store;
127
    }
128
129
    /**
130
     * @param Category $category
131
     */
132
    public function setCategory(Category $category)
133
    {
134
        $this->category = $category;
135
    }
136
137
    /**
138
     * @return Category
139
     */
140
    public function getCategory(): Category
141
    {
142
        return $this->category;
143
    }
144
145
    /**
146
     * @param Variant[] $variants
147
     */
148
    public function setVariants(array $variants)
149
    {
150
        $this->variants->clear();
151
        foreach ($variants as $variant) {
152
            $this->variants->add($variant);
153
        }
154
    }
155
156
    /**
157
     * @param Variant $variant
158
     */
159
    public function addVariant(Variant $variant)
160
    {
161
        $this->variants->add($variant);
162
    }
163
164
    /**
165
     * @return Collection|Variant[]
166
     */
167
    public function getVariants()
168
    {
169
        return $this->variants;
170
    }
171
}
172