Passed
Push — master ( 849e99...ce7ca6 )
by Luiz Kim
04:15 queued 01:56
created

OrderProduct::getProductGroup()   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
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\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
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
            validationContext: ['groups' => ['order_product:write']],
42
            denormalizationContext: ['groups' => ['order_product:write']]
43
        ),
44
        new Put(
45
            security: 'is_granted(\'ROLE_ADMIN\') or (is_granted(\'ROLE_CLIENT\'))',
46
            validationContext: ['groups' => ['order_product:write']],
47
            denormalizationContext: ['groups' => ['order_product:write']]
48
        ),
49
        new Delete(
50
            security: 'is_granted(\'ROLE_ADMIN\') or (is_granted(\'ROLE_CLIENT\'))',
51
            validationContext: ['groups' => ['order_product:write']],
52
            denormalizationContext: ['groups' => ['order_product:write']]
53
        ),
54
    ],
55
    formats: ['jsonld', 'json', 'html', 'jsonhal', 'csv' => ['text/csv']],
56
    normalizationContext: ['groups' => ['order_product:read']],
57
    denormalizationContext: ['groups' => ['order_product:write']]
58
)]
59
#[ApiFilter(filterClass: OrderFilter::class, properties: ['alterDate' => 'DESC'])]
60
61
class OrderProduct
62
{
63
    /**
64
     * @ORM\Id
65
     * @ORM\GeneratedValue
66
     * @ORM\Column(type="integer")
67
     * @Groups({"order:read","order_details:read","order:write","order_product:write","order_product:read"})
68
     */
69
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['id' => 'exact'])]
70
    private $id;
71
72
    /**
73
     * @ORM\ManyToOne(targetEntity="ControleOnline\Entity\Order")
74
     * @ORM\JoinColumn(nullable=false)
75
     * @Groups({"order_product:write","order_product:read"})
76
     */
77
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['order' => 'exact'])]
78
    private $order;
79
80
    /**
81
     * @ORM\ManyToOne(targetEntity="ControleOnline\Entity\Product")
82
     * @ORM\JoinColumn(nullable=false)
83
     * @Groups({"order:read","order_details:read","order:write","order_product:write","order_product:read"})
84
     */
85
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['product' => 'exact'])]
86
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['product.type' => 'exact'])]
87
    private $product;
88
89
90
    /**
91
     * @ORM\ManyToOne(targetEntity="ControleOnline\Entity\Product")
92
     * @ORM\JoinColumn(nullable=true)
93
     * @Groups({"order:read","order_details:read","order:write","order_product:write","order_product:read"})
94
     */
95
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['parent_product' => 'exact'])]
96
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['parent_product.type' => 'exact'])]
97
    private $parent_product;
98
99
    /**
100
     * @ORM\Column(type="float")
101
     * @Groups({"order:read","order_details:read","order:write","order_product:write","order_product:read"})
102
     */
103
    private $quantity = 1;
104
105
    /**
106
     * @ORM\Column(type="float")
107
     * @Groups({"order:read","order_details:read","order:write","order_product:write","order_product:read"})
108
     */
109
    private $price = 0;
110
111
    /**
112
     * @ORM\Column(type="float")
113
     * @Groups({"order:read","order_details:read","order:write","order_product:write","order_product:read"})
114
     */
115
    private $total = 0;
116
117
    // Getters and setters
118
119
    /**
120
     * Get the value of id
121
     */
122
    public function getId()
123
    {
124
        return $this->id;
125
    }
126
127
    /**
128
     * Set the value of id
129
     */
130
    public function setId($id): self
131
    {
132
        $this->id = $id;
133
134
        return $this;
135
    }
136
137
    /**
138
     * Get the value of order
139
     */
140
    public function getOrder()
141
    {
142
        return $this->order;
143
    }
144
145
    /**
146
     * Set the value of order
147
     */
148
    public function setOrder($order): self
149
    {
150
        $this->order = $order;
151
152
        return $this;
153
    }
154
155
    /**
156
     * Get the value of product
157
     */
158
    public function getProduct()
159
    {
160
        return $this->product;
161
    }
162
163
    /**
164
     * Set the value of product
165
     */
166
    public function setProduct($product): self
167
    {
168
        $this->product = $product;
169
170
        return $this;
171
    }
172
173
    /**
174
     * Get the value of quantity
175
     */
176
    public function getQuantity()
177
    {
178
        return $this->quantity;
179
    }
180
181
    /**
182
     * Set the value of quantity
183
     */
184
    public function setQuantity($quantity): self
185
    {
186
        $this->quantity = $quantity;
187
188
        return $this;
189
    }
190
191
    /**
192
     * Get the value of price
193
     */
194
    public function getPrice()
195
    {
196
        return $this->price;
197
    }
198
199
    /**
200
     * Set the value of price
201
     */
202
    public function setPrice($price): self
203
    {
204
        $this->price = $price;
205
206
        return $this;
207
    }
208
209
    /**
210
     * Get the value of total
211
     */
212
    public function getTotal()
213
    {
214
        return $this->total;
215
    }
216
217
    /**
218
     * Set the value of total
219
     */
220
    public function setTotal($total): self
221
    {
222
        $this->total = $total;
223
224
        return $this;
225
    }
226
227
    /**
228
     * Get the value of parent_product
229
     */
230
    public function getParentProduct()
231
    {
232
        return $this->parent_product;
233
    }
234
235
    /**
236
     * Set the value of parent_product
237
     */
238
    public function setParentProduct($parent_product): self
239
    {
240
        $this->parent_product = $parent_product;
241
242
        return $this;
243
    }
244
}
245