Passed
Push — master ( c58f02...0be31e )
by Luiz Kim
04:37 queued 02:15
created

Product::getDefaultOutInventory()   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
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
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 ControleOnline\Entity\Inventory;
9
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...
10
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...
11
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...
12
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...
13
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...
14
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...
15
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...
16
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...
17
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...
18
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...
19
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...
20
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...
21
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...
22
23
/**
24
 * Product
25
 *
26
 * @ORM\Table(name="product", uniqueConstraints={@ORM\UniqueConstraint(name="company_id", columns={"company_id", "sku"})}, indexes={@ORM\Index(name="product_unity_id", columns={"product_unity_id"}), @ORM\Index(name="IDX_D34A04AD979B1AD6", columns={"company_id"}), @ORM\Index(name="default_out_inventory_id", columns={"default_out_inventory_id"}), @ORM\Index(name="default_in_inventory_id", columns={"default_in_inventory_id"})})
27
 * @ORM\Entity(repositoryClass="ControleOnline\Repository\ProductRepository")
28
 */
29
#[ApiResource(
30
    operations: [
31
        new Get(security: 'is_granted(\'IS_AUTHENTICATED_ANONYMOUSLY\')'),
32
        new Put(security: 'is_granted(\'ROLE_CLIENT\')', denormalizationContext: ['groups' => ['product:write']]),
33
        new Delete(security: 'is_granted(\'ROLE_CLIENT\')'),
34
        new Post(securityPostDenormalize: 'is_granted(\'ROLE_CLIENT\')'),
35
        new GetCollection(security: 'is_granted(\'IS_AUTHENTICATED_ANONYMOUSLY\')'),
36
    ],
37
    formats: ['jsonld', 'json', 'html', 'jsonhal', 'csv' => ['text/csv']],
38
    normalizationContext: ['groups' => ['product:read']],
39
    denormalizationContext: ['groups' => ['product:write']]
40
)]
41
#[ApiFilter(OrderFilter::class, properties: ['product', 'price', 'description'])]
42
#[ApiFilter(RandomOrderFilter::class)]
43
class Product
44
{
45
    /**
46
     * @var int
47
     * @ORM\Column(name="id", type="integer", nullable=false)
48
     * @ORM\Id
49
     * @ORM\GeneratedValue(strategy="IDENTITY")
50
     * @Groups({"product_category:read","product:read","order_product:read"})
51
     */
52
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['id' => 'exact'])]
53
    private $id;
54
55
    /**
56
     * @var string
57
     * @ORM\Column(name="product", type="string", length=255, nullable=false)
58
     * @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"})
59
     */
60
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['product' => 'partial'])]
61
    private $product;
62
63
    /**
64
     * @ORM\OneToMany(targetEntity="ProductFile", mappedBy="product")
65
     * @Groups({"product:read","product_category:read","order_product:read"})
66
     */
67
    #[ApiFilter(filterClass: ExistsFilter::class, properties: ['productFiles'])]
68
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['productFiles.file.fileType' => 'exact'])]
69
    private $productFiles;
70
71
    /**
72
     * @ORM\OneToMany(targetEntity="ProductCategory", mappedBy="product")
73
     */
74
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['productCategory.category' => 'exact'])]
75
    private $productCategory;
76
77
    /**
78
     * @var string|null
79
     * @ORM\Column(name="sku", type="string", length=32, nullable=true, options={"default"="NULL"})
80
     * @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"})
81
     */
82
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['sku' => 'partial'])]
83
    private $sku = null;
84
85
    /**
86
     * @var string
87
     * @ORM\Column(name="type", type="string", length=0, nullable=false, options={"default"="'product'"})
88
     * @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"})
89
     */
90
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['type' => 'exact'])]
91
    private $type = 'product';
92
93
    /**
94
     * @var float
95
     * @ORM\Column(name="price", type="float", precision=10, scale=0, nullable=false)
96
     * @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"})
97
     */
98
    private $price = 0;
99
100
    /**
101
     * @var string
102
     * @ORM\Column(name="product_condition", type="string", length=0, nullable=false, options={"default"="'new'"})
103
     * @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"})
104
     */
105
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['productCondition' => 'exact'])]
106
    private $productCondition = 'new';
107
108
    /**
109
     * @var string
110
     * @ORM\Column(name="description", type="string", length=0, nullable=false)
111
     * @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"})
112
     */
113
    private $description = '';
114
115
    /**
116
     * @var bool
117
     * @ORM\Column(name="featured", type="boolean", nullable=false, options={"default"="0"})
118
     * @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"})
119
     */
120
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['featured' => 'exact'])]
121
    private $featured = false;
122
123
    /**
124
     * @var bool
125
     * @ORM\Column(name="active", type="boolean", nullable=false, options={"default"="1"})
126
     * @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"})
127
     */
128
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['active' => 'exact'])]
129
    private $active = true;
130
131
    /**
132
     * @var \ControleOnline\Entity\People
133
     * @ORM\ManyToOne(targetEntity="\ControleOnline\Entity\People")
134
     * @ORM\JoinColumns({
135
     *   @ORM\JoinColumn(name="company_id", referencedColumnName="id")
136
     * })
137
     * @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"})
138
     */
139
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['company' => 'exact'])]
140
    private $company;
141
142
    /**
143
     * @var ProductUnity
144
     * @ORM\ManyToOne(targetEntity="ProductUnity")
145
     * @ORM\JoinColumns({
146
     *   @ORM\JoinColumn(name="product_unity_id", referencedColumnName="id")
147
     * })
148
     * @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"})
149
     */
150
    private $productUnit;
151
152
    /**
153
     * @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...
154
     * @ORM\ManyToOne(targetEntity="Queue")
155
     * @ORM\JoinColumns({
156
     *   @ORM\JoinColumn(name="queue_id", referencedColumnName="id")
157
     * })
158
     * @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"})
159
     */
160
    private $queue;
161
162
    /**
163
     * @var \ControleOnline\Entity\Inventory
164
     * @ORM\ManyToOne(targetEntity="\ControleOnline\Entity\Inventory")
165
     * @ORM\JoinColumns({
166
     *   @ORM\JoinColumn(name="default_out_inventory_id", referencedColumnName="id", nullable=false)
167
     * })
168
     * @Groups({"product:read", "product:write"})
169
     */
170
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['defaultOutInventory' => 'exact'])]
171
    private $defaultOutInventory;
172
173
    /**
174
     * @var \ControleOnline\Entity\Inventory
175
     * @ORM\ManyToOne(targetEntity="\ControleOnline\Entity\Inventory")
176
     * @ORM\JoinColumns({
177
     *   @ORM\JoinColumn(name="default_in_inventory_id", referencedColumnName="id", nullable=false)
178
     * })
179
     * @Groups({"product:read", "product:write"})
180
     */
181
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['defaultInInventory' => 'exact'])]
182
    private $defaultInInventory;
183
184
    public function __construct()
185
    {
186
        $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...
187
        $this->productCategory = new \Doctrine\Common\Collections\ArrayCollection();
188
    }
189
190
    public function getId()
191
    {
192
        return $this->id;
193
    }
194
195
    public function setId($id): self
196
    {
197
        $this->id = $id;
198
        return $this;
199
    }
200
201
    public function getProduct(): string
202
    {
203
        return $this->product;
204
    }
205
206
    public function setProduct(string $product): self
207
    {
208
        $this->product = $product;
209
        return $this;
210
    }
211
212
    public function getSku(): ?string
213
    {
214
        return $this->sku;
215
    }
216
217
    public function setSku(?string $sku): self
218
    {
219
        $this->sku = $sku;
220
        return $this;
221
    }
222
223
    public function getType(): string
224
    {
225
        return $this->type;
226
    }
227
228
    public function setType(string $type): self
229
    {
230
        $this->type = $type;
231
        return $this;
232
    }
233
234
    public function getPrice(): float
235
    {
236
        return $this->price;
237
    }
238
239
    public function setPrice(float $price): self
240
    {
241
        $this->price = $price;
242
        return $this;
243
    }
244
245
    public function getProductCondition(): string
246
    {
247
        return $this->productCondition;
248
    }
249
250
    public function setProductCondition(string $productCondition): self
251
    {
252
        $this->productCondition = $productCondition;
253
        return $this;
254
    }
255
256
    public function isActive(): bool
257
    {
258
        return $this->active;
259
    }
260
261
    public function setActive(bool $active): self
262
    {
263
        $this->active = $active;
264
        return $this;
265
    }
266
267
    public function getCompany(): ?People
268
    {
269
        return $this->company;
270
    }
271
272
    public function setCompany(People $company): self
273
    {
274
        $this->company = $company;
275
        return $this;
276
    }
277
278
    public function getProductUnit(): ProductUnity
279
    {
280
        return $this->productUnit;
281
    }
282
283
    public function setProductUnit(ProductUnity $productUnit): self
284
    {
285
        $this->productUnit = $productUnit;
286
        return $this;
287
    }
288
289
    public function getDescription(): string
290
    {
291
        return $this->description;
292
    }
293
294
    public function setDescription(string $description): self
295
    {
296
        $this->description = $description;
297
        return $this;
298
    }
299
300
    public function getQueue()
301
    {
302
        return $this->queue;
303
    }
304
305
    public function setQueue($queue): self
306
    {
307
        $this->queue = $queue;
308
        return $this;
309
    }
310
311
    public function getProductFiles(): Collection
312
    {
313
        return $this->productFiles;
314
    }
315
316
    public function getProductCategory(): Collection
317
    {
318
        return $this->productCategory;
319
    }
320
321
    public function getFeatured(): bool
322
    {
323
        return $this->featured;
324
    }
325
326
    public function setFeatured(bool $featured): self
327
    {
328
        $this->featured = $featured;
329
        return $this;
330
    }
331
332
    public function getDefaultOutInventory(): ?Inventory
333
    {
334
        return $this->defaultOutInventory;
335
    }
336
337
    public function setDefaultOutInventory(Inventory $defaultOutInventory): self
338
    {
339
        $this->defaultOutInventory = $defaultOutInventory;
340
        return $this;
341
    }
342
343
    public function getDefaultInInventory(): ?Inventory
344
    {
345
        return $this->defaultInInventory;
346
    }
347
348
    public function setDefaultInInventory(Inventory $defaultInInventory): self
349
    {
350
        $this->defaultInInventory = $defaultInInventory;
351
        return $this;
352
    }
353
}