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

ProductComponent::getParentProduct()   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
 * ProductComponent
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_ADMIN\') or 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' => ['product_components:read']],
50
    denormalizationContext: ['groups' => ['product_components:write']]
51
)]
52
#[ApiFilter(filterClass: OrderFilter::class, properties: ['alterDate' => 'DESC'])]
53
#[ApiFilter(OrderFilter::class, properties: ['id' => 'ASC', 'parentProduct' => 'ASC'])]
54
class ProductComponent
55
{
56
    /**
57
     * @ORM\Id
58
     * @ORM\GeneratedValue
59
     * @ORM\Column(type="integer")
60
     * @Groups({"product_components:read", "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({"product_components:read", "product_components:write", "order_product:read", "order_product:write"})
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({"product_components:read", "product_components:write", "order_product:read", "order_product:write"})
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({"product_components:read", "product_components:write"})
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\Column(type="float")
94
     * @Groups({"product_components:read", "product_components:write", "order_product:read", "order_product:write"})
95
     */
96
    private $quantity = 1;
97
98
    /**
99
     * @ORM\Column(type="float")
100
     * @Groups({"product_components:read", "product_components:write", "order_product:read", "order_product:write"})
101
     */
102
    private $price = 0;
103
104
    /**
105
     * @ORM\Column(type="float")
106
     * @Groups({"product_components:read", "product_components:write", "order_product:read", "order_product:write"})
107
     */
108
    private $total = 0;
109
110
    public function __construct()
111
    {
112
    }
113
114
    /**
115
     * Get the value of id
116
     */
117
    public function getId()
118
    {
119
        return $this->id;
120
    }
121
122
    /**
123
     * Set the value of id
124
     */
125
    public function setId($id): self
126
    {
127
        $this->id = $id;
128
        return $this;
129
    }
130
131
    /**
132
     * Get the value of order
133
     */
134
    public function getOrder()
135
    {
136
        return $this->order;
137
    }
138
139
    /**
140
     * Set the value of order
141
     */
142
    public function setOrder($order): self
143
    {
144
        $this->order = $order;
145
        return $this;
146
    }
147
148
    /**
149
     * Get the value of product
150
     */
151
    public function getProduct()
152
    {
153
        return $this->product;
154
    }
155
156
    /**
157
     * Set the value of product
158
     */
159
    public function setProduct($product): self
160
    {
161
        $this->product = $product;
162
        return $this;
163
    }
164
165
    /**
166
     * Get the value of parentProduct
167
     */
168
    public function getParentProduct()
169
    {
170
        return $this->parentProduct;
171
    }
172
173
    /**
174
     * Set the value of parentProduct
175
     */
176
    public function setParentProduct($parentProduct): self
177
    {
178
        $this->parentProduct = $parentProduct;
179
        return $this;
180
    }
181
182
    /**
183
     * Get the value of quantity
184
     */
185
    public function getQuantity()
186
    {
187
        return $this->quantity;
188
    }
189
190
    /**
191
     * Set the value of quantity
192
     */
193
    public function setQuantity($quantity): self
194
    {
195
        $this->quantity = $quantity;
196
        return $this;
197
    }
198
199
    /**
200
     * Get the value of price
201
     */
202
    public function getPrice()
203
    {
204
        return $this->price;
205
    }
206
207
    /**
208
     * Set the value of price
209
     */
210
    public function setPrice($price): self
211
    {
212
        $this->price = $price;
213
        return $this;
214
    }
215
216
    /**
217
     * Get the value of total
218
     */
219
    public function getTotal()
220
    {
221
        return $this->total;
222
    }
223
224
    /**
225
     * Set the value of total
226
     */
227
    public function setTotal($total): self
228
    {
229
        $this->total = $total;
230
        return $this;
231
    }
232
}