Completed
Pull Request — master (#136)
by
unknown
19:52 queued 08:32
created

PerformanceEvent::setSeriesNumber()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
ccs 0
cts 3
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace AppBundle\Entity;
4
5
use Doctrine\Common\Collections\Collection;
6
use Doctrine\ORM\Mapping as ORM;
7
use Doctrine\Common\Collections\ArrayCollection;
8
use Gedmo\Mapping\Annotation as Gedmo;
9
use Gedmo\Blameable\Traits\BlameableEntity;
10
use JMS\Serializer\Annotation as Serializer;
11
use Symfony\Component\Validator\Constraints as Assert;
12
use AppBundle\Traits\TimestampableTrait;
13
use AppBundle\Traits\DeletedByTrait;
14
use JMS\Serializer\Annotation\ExclusionPolicy;
15
use JMS\Serializer\Annotation\Expose;
16
use JMS\Serializer\Annotation\Type;
17
use JMS\Serializer\Annotation\Accessor;
18
use AppBundle\Validator\TwoPerformanceEventsPerDay;
19
use Sonata\TranslationBundle\Model\Gedmo\TranslatableInterface;
20
use Sonata\TranslationBundle\Model\Gedmo\AbstractPersonalTranslatable;
21
22
/**
23
 * @ORM\Table(name="performance_schedule")
24
 * @ORM\Entity(repositoryClass="AppBundle\Repository\PerformanceEventRepository")
25
 * @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false)
26
 * @ExclusionPolicy("all")
27
 * @Gedmo\TranslationEntity(class="AppBundle\Entity\Translations\PerformanceEventTranslation")
28
 * @TwoPerformanceEventsPerDay()
29
 */
30
class PerformanceEvent extends AbstractPersonalTranslatable implements TranslatableInterface
31
{
32
    use TimestampableTrait, BlameableEntity, DeletedByTrait;
33
34
    /**
35
     * @var integer
36
     *
37
     * @ORM\Column(name="id", type="integer")
38
     * @ORM\Id
39
     * @ORM\GeneratedValue(strategy="AUTO")
40
     *
41
     * @Serializer\Groups({"get_ticket"})
42
     * @Type("integer")
43
     * @Expose
44
     */
45
    private $id;
46
47
    /**
48
     * @var Performance
49
     *
50
     * @ORM\ManyToOne(targetEntity="AppBundle\Entity\Performance", inversedBy="performanceEvents")
51
     *
52
     * @Serializer\Groups({"get_ticket"})
53
     * @Type("AppBundle\Entity\Performance")
54
     * @Expose
55
     */
56
    private $performance;
57
58
    /**
59
     * @var /Datetime
60
     *
61
     * @Assert\NotBlank()
62
     * @ORM\Column(type="datetime")
63
     *
64
     * @Serializer\Groups({"get_ticket"})
65
     * @Type("DateTime")
66
     * @Expose
67
     */
68
    private $dateTime;
69
70
    /**
71
     * @var Venue
72
     *
73
     * @ORM\ManyToOne(targetEntity="AppBundle\Entity\Venue", inversedBy="performanceEvents")
74
     *
75
     * @Serializer\Groups({"get_ticket"})
76
     * @Type("AppBundle\Entity\Venue")
77
     * @Expose
78
     */
79
    private $venue;
80
81
    /**
82
     * @var int
83
     *
84
     * @Serializer\Groups({"get_ticket"})
85
     * @Type("integer")
86
     * @Expose
87
     * @Accessor(getter="getYear")
88
     */
89
    private $year;
90
91
    /**
92
     * @var int
93
     *
94
     * @Serializer\Groups({"get_ticket"})
95
     * @Expose
96
     * @Accessor(getter="getMonth")
97
     */
98
    private $month;
99
100
    /**
101
     * @var int
102
     *
103
     * @Serializer\Groups({"get_ticket"})
104
     * @Expose
105
     * @Accessor(getter="getDay")
106
     */
107
    private $day;
108
109
    /**
110
     * @var string
111
     *
112
     * @Serializer\Groups({"get_ticket"})
113
     * @Expose
114
     * @Accessor(getter="getTime")
115
     */
116
    private $time;
117
118
    /**
119
     * @var string
120
     *
121
     * @Serializer\Groups({"get_ticket"})
122
     * @ORM\Column(type="string", length=10,  nullable=true)
123
     * @Assert\Length(max="10", min="3")
124
     * @Type("string")
125
     * @Expose
126
     */
127
    private $seriesNumber;
128
129
    /**
130
     * @var \DateTime
131
     * @Assert\DateTime()
132
     * @ORM\Column(type="datetime", nullable=true)
133
     *
134
     * @Serializer\Groups({"get_ticket"})
135
     * @Type("DateTime")
136
     * @Expose
137
     */
138
    private $seriesDate;
139
140
    /**
141
     * @var boolean
142
     * @ORM\Column(type="boolean", nullable=true, options={"default" : false})
143
     *
144
     * @Serializer\Groups({"get_ticket"})
145
     * @Type("boolean")
146
     * @Expose
147
     */
148
    private $enableSale;
149
150
    /**
151
     * @var Collection
152
     *
153
     * @ORM\ManyToMany(
154
     *     targetEntity="AppBundle\Entity\RowsForSale",
155
     *     inversedBy="performanceEvent",
156
     *     cascade={"persist","detach","merge"}
157
     * )
158
     * @Serializer\Groups({"get_ticket"})
159
     * @Type("array")
160
     * @Expose
161
     */
162
    protected $rowsForSale;
163
164
    /**
165
     * @var ArrayCollection|Translation[]
166
     *
167
     * @ORM\OneToMany(
168
     *     targetEntity="AppBundle\Entity\Translations\PerformanceEventTranslation",
169
     *     mappedBy="object",
170
     *     cascade={"persist", "remove"}
171
     * )
172
     */
173
    protected $translations;
174
175
    /**
176
     * @var ArrayCollection|PriceCategory[]
177
     *
178
     * @Assert\Valid
179
     * @ORM\OneToMany(
180
     *     targetEntity="AppBundle\Entity\PriceCategory",
181
     *     mappedBy="performanceEvent",
182
     *     cascade={"persist"},
183
     *     orphanRemoval=true
184
     * )
185
     */
186
    protected $priceCategories;
187
188 8
    public function __construct()
189
    {
190 8
        parent::__construct();
191 8
        $this->priceCategories = new ArrayCollection();
192 8
        $this->seriesDate = new \DateTime();
193 8
        $this->rowsForSale = new ArrayCollection();
194 8
    }
195
196
    /**
197
     * Unset translations
198
     *
199
     * @return PerformanceEvent
200
     */
201 4
    public function unsetTranslations()
202
    {
203 4
        $this->translations = null;
204
205 4
        return $this;
206
    }
207
208
    /**
209
     * Get id
210
     *
211
     * @return integer
212
     */
213 14
    public function getId()
214
    {
215 14
        return $this->id;
216
    }
217
218
    /**
219
     * Set dateTime
220
     *
221
     * @param  \DateTime        $dateTime
222
     * @return PerformanceEvent
223
     */
224 7
    public function setDateTime($dateTime)
225
    {
226 7
        $this->dateTime = $dateTime;
227
228 7
        return $this;
229
    }
230
231
    /**
232
     * Get dateTime
233
     *
234
     * @return \DateTime
235
     */
236 16
    public function getDateTime()
237
    {
238 16
        return $this->dateTime;
239
    }
240
241
    /**
242
     * Set performance
243
     *
244
     * @param  \AppBundle\Entity\Performance $performance
245
     * @return PerformanceEvent
246
     */
247
    public function setPerformance(\AppBundle\Entity\Performance $performance = null)
248
    {
249
        $this->performance = $performance;
250
251
        return $this;
252
    }
253
254
    /**
255
     * Get performance
256
     *
257
     * @return \AppBundle\Entity\Performance
258
     */
259 6
    public function getPerformance()
260
    {
261 6
        return $this->performance;
262
    }
263
264 3
    public function __toString()
265
    {
266 3
        if ($this->getDateTime()) {
267 2
            return $this->getDateTime()->format('d-m-Y H:i');
268
        }
269
270 1
        return date("F j, Y, g:i a");
271
    }
272
273
    /**
274
     * @return mixed
275
     */
276 5
    public function getYear()
277
    {
278 5
        return $this->getDateTime()->format('Y');
279
    }
280
281
    /**
282
     * @param mixed $year
283
     */
284
    public function setYear($year)
285
    {
286
        $this->year = $year;
287
    }
288
289
    /**
290
     * @return int
291
     */
292 5
    public function getMonth()
293
    {
294 5
        return $this->getDateTime()->format('n');
295
    }
296
297
    /**
298
     * @param int $month
299
     */
300
    public function setMonth($month)
301
    {
302
        $this->month = $month;
303
    }
304
305
    /**
306
     * @return int
307
     */
308 5
    public function getDay()
309
    {
310 5
        return $this->getDateTime()->format('j');
311
    }
312
313
    /**
314
     * @param int $day
315
     */
316
    public function setDay($day)
317
    {
318
        $this->day = $day;
319
    }
320
321
    /**
322
     * @return string
323
     */
324 5
    public function getTime()
325
    {
326 5
        return $this->getDateTime()->format('G:i');
327
    }
328
329
    /**
330
     * @param string $time
331
     */
332
    public function setTime($time)
333
    {
334
        $this->time = $time;
335
    }
336
337
    /**
338
     * @return Venue
339
     */
340 8
    public function getVenue()
341
    {
342 8
        return $this->venue;
343
    }
344
345
    /**
346
     * @param Venue $venue
347
     * @return PerformanceEvent
348
     */
349
    public function setVenue(Venue $venue)
350
    {
351
        $this->venue = $venue;
352
353
        return $this;
354
    }
355
356
    /**
357
     * @param  PriceCategory $priceCategory
358
     * @return PerformanceEvent
359
     */
360
    public function addPriceCategory(PriceCategory $priceCategory)
361
    {
362
        $this->priceCategories[] = $priceCategory;
363
364
        return $this;
365
    }
366
367
    /**
368
     * @param PriceCategory $priceCategory
369
     */
370
    public function removePriceCategories(PriceCategory $priceCategory)
371
    {
372
        $this->priceCategories->removeElement($priceCategory);
373
    }
374
375
    /**
376
     * @return Collection
377
     */
378 3
    public function getPriceCategories()
379
    {
380 3
        return $this->priceCategories;
381
    }
382
383
    /**
384
     * @param PriceCategory[]|ArrayCollection $priceCategory
385
     */
386
    public function setPriceCategories($priceCategory)
387
    {
388
        $this->priceCategories[] = $priceCategory;
389
    }
390
391
    /**
392
     * @return string
393
     */
394 1
    public function getSeriesNumber()
395
    {
396 1
        return $this->seriesNumber;
397
    }
398
399
    /**
400
     * @param string $seriesNumber
401
     */
402
    public function setSeriesNumber($seriesNumber)
403
    {
404
        $this->seriesNumber = $seriesNumber;
405
    }
406
407
    /**
408
     * @return \DateTime
409
     */
410 1
    public function getSeriesDate()
411
    {
412 1
        return $this->seriesDate;
413
    }
414
415
    /**
416
     * @param \DateTime $seriesDate
417
     */
418
    public function setSeriesDate($seriesDate)
419
    {
420
        $this->seriesDate = $seriesDate;
421
    }
422
423
    /**
424
     * @return boolean
425
     */
426 1
    public function isEnableSale()
427
    {
428 1
        return $this->enableSale;
429
    }
430
431
    /**
432
     * @param boolean $enableSale
433
     */
434
    public function setEnableSale($enableSale)
435
    {
436
        $this->enableSale = $enableSale;
437
    }
438
439
    /**
440
     * @return Collection
441
     */
442 1
    public function getRowsForSale()
443
    {
444 1
        return $this->rowsForSale;
445
    }
446
447
    /**
448
     * @param  RowsForSale $rowsForSale
449
     * @return PerformanceEvent
450
     */
451
    public function addRowsForSale(RowsForSale $rowsForSale)
452
    {
453
        $this->rowsForSale[] = $rowsForSale;
454
455
        return $this;
456
    }
457
458
    /**
459
     * @param RowsForSale $rowsForSale
460
     */
461
    public function removeRowsForSale(RowsForSale $rowsForSale)
462
    {
463
        $this->rowsForSale->removeElement($rowsForSale);
464
    }
465
}
466