Passed
Push — master ( f11284...b75554 )
by Luiz Kim
07:56 queued 05:34
created

OrderProduct::setOrder()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 2
b 0
f 0
nc 1
nop 1
dl 0
loc 4
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
 * 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(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")
94
     * @ORM\JoinColumn(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\OrderProductQueue", mappedBy="order_product")
114
     * @Groups({"order_product:read"})
115
     */
116
    private $orderProductQueues;
117
118
    /**
119
     * @ORM\Column(type="float")
120
     * @Groups({"order_product_queue:read","order:read","order_details:read","order:write","order_product:write","order_product:read"})
121
     */
122
    private $quantity = 1;
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 $price = 0;
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 $total = 0;
135
136
    public function __construct()
137
    {
138
        $this->orderProductQueues = new ArrayCollection();
139
    }
140
141
    // Getters and setters
142
143
    /**
144
     * Get the value of id
145
     */
146
    public function getId()
147
    {
148
        return $this->id;
149
    }
150
151
    /**
152
     * Set the value of id
153
     */
154
    public function setId($id): self
155
    {
156
        $this->id = $id;
157
        return $this;
158
    }
159
160
    /**
161
     * Get the value of order
162
     */
163
    public function getOrder()
164
    {
165
        return $this->order;
166
    }
167
168
    /**
169
     * Set the value of order
170
     */
171
    public function setOrder($order): self
172
    {
173
        $this->order = $order;
174
        return $this;
175
    }
176
177
    /**
178
     * Get the value of product
179
     */
180
    public function getProduct()
181
    {
182
        return $this->product;
183
    }
184
185
    /**
186
     * Set the value of product
187
     */
188
    public function setProduct($product): self
189
    {
190
        $this->product = $product;
191
        return $this;
192
    }
193
194
    /**
195
     * Get the value of quantity
196
     */
197
    public function getQuantity()
198
    {
199
        return $this->quantity;
200
    }
201
202
    /**
203
     * Set the value of quantity
204
     */
205
    public function setQuantity($quantity): self
206
    {
207
        $this->quantity = $quantity;
208
        return $this;
209
    }
210
211
    /**
212
     * Get the value of price
213
     */
214
    public function getPrice()
215
    {
216
        return $this->price;
217
    }
218
219
    /**
220
     * Set the value of price
221
     */
222
    public function setPrice($price): self
223
    {
224
        $this->price = $price;
225
        return $this;
226
    }
227
228
    /**
229
     * Get the value of total
230
     */
231
    public function getTotal()
232
    {
233
        return $this->total;
234
    }
235
236
    /**
237
     * Set the value of total
238
     */
239
    public function setTotal($total): self
240
    {
241
        $this->total = $total;
242
        return $this;
243
    }
244
245
    /**
246
     * Get the value of parentProduct
247
     */
248
    public function getParentProduct()
249
    {
250
        return $this->parentProduct;
251
    }
252
253
    /**
254
     * Set the value of parentProduct
255
     */
256
    public function setParentProduct($parentProduct): self
257
    {
258
        $this->parentProduct = $parentProduct;
259
        return $this;
260
    }
261
262
    /**
263
     * Get the value of orderProduct
264
     */
265
    public function getOrderProduct()
266
    {
267
        return $this->orderProduct;
268
    }
269
270
    /**
271
     * Set the value of orderProduct
272
     */
273
    public function setOrderProduct($orderProduct): self
274
    {
275
        $this->orderProduct = $orderProduct;
276
        return $this;
277
    }
278
279
    /**
280
     * Get the value of productGroup
281
     */
282
    public function getProductGroup()
283
    {
284
        return $this->productGroup;
285
    }
286
287
    /**
288
     * Set the value of productGroup
289
     */
290
    public function setProductGroup($productGroup): self
291
    {
292
        $this->productGroup = $productGroup;
293
        return $this;
294
    }
295
296
    /**
297
     * Get the value of orderProductQueues
298
     */
299
    public function getOrderProductQueues()
300
    {
301
        return $this->orderProductQueues;
302
    }
303
304
    /**
305
     * Add an OrderProductQueue
306
     */
307
    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...
308
    {
309
        if (!$this->orderProductQueues->contains($orderProductQueue)) {
310
            $this->orderProductQueues[] = $orderProductQueue;
311
            $orderProductQueue->setOrderProduct($this);
312
        }
313
        return $this;
314
    }
315
316
    public function removeOrderProductQueue(OrderProductQueue $orderProductQueue): self
317
    {
318
        if ($this->orderProductQueues->removeElement($orderProductQueue)) {
319
            if ($orderProductQueue->getOrderProduct() === $this) {
320
                $orderProductQueue->setOrderProduct(null);
321
            }
322
        }
323
        return $this;
324
    }
325
}