Passed
Push — master ( c4d70d...77eaa4 )
by Luiz Kim
02:36
created

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