Passed
Push — master ( f8cd73...54ec09 )
by Luiz Kim
02:26
created

OrderProduct::setProductGroup()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
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 5
rs 10
1
<?php
2
3
namespace ControleOnline\Entity;
4
5
6
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...
7
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...
8
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...
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\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...
11
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...
12
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...
13
use stdClass;
14
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...
15
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...
16
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...
17
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...
18
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...
19
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...
20
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...
21
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...
22
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...
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
32
#[ApiResource(
33
    operations: [
34
        new Get(
35
            security: 'is_granted(\'ROLE_CLIENT\')',
36
        ),
37
        new GetCollection(
38
            security: 'is_granted(\'ROLE_ADMIN\') or is_granted(\'ROLE_CLIENT\')',
39
        ),
40
        new Post(
41
            security: 'is_granted(\'ROLE_ADMIN\') or is_granted(\'ROLE_CLIENT\')',
42
        ),
43
        new Put(
44
            security: 'is_granted(\'ROLE_ADMIN\') or (is_granted(\'ROLE_CLIENT\'))',
45
        ),
46
        new Delete(
47
            security: 'is_granted(\'ROLE_ADMIN\') or (is_granted(\'ROLE_CLIENT\'))',
48
        ),
49
    ],
50
    formats: ['jsonld', 'json', 'html', 'jsonhal', 'csv' => ['text/csv']],
51
    normalizationContext: ['groups' => ['order_product:read']],
52
    denormalizationContext: ['groups' => ['order_product:write']]
53
)]
54
#[ApiFilter(filterClass: OrderFilter::class, properties: ['alterDate' => 'DESC'])]
55
56
class OrderProduct
57
{
58
    /**
59
     * @ORM\Id
60
     * @ORM\GeneratedValue
61
     * @ORM\Column(type="integer")
62
     * @Groups({"order:read","order_details:read","order:write","order_product:write","order_product:read"})
63
     */
64
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['id' => 'exact'])]
65
    private $id;
66
67
    /**
68
     * @ORM\ManyToOne(targetEntity="ControleOnline\Entity\Order")
69
     * @ORM\JoinColumn(nullable=false)
70
     * @Groups({"order_product:write","order_product:read"})
71
     */
72
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['order' => 'exact'])]
73
    private $order;
74
75
    /**
76
     * @ORM\ManyToOne(targetEntity="ControleOnline\Entity\Product")
77
     * @ORM\JoinColumn(nullable=false)
78
     * @Groups({"order:read","order_details:read","order:write","order_product:write","order_product:read"})
79
     */
80
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['product' => 'exact'])]
81
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['product.type' => 'exact'])]
82
    private $product;
83
84
85
    /**
86
     * @ORM\ManyToOne(targetEntity="ControleOnline\Entity\Product")
87
     * @ORM\JoinColumn(nullable=true)
88
     * @Groups({"order_product:write","order_product:read"})
89
     */
90
    #[ApiFilter(ExistsFilter::class, properties: ['parentProduct'])]
91
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['parentProduct' => 'exact'])]
92
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['parentProduct.type' => 'exact'])]
93
    private $parentProduct;
94
95
    /**
96
     * @ORM\ManyToOne(targetEntity="ControleOnline\Entity\OrderProduct")
97
     * @ORM\JoinColumn(nullable=true)
98
     * @Groups({"order_product:write","order_product:read"})
99
     */
100
    #[ApiFilter(ExistsFilter::class, properties: ['orderProduct'])]
101
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['orderProduct' => 'exact'])]
102
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['orderProduct.type' => 'exact'])]
103
    private $orderProduct;
104
105
    /**
106
     * @ORM\ManyToOne(targetEntity="ControleOnline\Entity\ProductGroup")
107
     * @ORM\JoinColumn(nullable=true)
108
     * @Groups({"order_product:write","order_product:read"})
109
     */
110
    #[ApiFilter(ExistsFilter::class, properties: ['productGroup'])]
111
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['productGroup' => 'exact'])]
112
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['productGroup.type' => 'exact'])]
113
    private $productGroup;
114
    
115
116
    /**
117
     * @ORM\Column(type="float")
118
     * @Groups({"order:read","order_details:read","order:write","order_product:write","order_product:read"})
119
     */
120
    private $quantity = 1;
121
122
    /**
123
     * @ORM\Column(type="float")
124
     * @Groups({"order:read","order_details:read","order:write","order_product:write","order_product:read"})
125
     */
126
    private $price = 0;
127
128
    /**
129
     * @ORM\Column(type="float")
130
     * @Groups({"order:read","order_details:read","order:write","order_product:write","order_product:read"})
131
     */
132
    private $total = 0;
133
134
    // Getters and setters
135
136
    /**
137
     * Get the value of id
138
     */
139
    public function getId()
140
    {
141
        return $this->id;
142
    }
143
144
    /**
145
     * Set the value of id
146
     */
147
    public function setId($id): self
148
    {
149
        $this->id = $id;
150
151
        return $this;
152
    }
153
154
    /**
155
     * Get the value of order
156
     */
157
    public function getOrder()
158
    {
159
        return $this->order;
160
    }
161
162
    /**
163
     * Set the value of order
164
     */
165
    public function setOrder($order): self
166
    {
167
        $this->order = $order;
168
169
        return $this;
170
    }
171
172
    /**
173
     * Get the value of product
174
     */
175
    public function getProduct()
176
    {
177
        return $this->product;
178
    }
179
180
    /**
181
     * Set the value of product
182
     */
183
    public function setProduct($product): self
184
    {
185
        $this->product = $product;
186
187
        return $this;
188
    }
189
190
    /**
191
     * Get the value of quantity
192
     */
193
    public function getQuantity()
194
    {
195
        return $this->quantity;
196
    }
197
198
    /**
199
     * Set the value of quantity
200
     */
201
    public function setQuantity($quantity): self
202
    {
203
        $this->quantity = $quantity;
204
205
        return $this;
206
    }
207
208
    /**
209
     * Get the value of price
210
     */
211
    public function getPrice()
212
    {
213
        return $this->price;
214
    }
215
216
    /**
217
     * Set the value of price
218
     */
219
    public function setPrice($price): self
220
    {
221
        $this->price = $price;
222
223
        return $this;
224
    }
225
226
    /**
227
     * Get the value of total
228
     */
229
    public function getTotal()
230
    {
231
        return $this->total;
232
    }
233
234
    /**
235
     * Set the value of total
236
     */
237
    public function setTotal($total): self
238
    {
239
        $this->total = $total;
240
241
        return $this;
242
    }
243
244
    /**
245
     * Get the value of parentProduct
246
     */
247
    public function getParentProduct()
248
    {
249
        return $this->parentProduct;
250
    }
251
252
    /**
253
     * Set the value of parentProduct
254
     */
255
    public function setParentProduct($parentProduct): self
256
    {
257
        $this->parentProduct = $parentProduct;
258
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
277
        return $this;
278
    }
279
280
    /**
281
     * Get the value of productGroup
282
     */
283
    public function getProductGroup()
284
    {
285
        return $this->productGroup;
286
    }
287
288
    /**
289
     * Set the value of productGroup
290
     */
291
    public function setProductGroup($productGroup): self
292
    {
293
        $this->productGroup = $productGroup;
294
295
        return $this;
296
    }
297
}
298