Passed
Push — master ( 05d637...dc0b40 )
by Luiz Kim
02:32
created

OrderProduct   A

Complexity

Total Complexity 31

Size/Duplication

Total Lines 335
Duplicated Lines 0 %

Importance

Changes 24
Bugs 0 Features 1
Metric Value
eloc 89
c 24
b 0
f 1
dl 0
loc 335
rs 9.92
wmc 31

25 Methods

Rating   Name   Duplication   Size   Complexity  
A setOrder() 0 4 1
A removeOrderProductComponent() 0 8 3
A getOrderProduct() 0 3 1
A getOrderProductQueues() 0 3 1
A setOrderProduct() 0 4 1
A setId() 0 4 1
A getId() 0 3 1
A getTotal() 0 3 1
A setPrice() 0 4 1
A getPrice() 0 3 1
A setQuantity() 0 4 1
A getQuantity() 0 3 1
A setProduct() 0 4 1
A getOrderProductComponents() 0 3 1
A setParentProduct() 0 4 1
A setTotal() 0 4 1
A addOrderProductComponent() 0 7 2
A addOrderProductQueue() 0 7 2
A getOrder() 0 3 1
A getParentProduct() 0 3 1
A getProductGroup() 0 3 1
A getProduct() 0 3 1
A __construct() 0 4 1
A removeOrderProductQueue() 0 8 3
A setProductGroup() 0 4 1
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 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...
7
use ApiPlatform\Core\Annotation\ApiSubresource;
0 ignored issues
show
Bug introduced by
The type ApiPlatform\Core\Annotation\ApiSubresource 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...
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\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...
10
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...
11
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...
12
use stdClass;
13
use ApiPlatform\Doctrine\Orm\Filter\DateFilter;
0 ignored issues
show
Bug introduced by
The type ApiPlatform\Doctrine\Orm\Filter\DateFilter 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\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...
15
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...
16
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...
17
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...
18
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...
19
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...
20
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...
21
use ApiPlatform\Metadata\ApiProperty;
0 ignored issues
show
Bug introduced by
The type ApiPlatform\Metadata\ApiProperty 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
 * OrderProduct
25
 *
26
 * @ORM\EntityListeners({ControleOnline\Listener\LogListener::class})
27
 * @ORM\Table(name="order_product")
28
 * @ORM\Entity(repositoryClass="ControleOnline\Repository\OrderProductRepository")
29
 */
30
#[ApiResource(
31
    operations: [
32
        new Get(
33
            security: 'is_granted(\'ROLE_CLIENT\')',
34
        ),
35
        new GetCollection(
36
            security: 'is_granted(\'ROLE_ADMIN\') or is_granted(\'ROLE_CLIENT\')',
37
        ),
38
        new Post(
39
            security: 'is_granted(\'ROLE_ADMIN\') or is_granted(\'ROLE_CLIENT\')',
40
        ),
41
        new Put(
42
            security: 'is_granted(\'ROLE_ADMIN\') or (is_granted(\'ROLE_CLIENT\'))',
43
        ),
44
        new Delete(
45
            security: 'is_granted(\'ROLE_ADMIN\') or (is_granted(\'ROLE_CLIENT\'))',
46
        ),
47
    ],
48
    formats: ['jsonld', 'json', 'html', 'jsonhal', 'csv' => ['text/csv']],
49
    normalizationContext: ['groups' => ['order_product:read']],
50
    denormalizationContext: ['groups' => ['order_product:write']]
51
)]
52
#[ApiFilter(filterClass: OrderFilter::class, properties: ['alterDate' => 'DESC'])]
53
#[ApiFilter(OrderFilter::class, properties: ['id' => 'ASC', 'product.product' => 'ASC'])]
54
class OrderProduct
55
{
56
    /**
57
     * @ORM\Id
58
     * @ORM\GeneratedValue
59
     * @ORM\Column(type="integer")
60
     * @Groups({"order_product_queue:read","order:read","order_details:read","order:write","order_product:write","order_product:read"})
61
     */
62
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['id' => 'exact'])]
63
    private $id;
64
65
    /**
66
     * @ORM\ManyToOne(targetEntity="ControleOnline\Entity\Order")
67
     * @ORM\JoinColumn(nullable=false)
68
     * @Groups({"order_product_queue:read","order_product:write","order_product:read"})
69
     */
70
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['order' => 'exact'])]
71
    private $order;
72
73
    /**
74
     * @ORM\ManyToOne(targetEntity="ControleOnline\Entity\Product")
75
     * @ORM\JoinColumn(nullable=false)
76
     * @Groups({"order_product_queue:read","order:read","order_details:read","order:write","order_product:write","order_product:read"})
77
     */
78
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['product' => 'exact'])]
79
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['product.type' => 'exact'])]
80
    private $product;
81
82
    /**
83
     * @ORM\ManyToOne(targetEntity="ControleOnline\Entity\Product")
84
     * @ORM\JoinColumn(name="parent_product_id", referencedColumnName="id", nullable=true)
85
     * @Groups({"order_product:write","order_product:read"})
86
     */
87
    #[ApiFilter(ExistsFilter::class, properties: ['parentProduct'])]
88
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['parentProduct' => 'exact'])]
89
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['parentProduct.type' => 'exact'])]
90
    private $parentProduct;
91
92
    /**
93
     * @ORM\ManyToOne(targetEntity="ControleOnline\Entity\OrderProduct", inversedBy="orderProductComponents")
94
     * @ORM\JoinColumn(name="order_product_id", nullable=true)
95
     * @Groups({"order_product:write","order_product:read"})
96
     */
97
    #[ApiFilter(ExistsFilter::class, properties: ['orderProduct'])]
98
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['orderProduct' => 'exact'])]
99
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['orderProduct.type' => 'exact'])]
100
    private $orderProduct;
101
102
    /**
103
     * @ORM\ManyToOne(targetEntity="ControleOnline\Entity\ProductGroup")
104
     * @ORM\JoinColumn(nullable=true)
105
     * @Groups({"order_product:write","order_product:read"})
106
     */
107
    #[ApiFilter(ExistsFilter::class, properties: ['productGroup'])]
108
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['productGroup' => 'exact'])]
109
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['productGroup.type' => 'exact'])]
110
    private $productGroup;
111
112
    /**
113
     * @ORM\OneToMany(targetEntity="ControleOnline\Entity\OrderProduct", mappedBy="orderProduct")
114
     * @Groups({"order_product:read", "order_product:write"})
115
     */
116
    private $orderProductComponents;
117
118
    /**
119
     * @ORM\OneToMany(targetEntity="ControleOnline\Entity\OrderProductQueue", mappedBy="order_product")
120
     * @Groups({"order_product:read"})
121
     */
122
    private $orderProductQueues;
123
124
    /**
125
     * @ORM\Column(type="float")
126
     * @Groups({"order_product_queue:read","order:read","order_details:read","order:write","order_product:write","order_product:read"})
127
     */
128
    private $quantity = 1;
129
130
    /**
131
     * @ORM\Column(type="float")
132
     * @Groups({"order_product_queue:read","order:read","order_details:read","order:write","order_product:write","order_product:read"})
133
     */
134
    private $price = 0;
135
136
    /**
137
     * @ORM\Column(type="float")
138
     * @Groups({"order_product_queue:read","order:read","order_details:read","order:write","order_product:write","order_product:read"})
139
     */
140
    private $total = 0;
141
142
    public function __construct()
143
    {
144
        $this->orderProductQueues = new ArrayCollection();
145
        $this->orderProductComponents = new ArrayCollection();
146
    }
147
148
    /**
149
     * Get the value of id
150
     */
151
    public function getId()
152
    {
153
        return $this->id;
154
    }
155
156
    /**
157
     * Set the value of id
158
     */
159
    public function setId($id): self
160
    {
161
        $this->id = $id;
162
        return $this;
163
    }
164
165
    /**
166
     * Get the value of order
167
     */
168
    public function getOrder()
169
    {
170
        return $this->order;
171
    }
172
173
    /**
174
     * Set the value of order
175
     */
176
    public function setOrder($order): self
177
    {
178
        $this->order = $order;
179
        return $this;
180
    }
181
182
    /**
183
     * Get the value of product
184
     */
185
    public function getProduct()
186
    {
187
        return $this->product;
188
    }
189
190
    /**
191
     * Set the value of product
192
     */
193
    public function setProduct($product): self
194
    {
195
        $this->product = $product;
196
        return $this;
197
    }
198
199
    /**
200
     * Get the value of quantity
201
     */
202
    public function getQuantity()
203
    {
204
        return $this->quantity;
205
    }
206
207
    /**
208
     * Set the value of quantity
209
     */
210
    public function setQuantity($quantity): self
211
    {
212
        $this->quantity = $quantity;
213
        return $this;
214
    }
215
216
    /**
217
     * Get the value of price
218
     */
219
    public function getPrice()
220
    {
221
        return $this->price;
222
    }
223
224
    /**
225
     * Set the value of price
226
     */
227
    public function setPrice($price): self
228
    {
229
        $this->price = $price;
230
        return $this;
231
    }
232
233
    /**
234
     * Get the value of total
235
     */
236
    public function getTotal()
237
    {
238
        return $this->total;
239
    }
240
241
    /**
242
     * Set the value of total
243
     */
244
    public function setTotal($total): self
245
    {
246
        $this->total = $total;
247
        return $this;
248
    }
249
250
    /**
251
     * Get the value of parentProduct
252
     */
253
    public function getParentProduct()
254
    {
255
        return $this->parentProduct;
256
    }
257
258
    /**
259
     * Set the value of parentProduct
260
     */
261
    public function setParentProduct($parentProduct): self
262
    {
263
        $this->parentProduct = $parentProduct;
264
        return $this;
265
    }
266
267
    /**
268
     * Get the value of orderProduct
269
     */
270
    public function getOrderProduct()
271
    {
272
        return $this->orderProduct;
273
    }
274
275
    /**
276
     * Set the value of orderProduct
277
     */
278
    public function setOrderProduct(?OrderProduct $orderProduct): self
279
    {
280
        $this->orderProduct = $orderProduct;
281
        return $this;
282
    }
283
284
    /**
285
     * Get the value of productGroup
286
     */
287
    public function getProductGroup()
288
    {
289
        return $this->productGroup;
290
    }
291
292
    /**
293
     * Set the value of productGroup
294
     */
295
    public function setProductGroup($productGroup): self
296
    {
297
        $this->productGroup = $productGroup;
298
        return $this;
299
    }
300
301
    /**
302
     * Get the value of orderProductQueues
303
     */
304
    public function getOrderProductQueues()
305
    {
306
        return $this->orderProductQueues;
307
    }
308
309
    /**
310
     * Add an OrderProductQueue
311
     */
312
    public function addOrderProductQueue(OrderProductQueue $orderProductQueue): self
0 ignored issues
show
Bug introduced by
The type ControleOnline\Entity\OrderProductQueue 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...
313
    {
314
        if (!$this->orderProductQueues->contains($orderProductQueue)) {
315
            $this->orderProductQueues[] = $orderProductQueue;
316
            $orderProductQueue->setOrderProduct($this);
317
        }
318
        return $this;
319
    }
320
321
    /**
322
     * Remove an OrderProductQueue
323
     */
324
    public function removeOrderProductQueue(OrderProductQueue $orderProductQueue): self
325
    {
326
        if ($this->orderProductQueues->removeElement($orderProductQueue)) {
327
            if ($orderProductQueue->getOrderProduct() === $this) {
328
                $orderProductQueue->setOrderProduct(null);
329
            }
330
        }
331
        return $this;
332
    }
333
334
    /**
335
     * Get the value of orderProductComponents
336
     */
337
    public function getOrderProductComponents()
338
    {
339
        return $this->orderProductComponents;
340
    }
341
342
    /**
343
     * Add an OrderProduct component
344
     */
345
    public function addOrderProductComponent(OrderProduct $orderProductComponent): self
346
    {
347
        if (!$this->orderProductComponents->contains($orderProductComponent)) {
348
            $this->orderProductComponents[] = $orderProductComponent;
349
            $orderProductComponent->setOrderProduct($this);
350
        }
351
        return $this;
352
    }
353
354
    /**
355
     * Remove an OrderProduct component
356
     */
357
    public function removeOrderProductComponent(OrderProduct $orderProductComponent): self
358
    {
359
        if ($this->orderProductComponents->removeElement($orderProductComponent)) {
360
            if ($orderProductComponent->getOrderProduct() === $this) {
361
                $orderProductComponent->setOrderProduct(null);
362
            }
363
        }
364
        return $this;
365
    }
366
}