Passed
Push — master ( f719f2...ac9ba8 )
by Luiz Kim
05:01 queued 02:51
created

Product::getChildProducts()   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
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
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 ControleOnline\Entity\People;
0 ignored issues
show
Bug introduced by
The type ControleOnline\Entity\People 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 ControleOnline\Entity\ProductUnity;
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\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...
10
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...
11
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...
12
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...
13
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...
14
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...
15
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...
16
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...
17
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...
18
use Doctrine\Common\Collections\Collection;
0 ignored issues
show
Bug introduced by
The type Doctrine\Common\Collections\Collection 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\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...
20
use ControleOnline\Filter\RandomOrderFilter;
0 ignored issues
show
Bug introduced by
The type ControleOnline\Filter\RandomOrderFilter 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
22
/**
23
 * Product
24
 *
25
 * @ORM\Table(name="product", uniqueConstraints={@ORM\UniqueConstraint(name="company_id", columns={"company_id", "sku"})}, indexes={@ORM\Index(name="product_unit_id", columns={"product_unit_id"}), @ORM\Index(name="IDX_D34A04AD979B1AD6", columns={"company_id"})})
26
 * @ORM\Entity(repositoryClass="ControleOnline\Repository\ProductRepository")
27
 */
28
#[ApiResource(
29
    operations: [
30
        new Get(security: 'is_granted(\'IS_AUTHENTICATED_ANONYMOUSLY\')'),
31
        new Put(security: 'is_granted(\'ROLE_CLIENT\')', denormalizationContext: ['groups' => ['product:write']]),
32
        new Delete(security: 'is_granted(\'ROLE_CLIENT\')'),
33
        new Post(securityPostDenormalize: 'is_granted(\'ROLE_CLIENT\')'),
34
        new GetCollection(security: 'is_granted(\'IS_AUTHENTICATED_ANONYMOUSLY\')'),
35
    ],
36
    formats: ['jsonld', 'json', 'html', 'jsonhal', 'csv' => ['text/csv']],
37
    normalizationContext: ['groups' => ['product:read']],
38
    denormalizationContext: ['groups' => ['product:write']]
39
)]
40
#[ApiFilter(OrderFilter::class, properties: ['id' => 'ASC', 'product' => 'ASC', 'price' => 'DESC'])]
41
#[ApiFilter(RandomOrderFilter::class)]
42
class Product
43
{
44
    /**
45
     * @var int
46
     * @ORM\Column(name="id", type="integer", nullable=false)
47
     * @ORM\Id
48
     * @ORM\GeneratedValue(strategy="IDENTITY")
49
     * @Groups({"product_category:read","product:read","order_product:read"})
50
     */
51
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['id' => 'exact'])]
52
    private $id;
53
54
    /**
55
     * @var string
56
     * @ORM\Column(name="product", type="string", length=255, nullable=false)
57
     * @Groups({"product_category:read","product:read","product_group_product:read","order_product:read","order_product_queue:read","order:read","order_details:read","order:write","product:write"})
58
     */
59
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['product' => 'partial'])]
60
    private $product;
61
62
    /**
63
     * @ORM\OneToMany(targetEntity="ProductFile", mappedBy="product")
64
     * @Groups({"product:read","product_category:read"})
65
     */
66
    #[ApiFilter(filterClass: ExistsFilter::class, properties: ['productFiles'])]
67
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['productFiles.file.fileType' => 'exact'])]
68
    private $productFiles;
69
70
    /**
71
     * @ORM\OneToMany(targetEntity="ProductCategory", mappedBy="product")
72
     */
73
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['productCategory.category' => 'exact'])]
74
    private $productCategory;
75
76
    /**
77
     * @var string|null
78
     * @ORM\Column(name="sku", type="string", length=32, nullable=true, options={"default"="NULL"})
79
     * @Groups({"product_category:read","product:read","product_group_product:read","order_product:read","order_product_queue:read","order:read","order_details:read","order:write","product:write"})
80
     */
81
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['sku' => 'partial'])]
82
    private $sku = null;
83
84
    /**
85
     * @var string
86
     * @ORM\Column(name="type", type="string", length=0, nullable=false, options={"default"="'product'"})
87
     * @Groups({"product_category:read","product:read","product_group_product:read","order_product:read","order_product_queue:read","order:read","order_details:read","order:write","product:write"})
88
     */
89
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['type' => 'exact'])]
90
    private $type = 'product';
91
92
    /**
93
     * @var float
94
     * @ORM\Column(name="price", type="float", precision=10, scale=0, nullable=false)
95
     * @Groups({"product_category:read","product:read","product_group_product:read","order_product:read","order_product_queue:read","order:read","order_details:read","order:write","product:write"})
96
     */
97
    private $price = 0;
98
99
    /**
100
     * @var string
101
     * @ORM\Column(name="product_condition", type="string", length=0, nullable=false, options={"default"="'new'"})
102
     * @Groups({"product_category:read","product:read","product_group_product:read","order_product:read","order_product_queue:read","order:read","order_details:read","order:write","product:write"})
103
     */
104
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['productCondition' => 'exact'])]
105
    private $productCondition = 'new';
106
107
    /**
108
     * @var string
109
     * @ORM\Column(name="description", type="string", length=0, nullable=false)
110
     * @Groups({"product_category:read","product:read","product_group_product:read","order_product:read","order_product_queue:read","order:read","order_details:read","order:write","product:write"})
111
     */
112
    private $description = '';
113
114
    /**
115
     * @var bool
116
     * @ORM\Column(name="featured", type="boolean", nullable=false, options={"default"="0"})
117
     * @Groups({"product_category:read","product:read","product_group_product:read","order_product:read","order_product_queue:read","order:read","order_details:read","order:write","product:write"})
118
     */
119
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['featured' => 'exact'])]
120
    private $featured = false;
121
122
    /**
123
     * @var bool
124
     * @ORM\Column(name="active", type="boolean", nullable=false, options={"default"="1"})
125
     * @Groups({"product_category:read","product:read","product_group_product:read","order_product:read","order_product_queue:read","order:read","order_details:read","order:write","product:write"})
126
     */
127
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['active' => 'exact'])]
128
    private $active = true;
129
130
    /**
131
     * @var \ControleOnline\Entity\People
132
     * @ORM\ManyToOne(targetEntity="\ControleOnline\Entity\People")
133
     * @ORM\JoinColumns({
134
     *   @ORM\JoinColumn(name="company_id", referencedColumnName="id")
135
     * })
136
     * @Groups({"product_category:read","product:read","product_group_product:read","order_product:read","order_product_queue:read","order:read","order_details:read","order:write","product:write"})
137
     */
138
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['company' => 'exact'])]
139
    private $company;
140
141
    /**
142
     * @var ProductUnity
143
     * @ORM\ManyToOne(targetEntity="ProductUnity")
144
     * @ORM\JoinColumns({
145
     *   @ORM\JoinColumn(name="product_unit_id", referencedColumnName="id")
146
     * })
147
     * @Groups({"product_category:read","product:read","product_group_product:read","order_product:read","order_product_queue:read","order:read","order_details:read","order:write","product:write"})
148
     */
149
    private $productUnit;
150
151
    /**
152
     * @var Queue
0 ignored issues
show
Bug introduced by
The type ControleOnline\Entity\Queue 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...
153
     * @ORM\ManyToOne(targetEntity="Queue")
154
     * @ORM\JoinColumns({
155
     *   @ORM\JoinColumn(name="queue_id", referencedColumnName="id")
156
     * })
157
     * @Groups({"product_category:read","product:read","product_group_product:read","order_product:read","order_product_queue:read","order:read","order_details:read","order:write","product:write"})
158
     */
159
    private $queue;
160
161
    public function __construct()
162
    {
163
        $this->productFiles = new \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...
164
        $this->productCategory = new \Doctrine\Common\Collections\ArrayCollection();
165
    }
166
167
    public function getId(): int
168
    {
169
        return $this->id;
170
    }
171
172
    public function setId(int $id): self
173
    {
174
        $this->id = $id;
175
        return $this;
176
    }
177
178
    public function getProduct(): string
179
    {
180
        return $this->product;
181
    }
182
183
    public function setProduct(string $product): self
184
    {
185
        $this->product = $product;
186
        return $this;
187
    }
188
189
    public function getSku(): ?string
190
    {
191
        return $this->sku;
192
    }
193
194
    public function setSku(?string $sku): self
195
    {
196
        $this->sku = $sku;
197
        return $this;
198
    }
199
200
    public function getType(): string
201
    {
202
        return $this->type;
203
    }
204
205
    public function setType(string $type): self
206
    {
207
        $this->type = $type;
208
        return $this;
209
    }
210
211
    public function getPrice(): float
212
    {
213
        return $this->price;
214
    }
215
216
    public function setPrice(float $price): self
217
    {
218
        $this->price = $price;
219
        return $this;
220
    }
221
222
    public function getProductCondition(): string
223
    {
224
        return $this->productCondition;
225
    }
226
227
    public function setProductCondition(string $productCondition): self
228
    {
229
        $this->productCondition = $productCondition;
230
        return $this;
231
    }
232
233
    public function isActive(): bool
234
    {
235
        return $this->active;
236
    }
237
238
    public function setActive(bool $active): self
239
    {
240
        $this->active = $active;
241
        return $this;
242
    }
243
244
    public function getCompany(): ?People
245
    {
246
        return $this->company;
247
    }
248
249
    public function setCompany(People $company): self
250
    {
251
        $this->company = $company;
252
        return $this;
253
    }
254
255
    public function getProductUnit(): ProductUnity
256
    {
257
        return $this->productUnit;
258
    }
259
260
    public function setProductUnit(ProductUnity $productUnit): self
261
    {
262
        $this->productUnit = $productUnit;
263
        return $this;
264
    }
265
266
    public function getDescription(): string
267
    {
268
        return $this->description;
269
    }
270
271
    public function setDescription(string $description): self
272
    {
273
        $this->description = $description;
274
        return $this;
275
    }
276
277
    public function getQueue()
278
    {
279
        return $this->queue;
280
    }
281
282
    public function setQueue($queue): self
283
    {
284
        $this->queue = $queue;
285
        return $this;
286
    }
287
288
    public function getProductFiles(): Collection
289
    {
290
        return $this->productFiles;
291
    }
292
293
    public function getProductCategory(): Collection
294
    {
295
        return $this->productCategory;
296
    }
297
298
    public function getFeatured(): bool
299
    {
300
        return $this->featured;
301
    }
302
303
    public function setFeatured(bool $featured): self
304
    {
305
        $this->featured = $featured;
306
        return $this;
307
    }
308
}
309