Completed
Pull Request — master (#141)
by
unknown
11:45
created

Ticket::setPerformanceEvent()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 6
rs 9.4285
1
<?php
2
3
namespace AppBundle\Entity;
4
5
use AppBundle\Traits\TimestampableTrait;
6
use Doctrine\Common\Annotations\Annotation\Enum;
7
use Doctrine\ORM\Mapping as ORM;
8
use JMS\Serializer\Annotation as Serializer;
9
use JMS\Serializer\Annotation\ExclusionPolicy;
10
use JMS\Serializer\Annotation\Expose;
11
use JMS\Serializer\Annotation\Type;
12
use Ramsey\Uuid\Uuid;
13
use Symfony\Component\Validator\Constraints as Assert;
14
15
/**
16
 * @ORM\Table(name="ticket")
17
 * @ORM\Entity(repositoryClass="AppBundle\Repository\TicketRepository")
18
 * @ExclusionPolicy("all")
19
 */
20
class Ticket
21
{
22
    use TimestampableTrait;
23
24
    const STATUS_FREE    = 'free';
25
    const STATUS_BOOKED  = 'booked';
26
    const STATUS_PAID    = 'paid';
27
    const STATUS_OFFLINE = 'offline';
28
29
    /**
30
     * @var Uuid
31
     *
32
     * @ORM\Column(name="id", type="uuid_binary")
33
     * @ORM\Id
34
     * @ORM\GeneratedValue(strategy="UUID")
35
     *
36
     * @Serializer\Groups({"get_ticket", "cget_ticket"})
37
     * @Type("string")
38
     * @Expose
39
     */
40
    private $id;
41
42
    /**
43
     * @var \DateTime
44
     * @Assert\DateTime()
45
     * @ORM\Column(type="datetime", nullable=false)
46
     *
47
     * @Serializer\Groups({"get_ticket", "cget_ticket"})
48
     * @Type("datetime")
49
     * @Expose
50
     */
51
    private $setDate;
52
53
    /**
54
     * @var string
55
     * @Assert\NotBlank()
56
     * @ORM\Column(type="string", length=10,  nullable=false)
57
     *
58
     * @Serializer\Groups({"get_ticket", "cget_ticket"})
59
     * @Type("string")
60
     * @Expose
61
     */
62
    private $setNumber;
63
64
    /**
65
     * @var integer
66
     * @Assert\NotBlank()
67
     * @ORM\Column(type="integer", nullable=false)
68
     *
69
     * @Serializer\Groups({"get_ticket", "cget_ticket"})
70
     * @Type("integer")
71
     * @Expose
72
     */
73
    private $price;
74
75
    /**
76
     * @var Seat
77
     *
78
     * @ORM\ManyToOne(targetEntity="AppBundle\Entity\Seat", fetch="EAGER")
79
     * @ORM\JoinColumn(name="seat_id", referencedColumnName="id", nullable=false)
80
     *
81
     * @Serializer\Groups({"get_ticket", "cget_ticket"})
82
     * @Type("AppBundle\Entity\Seat")
83
     * @Expose()
84
     */
85
    protected $seat;
86
87
    /**
88
     * @var PerformanceEvent
89
     *
90
     * @ORM\ManyToOne(targetEntity="AppBundle\Entity\PerformanceEvent",  fetch="EAGER")
91
     * @ORM\JoinColumn(name="performance_event_id", referencedColumnName="id", nullable=false)
92
     *
93
     * @Serializer\Groups({"get_ticket"})
94
     * @Type("AppBundle\Entity\PerformanceEvent")
95
     * @Expose()
96
     */
97
    protected $performanceEvent;
98
99
    /**
100
     * @var CustomerOrder
101
     *
102
     * @ORM\ManyToOne(targetEntity="CustomerOrder", inversedBy="tickets")
103
     */
104
    protected $customerOrder;
105
106
    /**
107
     * @var Enum
108
     * @Assert\Choice(callback="getStatuses")
109
     * @ORM\Column(name="status", type="string", columnDefinition="enum('free', 'booked', 'paid', 'offline')")
110
     * @Serializer\Groups({"get_ticket", "cget_ticket"})
111
     * @Expose()
112
     */
113
    protected $status;
114
115
    /**
116
     * Ticket constructor.
117
     *
118
     * @param Seat $seat
119
     * @param PerformanceEvent $performanceEvent
120
     */
121
    public function __construct(Seat $seat, PerformanceEvent $performanceEvent)
122
    {
123
        $this->id = Uuid::uuid4();
124
        $this->seat = $seat;
125
        $this->performanceEvent = $performanceEvent;
126
        $this->status = self::STATUS_FREE;
0 ignored issues
show
Documentation Bug introduced by
It seems like self::STATUS_FREE of type string is incompatible with the declared type object<Doctrine\Common\A...ations\Annotation\Enum> of property $status.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
127
    }
128
129
    /**
130
     * @return string
131
     */
132
    public function getId()
133
    {
134
        return $this->id;
135
    }
136
137
    /**
138
     * @return int
139
     */
140
    public function getPrice()
141
    {
142
        return $this->price;
143
    }
144
145
    /**
146
     * @param int $price
147
     */
148
    public function setPrice($price)
149
    {
150
        $this->price = $price;
151
    }
152
153
    /**
154
     * @return Seat
155
     */
156
    public function getSeat()
157
    {
158
        return $this->seat;
159
    }
160
161
    /**
162
     * @return PerformanceEvent
163
     */
164
    public function getPerformanceEvent()
165
    {
166
        return $this->performanceEvent;
167
    }
168
169
    /**
170
     * @return Enum
171
     */
172
    public function getStatus()
173
    {
174
        return $this->status;
175
    }
176
177
    /**
178
     * @param Enum $status
179
     */
180
    public function setStatus($status)
181
    {
182
        $this->status = $status;
183
    }
184
185
    /**
186
     * @return array
187
     */
188
    public static function getStatuses()
189
    {
190
        return [
191
            self::STATUS_FREE,
192
            self::STATUS_BOOKED,
193
            self::STATUS_PAID,
194
            self::STATUS_OFFLINE,
195
        ];
196
    }
197
198
    /**
199
     * @return \DateTime
200
     */
201
    public function getSetDate(): \DateTime
202
    {
203
        return $this->setDate;
204
    }
205
206
    /**
207
     * @param \DateTime $setDate
208
     */
209
    public function setSetDate(\DateTime $setDate)
210
    {
211
        $this->setDate = $setDate;
212
    }
213
214
    /**
215
     * @return string
216
     */
217
    public function getSetNumber(): string
218
    {
219
        return $this->setNumber;
220
    }
221
222
    /**
223
     * @param string $setNumber
224
     */
225
    public function setSetNumber(string $setNumber)
226
    {
227
        $this->setNumber = $setNumber;
228
    }
229
230
    /**
231
     * Set seat
232
     *
233
     * @param \AppBundle\Entity\Seat $seat
234
     *
235
     * @return Ticket
236
     */
237
    public function setSeat(\AppBundle\Entity\Seat $seat)
238
    {
239
        $this->seat = $seat;
240
241
        return $this;
242
    }
243
244
    /**
245
     * Set performanceEvent
246
     *
247
     * @param \AppBundle\Entity\PerformanceEvent $performanceEvent
248
     *
249
     * @return Ticket
250
     */
251
    public function setPerformanceEvent(\AppBundle\Entity\PerformanceEvent $performanceEvent)
252
    {
253
        $this->performanceEvent = $performanceEvent;
254
255
        return $this;
256
    }
257
258
    /**
259
     * Set customerOrder
260
     *
261
     * @param \AppBundle\Entity\CustomerOrder $customerOrder
262
     *
263
     * @return Ticket
264
     */
265
    public function setCustomerOrder(\AppBundle\Entity\CustomerOrder $customerOrder = null)
266
    {
267
        $this->customerOrder = $customerOrder;
268
269
        return $this;
270
    }
271
272
    /**
273
     * Get customerOrder
274
     *
275
     * @return \AppBundle\Entity\CustomerOrder
276
     */
277
    public function getCustomerOrder()
278
    {
279
        return $this->customerOrder;
280
    }
281
}
282