OrderProduct::getParentProduct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 3
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
namespace ControleOnline\Entity;
4
5
use Symfony\Component\Serializer\Attribute\Groups;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Serializer\Attribute\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...
6
7
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...
8
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...
9
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...
10
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...
11
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...
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\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...
14
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...
15
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...
16
use ControleOnline\Entity\Order;
17
use ControleOnline\Entity\Product;
0 ignored issues
show
Bug introduced by
The type ControleOnline\Entity\Product 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 ControleOnline\Entity\Inventory;
0 ignored issues
show
Bug introduced by
The type ControleOnline\Entity\Inventory 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 ControleOnline\Entity\ProductGroup;
0 ignored issues
show
Bug introduced by
The type ControleOnline\Entity\ProductGroup 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\Entity\OrderProductQueue;
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...
21
use ControleOnline\Repository\OrderProductRepository;
22
use ControleOnline\Listener\LogListener;
23
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...
24
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...
25
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...
26
use ApiPlatform\Doctrine\Orm\Filter\NumericFilter;
0 ignored issues
show
Bug introduced by
The type ApiPlatform\Doctrine\Orm\Filter\NumericFilter 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...
27
28
#[ORM\Table(name: 'order_product')]
29
#[ORM\EntityListeners([LogListener::class])]
30
#[ORM\Entity(repositoryClass: OrderProductRepository::class)]
31
#[ApiResource(
32
    formats: ['jsonld', 'json', 'html', 'jsonhal', 'csv' => ['text/csv']],
33
    normalizationContext: ['groups' => ['order_product:read']],
34
    denormalizationContext: ['groups' => ['order_product:write']],
35
    operations: [
36
        new GetCollection(security: "is_granted('ROLE_ADMIN') or is_granted('ROLE_CLIENT')"),
37
        new Get(security: "is_granted('ROLE_CLIENT')"),
38
        new Post(security: "is_granted('ROLE_ADMIN') or is_granted('ROLE_CLIENT')"),
39
        new Put(security: "is_granted('ROLE_ADMIN') or is_granted('ROLE_CLIENT')"),
40
        new Delete(security: "is_granted('ROLE_ADMIN') or is_granted('ROLE_CLIENT')")
41
    ]
42
)]
43
#[ApiFilter(OrderFilter::class, properties: ['alterDate' => 'DESC', 'id' => 'ASC', 'product.product' => 'ASC'])]
44
#[ApiFilter(NumericFilter::class, properties: ['order.id'])]
45
#[ApiFilter(SearchFilter::class, properties: [
46
    'id' => 'exact',
47
    'order' => 'exact',
48
    'product' => 'exact',
49
    'product.type' => 'exact',
50
    'inInventory' => 'exact',
51
    'outInventory' => 'exact',
52
    'parentProduct' => 'exact',
53
    'parentProduct.type' => 'exact',
54
    'orderProduct' => 'exact',
55
    'orderProduct.type' => 'exact',
56
    'productGroup' => 'exact',
57
    'productGroup.type' => 'exact'
58
])]
59
#[ApiFilter(ExistsFilter::class, properties: [
60
    'inInventory',
61
    'outInventory',
62
    'parentProduct',
63
    'orderProduct',
64
    'productGroup'
65
])]
66
class OrderProduct
67
{
68
    #[ORM\Id]
69
    #[ORM\GeneratedValue]
70
    #[ORM\Column(type: 'integer')]
71
    #[Groups(['order_product_queue:read', 'order:read', 'order_details:read', 'order:write',  'order_product:write', 'order_product:read'])]
72
    private $id;
73
74
    #[ORM\ManyToOne(targetEntity: Order::class)]
75
    #[ORM\JoinColumn(nullable: false)]
76
    #[Groups(['order_product_queue:read', 'order_product:write', 'order_product:read'])]
77
    private $order;
78
79
    #[ORM\ManyToOne(targetEntity: Product::class)]
80
    #[ORM\JoinColumn(nullable: false)]
81
    #[Groups(['order_product_queue:read', 'order:read', 'order_details:read', 'order:write',  'order_product:write', 'order_product:read'])]
82
    private $product;
83
84
    #[ORM\ManyToOne(targetEntity: Inventory::class)]
85
    #[ORM\JoinColumn(name: 'in_inventory_id', referencedColumnName: 'id', nullable: true)]
86
    #[Groups(['order_product:write', 'order_product:read'])]
87
    private $inInventory;
88
89
    #[ORM\ManyToOne(targetEntity: Inventory::class)]
90
    #[ORM\JoinColumn(name: 'out_inventory_id', referencedColumnName: 'id', nullable: true)]
91
    #[Groups(['order_product:write', 'order_product:read'])]
92
    private $outInventory;
93
94
    #[ORM\ManyToOne(targetEntity: Product::class)]
95
    #[ORM\JoinColumn(name: 'parent_product_id', referencedColumnName: 'id', nullable: true)]
96
    #[Groups(['order_product:write', 'order_product:read'])]
97
    private $parentProduct;
98
99
    #[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'orderProductComponents')]
100
    #[ORM\JoinColumn(name: 'order_product_id', nullable: true)]
101
    #[Groups(['order_product:write', 'order_product:read'])]
102
    private $orderProduct;
103
104
    #[ORM\ManyToOne(targetEntity: ProductGroup::class)]
105
    #[ORM\JoinColumn(nullable: true)]
106
    #[Groups(['order_product:write', 'order_product:read'])]
107
    private $productGroup;
108
109
    #[ORM\OneToMany(targetEntity: self::class, mappedBy: 'orderProduct')]
110
    #[Groups(['order_product:write', 'order_product:read'])]
111
    private $orderProductComponents;
112
113
    #[ORM\OneToMany(targetEntity: OrderProductQueue::class, mappedBy: 'order_product')]
114
    #[Groups(['order_product:read'])]
115
    private $orderProductQueues;
116
117
    #[ORM\Column(type: 'float')]
118
    #[Groups(['order_product_queue:read', 'order:read', 'order_details:read', 'order:write',  'order_product:write', 'order_product:read'])]
119
    private $quantity = 1;
120
121
    #[ORM\Column(type: 'float')]
122
    #[Groups(['order_product_queue:read', 'order:read', 'order_details:read', 'order:write',  'order_product:write', 'order_product:read'])]
123
    private $price = 0;
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
    private $total = 0;
128
129
    public function __construct()
130
    {
131
        $this->orderProductQueues = new ArrayCollection();
132
        $this->orderProductComponents = new ArrayCollection();
133
    }
134
135
    public function getId()
136
    {
137
        return $this->id;
138
    }
139
140
    public function setId($id): self
141
    {
142
        $this->id = $id;
143
        return $this;
144
    }
145
146
    public function getOrder()
147
    {
148
        return $this->order;
149
    }
150
151
    public function setOrder($order): self
152
    {
153
        $this->order = $order;
154
        return $this;
155
    }
156
157
    public function getProduct()
158
    {
159
        return $this->product;
160
    }
161
162
    public function setProduct($product): self
163
    {
164
        $this->product = $product;
165
        return $this;
166
    }
167
168
    public function getInInventory()
169
    {
170
        return $this->inInventory;
171
    }
172
173
    public function setInInventory($inInventory): self
174
    {
175
        $this->inInventory = $inInventory;
176
        return $this;
177
    }
178
179
    public function getOutInventory()
180
    {
181
        return $this->outInventory;
182
    }
183
184
    public function setOutInventory($outInventory): self
185
    {
186
        $this->outInventory = $outInventory;
187
        return $this;
188
    }
189
190
    public function getParentProduct()
191
    {
192
        return $this->parentProduct;
193
    }
194
195
    public function setParentProduct($parentProduct): self
196
    {
197
        $this->parentProduct = $parentProduct;
198
        return $this;
199
    }
200
201
    public function getOrderProduct()
202
    {
203
        return $this->orderProduct;
204
    }
205
206
    public function setOrderProduct(?OrderProduct $orderProduct): self
207
    {
208
        $this->orderProduct = $orderProduct;
209
        return $this;
210
    }
211
212
    public function getProductGroup()
213
    {
214
        return $this->productGroup;
215
    }
216
217
    public function setProductGroup($productGroup): self
218
    {
219
        $this->productGroup = $productGroup;
220
        return $this;
221
    }
222
223
    public function getOrderProductQueues()
224
    {
225
        return $this->orderProductQueues;
226
    }
227
228
    public function addOrderProductQueue(OrderProductQueue $orderProductQueue): self
229
    {
230
        if (!$this->orderProductQueues->contains($orderProductQueue)) {
231
            $this->orderProductQueues[] = $orderProductQueue;
232
            $orderProductQueue->setOrderProduct($this);
233
        }
234
        return $this;
235
    }
236
237
    public function removeOrderProductQueue(OrderProductQueue $orderProductQueue): self
238
    {
239
        if ($this->orderProductQueues->removeElement($orderProductQueue)) {
240
            if ($orderProductQueue->getOrderProduct() === $this) {
241
                $orderProductQueue->setOrderProduct(null);
242
            }
243
        }
244
        return $this;
245
    }
246
247
    public function getOrderProductComponents()
248
    {
249
        return $this->orderProductComponents;
250
    }
251
252
    public function addOrderProductComponent(OrderProduct $orderProductComponent): self
253
    {
254
        if (!$this->orderProductComponents->contains($orderProductComponent)) {
255
            $this->orderProductComponents[] = $orderProductComponent;
256
            $orderProductComponent->setOrderProduct($this);
257
        }
258
        return $this;
259
    }
260
261
    public function removeOrderProductComponent(OrderProduct $orderProductComponent): self
262
    {
263
        if ($this->orderProductComponents->removeElement($orderProductComponent)) {
264
            if ($orderProductComponent->getOrderProduct() === $this) {
265
                $orderProductComponent->setOrderProduct(null);
266
            }
267
        }
268
        return $this;
269
    }
270
271
    public function getQuantity()
272
    {
273
        return $this->quantity;
274
    }
275
276
    public function setQuantity($quantity): self
277
    {
278
        $this->quantity = $quantity;
279
        return $this;
280
    }
281
282
    public function getPrice()
283
    {
284
        return $this->price;
285
    }
286
287
    public function setPrice($price): self
288
    {
289
        $this->price = $price;
290
        return $this;
291
    }
292
293
    public function getTotal()
294
    {
295
        return $this->total;
296
    }
297
298
    public function setTotal($total): self
299
    {
300
        $this->total = $total;
301
        return $this;
302
    }
303
}
304