Passed
Push — master ( 2deebc...75575e )
by Luiz Kim
05:11 queued 02:56
created

Product::getParentProduct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace ControleOnline\Entity;
4
5
use Doctrine\ORM\Mapping as ORM;
0 ignored issues
show
Bug introduced by
The type Doctrine\ORM\Mapping was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use ControleOnline\Entity\People;
0 ignored issues
show
Bug introduced by
The type ControleOnline\Entity\People was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
use ControleOnline\Entity\ProductUnity;
8
use Symfony\Component\Serializer\Annotation\Groups;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Serializer\Annotation\Groups was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
use ApiPlatform\Metadata\GetCollection;
0 ignored issues
show
Bug introduced by
The type ApiPlatform\Metadata\GetCollection was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
10
use ApiPlatform\Metadata\Post;
0 ignored issues
show
Bug introduced by
The type ApiPlatform\Metadata\Post was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
use ApiPlatform\Metadata\Delete;
0 ignored issues
show
Bug introduced by
The type ApiPlatform\Metadata\Delete was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
12
use ApiPlatform\Metadata\Put;
0 ignored issues
show
Bug introduced by
The type ApiPlatform\Metadata\Put was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
13
use ApiPlatform\Metadata\Get;
0 ignored issues
show
Bug introduced by
The type ApiPlatform\Metadata\Get was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
14
use ApiPlatform\Metadata\ApiResource;
0 ignored issues
show
Bug introduced by
The type ApiPlatform\Metadata\ApiResource was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
15
use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
0 ignored issues
show
Bug introduced by
The type ApiPlatform\Doctrine\Orm\Filter\SearchFilter was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
16
use ApiPlatform\Doctrine\Orm\Filter\ExistsFilter;
0 ignored issues
show
Bug introduced by
The type ApiPlatform\Doctrine\Orm\Filter\ExistsFilter was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
17
use ApiPlatform\Metadata\ApiFilter;
0 ignored issues
show
Bug introduced by
The type ApiPlatform\Metadata\ApiFilter was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
18
use Doctrine\Common\Collections\Collection;
0 ignored issues
show
Bug introduced by
The type Doctrine\Common\Collections\Collection was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
19
use ApiPlatform\Doctrine\Orm\Filter\OrderFilter;
0 ignored issues
show
Bug introduced by
The type ApiPlatform\Doctrine\Orm\Filter\OrderFilter was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
20
use ControleOnline\Filter\RandomOrderFilter;
0 ignored issues
show
Bug introduced by
The type ControleOnline\Filter\RandomOrderFilter was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
21
22
/**
23
 * Product
24
 *
25
 * @ORM\Table(name="product", uniqueConstraints={@ORM\UniqueConstraint(name="company_id", columns={"company_id", "sku"})}, indexes={@ORM\Index(name="product_unit_id", columns={"product_unit_id"}), @ORM\Index(name="IDX_D34A04AD979B1AD6", columns={"company_id"})})
26
 * @ORM\Entity(repositoryClass="ControleOnline\Repository\ProductRepository")
27
 */
28
#[ApiResource(
29
    operations: [
30
        new Get(security: 'is_granted(\'IS_AUTHENTICATED_ANONYMOUSLY\')'),
31
        new Put(security: 'is_granted(\'ROLE_CLIENT\')', denormalizationContext: ['groups' => ['product:write']]),
32
        new Delete(security: 'is_granted(\'ROLE_CLIENT\')'),
33
        new Post(securityPostDenormalize: 'is_granted(\'ROLE_CLIENT\')'),
34
        new GetCollection(security: 'is_granted(\'IS_AUTHENTICATED_ANONYMOUSLY\')'),
35
    ],
36
    formats: ['jsonld', 'json', 'html', 'jsonhal', 'csv' => ['text/csv']],
37
    normalizationContext: ['groups' => ['product:read']],
38
    denormalizationContext: ['groups' => ['product:write']]
39
)]
40
#[ApiFilter(OrderFilter::class, properties: ['id' => 'ASC', 'product' => 'ASC', 'price' => 'DESC'])]
41
#[ApiFilter(RandomOrderFilter::class)]
42
class Product
43
{
44
    /**
45
     * @var int
46
     * @ORM\Column(name="id", type="integer", nullable=false)
47
     * @ORM\Id
48
     * @ORM\GeneratedValue(strategy="IDENTITY")
49
     * @Groups({"product_category:read","product:read","order_product:read"})
50
     */
51
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['id' => 'exact'])]
52
    private $id;
53
54
    /**
55
     * @var string
56
     * @ORM\Column(name="product", type="string", length=255, nullable=false)
57
     * @Groups({"product_category:read","product:read","product_group_product:read","order_product:read","order_product_queue:read","order:read","order_details:read","order:write","product:write"})
58
     */
59
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['product' => 'partial'])]
60
    private $product;
61
62
    /**
63
     * @ORM\OneToMany(targetEntity="ProductFile", mappedBy="product")
64
     * @Groups({"product:read","product_category:read"})
65
     */
66
    #[ApiFilter(filterClass: ExistsFilter::class, properties: ['productFiles'])]
67
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['productFiles.file.fileType' => 'exact'])]
68
    private $productFiles;
69
70
    /**
71
     * @ORM\OneToMany(targetEntity="ProductCategory", mappedBy="product")
72
     */
73
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['productCategory.category' => 'exact'])]
74
    private $productCategory;
75
76
    /**
77
     * @var string|null
78
     * @ORM\Column(name="sku", type="string", length=32, nullable=true, options={"default"="NULL"})
79
     * @Groups({"product_category:read","product:read","product_group_product:read","order_product:read","order_product_queue:read","order:read","order_details:read","order:write","product:write"})
80
     */
81
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['sku' => 'partial'])]
82
    private $sku = null;
83
84
    /**
85
     * @var string
86
     * @ORM\Column(name="type", type="string", length=0, nullable=false, options={"default"="'product'"})
87
     * @Groups({"product_category:read","product:read","product_group_product:read","order_product:read","order_product_queue:read","order:read","order_details:read","order:write","product:write"})
88
     */
89
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['type' => 'exact'])]
90
    private $type = 'product';
91
92
    /**
93
     * @var float
94
     * @ORM\Column(name="price", type="float", precision=10, scale=0, nullable=false)
95
     * @Groups({"product_category:read","product:read","product_group_product:read","order_product:read","order_product_queue:read","order:read","order_details:read","order:write","product:write"})
96
     */
97
    private $price = 0;
98
99
    /**
100
     * @var string
101
     * @ORM\Column(name="product_condition", type="string", length=0, nullable=false, options={"default"="'new'"})
102
     * @Groups({"product_category:read","product:read","product_group_product:read","order_product:read","order_product_queue:read","order:read","order_details:read","order:write","product:write"})
103
     */
104
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['productCondition' => 'exact'])]
105
    private $productCondition = 'new';
106
107
    /**
108
     * @var string
109
     * @ORM\Column(name="description", type="string", length=0, nullable=false)
110
     * @Groups({"product_category:read","product:read","product_group_product:read","order_product:read","order_product_queue:read","order:read","order_details:read","order:write","product:write"})
111
     */
112
    private $description = '';
113
114
    /**
115
     * @var bool
116
     * @ORM\Column(name="featured", type="boolean", nullable=false, options={"default"="0"})
117
     * @Groups({"product_category:read","product:read","product_group_product:read","order_product:read","order_product_queue:read","order:read","order_details:read","order:write","product:write"})
118
     */
119
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['featured' => 'exact'])]
120
    private $featured = false;
121
122
    /**
123
     * @var bool
124
     * @ORM\Column(name="active", type="boolean", nullable=false, options={"default"="1"})
125
     * @Groups({"product_category:read","product:read","product_group_product:read","order_product:read","order_product_queue:read","order:read","order_details:read","order:write","product:write"})
126
     */
127
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['active' => 'exact'])]
128
    private $active = true;
129
130
    /**
131
     * @var \ControleOnline\Entity\People
132
     * @ORM\ManyToOne(targetEntity="\ControleOnline\Entity\People")
133
     * @ORM\JoinColumns({
134
     *   @ORM\JoinColumn(name="company_id", referencedColumnName="id")
135
     * })
136
     * @Groups({"product_category:read","product:read","product_group_product:read","order_product:read","order_product_queue:read","order:read","order_details:read","order:write","product:write"})
137
     */
138
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['company' => 'exact'])]
139
    private $company;
140
141
    /**
142
     * @var ProductUnity
143
     * @ORM\ManyToOne(targetEntity="ProductUnity")
144
     * @ORM\JoinColumns({
145
     *   @ORM\JoinColumn(name="product_unit_id", referencedColumnName="id")
146
     * })
147
     * @Groups({"product_category:read","product:read","product_group_product:read","order_product:read","order_product_queue:read","order:read","order_details:read","order:write","product:write"})
148
     */
149
    private $productUnit;
150
151
    /**
152
     * @var Queue
0 ignored issues
show
Bug introduced by
The type ControleOnline\Entity\Queue was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
153
     * @ORM\ManyToOne(targetEntity="Queue")
154
     * @ORM\JoinColumns({
155
     *   @ORM\JoinColumn(name="queue_id", referencedColumnName="id")
156
     * })
157
     * @Groups({"product_category:read","product:read","product_group_product:read","order_product:read","order_product_queue:read","order:read","order_details:read","order:write","product:write"})
158
     */
159
    private $queue;
160
161
    /**
162
     * @var Collection|Product[]
163
     * @ORM\OneToMany(targetEntity="Product", mappedBy="parentProduct")
164
     * @Groups({"product_group_product:read"})
165
     */
166
    private $childProducts;
167
168
169
170
    public function __construct()
171
    {
172
        $this->productFiles = new \Doctrine\Common\Collections\ArrayCollection();
0 ignored issues
show
Bug introduced by
The type Doctrine\Common\Collections\ArrayCollection was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
173
        $this->productCategory = new \Doctrine\Common\Collections\ArrayCollection();
174
        $this->childProducts = new \Doctrine\Common\Collections\ArrayCollection();
175
    }
176
177
    public function getId(): int
178
    {
179
        return $this->id;
180
    }
181
182
    public function setId(int $id): self
183
    {
184
        $this->id = $id;
185
        return $this;
186
    }
187
188
    public function getProduct(): string
189
    {
190
        return $this->product;
191
    }
192
193
    public function setProduct(string $product): self
194
    {
195
        $this->product = $product;
196
        return $this;
197
    }
198
199
    public function getSku(): ?string
200
    {
201
        return $this->sku;
202
    }
203
204
    public function setSku(?string $sku): self
205
    {
206
        $this->sku = $sku;
207
        return $this;
208
    }
209
210
    public function getType(): string
211
    {
212
        return $this->type;
213
    }
214
215
    public function setType(string $type): self
216
    {
217
        $this->type = $type;
218
        return $this;
219
    }
220
221
    public function getPrice(): float
222
    {
223
        return $this->price;
224
    }
225
226
    public function setPrice(float $price): self
227
    {
228
        $this->price = $price;
229
        return $this;
230
    }
231
232
    public function getProductCondition(): string
233
    {
234
        return $this->productCondition;
235
    }
236
237
    public function setProductCondition(string $productCondition): self
238
    {
239
        $this->productCondition = $productCondition;
240
        return $this;
241
    }
242
243
    public function isActive(): bool
244
    {
245
        return $this->active;
246
    }
247
248
    public function setActive(bool $active): self
249
    {
250
        $this->active = $active;
251
        return $this;
252
    }
253
254
    public function getCompany(): ?People
255
    {
256
        return $this->company;
257
    }
258
259
    public function setCompany(People $company): self
260
    {
261
        $this->company = $company;
262
        return $this;
263
    }
264
265
    public function getProductUnit(): ProductUnity
266
    {
267
        return $this->productUnit;
268
    }
269
270
    public function setProductUnit(ProductUnity $productUnit): self
271
    {
272
        $this->productUnit = $productUnit;
273
        return $this;
274
    }
275
276
    public function getDescription(): string
277
    {
278
        return $this->description;
279
    }
280
281
    public function setDescription(string $description): self
282
    {
283
        $this->description = $description;
284
        return $this;
285
    }
286
287
    public function getQueue()
288
    {
289
        return $this->queue;
290
    }
291
292
    public function setQueue($queue): self
293
    {
294
        $this->queue = $queue;
295
        return $this;
296
    }
297
298
    public function getProductFiles(): Collection
299
    {
300
        return $this->productFiles;
301
    }
302
303
    public function getProductCategory(): Collection
304
    {
305
        return $this->productCategory;
306
    }
307
308
    public function getFeatured(): bool
309
    {
310
        return $this->featured;
311
    }
312
313
    public function setFeatured(bool $featured): self
314
    {
315
        $this->featured = $featured;
316
        return $this;
317
    }
318
319
    public function getChildProducts(): Collection
320
    {
321
        return $this->childProducts;
322
    }
323
324
    public function addChildProduct(Product $childProduct): self
325
    {
326
327
        $this->childProducts->add($childProduct);
328
        return $this;
329
    }
330
331
    public function removeChildProduct(Product $childProduct): self
332
    {
333
        $this->childProducts->removeElement($childProduct);
334
        return $this;
335
    }
336
}
337