Passed
Push — master ( 7ffb1d...53fac4 )
by Luiz Kim
01:59
created

OrderProduct::getOrder()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
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\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...
20
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...
21
22
/**
23
 *  OrderProduct
24
 *
25
 * @ORM\EntityListeners({App\Listener\LogListener::class})
26
 * @ORM\Table(name="order_product")
27
 * @ORM\Entity(repositoryClass="ControleOnline\Repository\OrderProductRepository")
28
 */
29
30
#[ApiResource(
31
    operations: [
32
        new Get(
33
            security: '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
            validationContext: ['groups' => ['order_product_write']],
41
            denormalizationContext: ['groups' => ['order_product_write']]
42
        ),
43
        new Put(
44
            security: 'is_granted(\'ROLE_ADMIN\') or (is_granted(\'ROLE_CLIENT\'))',
45
            validationContext: ['groups' => ['order_product_write']],
46
            denormalizationContext: ['groups' => ['order_product_write']]
47
        ),
48
    ],
49
    formats: ['jsonld', 'json', 'html', 'jsonhal', 'csv' => ['text/csv']],
50
    normalizationContext: ['groups' => ['order_product_read']],
51
    denormalizationContext: ['groups' => ['order_product_write']]
52
)]
53
#[ApiFilter(filterClass: OrderFilter::class, properties: ['alterDate' => 'DESC'])]
54
55
class OrderProduct
56
{
57
    /**
58
     * @ORM\Id
59
     * @ORM\GeneratedValue
60
     * @ORM\Column(type="integer")
61
     * @Groups({"order_read","order_product_write","order_product_read"})
62
     */
63
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['id' => 'exact'])]
64
    private $id;
65
66
    /**
67
     * @ORM\ManyToOne(targetEntity="ControleOnline\Entity\Order")
68
     * @ORM\JoinColumn(nullable=false)
69
     * @Groups({"order_product_write","order_product_read"})
70
     */
71
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['id' => 'exact'])]
72
    private $order;
73
74
    /**
75
     * @ORM\ManyToOne(targetEntity="ControleOnline\Entity\Product")
76
     * @ORM\JoinColumn(nullable=false)
77
     * @Groups({"order_read","order_product_write","order_product_read"})
78
     */
79
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['id' => 'exact'])]
80
    private $product;
81
82
    /**
83
     * @ORM\Column(type="float")
84
     * @Groups({"order_read","order_product_write","order_product_read"})
85
     */
86
    private $quantity;
87
88
    /**
89
     * @ORM\Column(type="float")
90
     * @Groups({"order_read","order_product_write","order_product_read"})
91
     */
92
    private $price;
93
94
    /**
95
     * @ORM\Column(type="float")
96
     * @Groups({"order_read","order_product_write","order_product_read"})
97
     */
98
    private $total;
99
100
    // Getters and setters
101
102
    /**
103
     * Get the value of id
104
     */
105
    public function getId()
106
    {
107
        return $this->id;
108
    }
109
110
    /**
111
     * Set the value of id
112
     */
113
    public function setId($id): self
114
    {
115
        $this->id = $id;
116
117
        return $this;
118
    }
119
120
    /**
121
     * Get the value of order
122
     */
123
    public function getOrder()
124
    {
125
        return $this->order;
126
    }
127
128
    /**
129
     * Set the value of order
130
     */
131
    public function setOrder($order): self
132
    {
133
        $this->order = $order;
134
135
        return $this;
136
    }
137
138
    /**
139
     * Get the value of product
140
     */
141
    public function getProduct()
142
    {
143
        return $this->product;
144
    }
145
146
    /**
147
     * Set the value of product
148
     */
149
    public function setProduct($product): self
150
    {
151
        $this->product = $product;
152
153
        return $this;
154
    }
155
156
    /**
157
     * Get the value of quantity
158
     */
159
    public function getQuantity()
160
    {
161
        return $this->quantity;
162
    }
163
164
    /**
165
     * Set the value of quantity
166
     */
167
    public function setQuantity($quantity): self
168
    {
169
        $this->quantity = $quantity;
170
171
        return $this;
172
    }
173
174
    /**
175
     * Get the value of price
176
     */
177
    public function getPrice()
178
    {
179
        return $this->price;
180
    }
181
182
    /**
183
     * Set the value of price
184
     */
185
    public function setPrice($price): self
186
    {
187
        $this->price = $price;
188
189
        return $this;
190
    }
191
192
    /**
193
     * Get the value of total
194
     */
195
    public function getTotal()
196
    {
197
        return $this->total;
198
    }
199
200
    /**
201
     * Set the value of total
202
     */
203
    public function setTotal($total): self
204
    {
205
        $this->total = $total;
206
207
        return $this;
208
    }
209
}
210