Completed
Pull Request — master (#191)
by Serhii
02:32
created

Performance   A

Complexity

Total Complexity 34

Size/Duplication

Total Lines 493
Duplicated Lines 0 %

Coupling/Cohesion

Components 5
Dependencies 7

Test Coverage

Coverage 50.56%

Importance

Changes 0
Metric Value
wmc 34
lcom 5
cbo 7
dl 0
loc 493
ccs 45
cts 89
cp 0.5056
rs 9.68
c 0
b 0
f 0
1
<?php
2
3
namespace App\Entity;
4
5
use App\Model\LinksTrait;
6
use Doctrine\Common\Collections\ArrayCollection;
7
use Doctrine\Common\Collections\Collection;
8
use Doctrine\ORM\Mapping as ORM;
9
use Gedmo\Mapping\Annotation as Gedmo;
10
use Gedmo\Blameable\Traits\BlameableEntity;
11
use JMS\Serializer\Annotation as Serializer;
12
use JMS\Serializer\Annotation\SerializedName;
13
use Symfony\Component\Validator\Constraints as Assert;
14
use App\Traits\TimestampableTrait;
15
use App\Traits\DeletedByTrait;
16
use JMS\Serializer\Annotation\ExclusionPolicy;
17
use JMS\Serializer\Annotation\Expose;
18
use JMS\Serializer\Annotation\Type;
19
use JMS\Serializer\Annotation\Groups;
20
use App\Validator\MinSizeSliderImage;
21
use Sonata\TranslationBundle\Model\Gedmo\TranslatableInterface;
22
use Sonata\TranslationBundle\Model\Gedmo\AbstractPersonalTranslatable;
23
use Fresh\DoctrineEnumBundle\Validator\Constraints as DoctrineAssert;
24
use App\Validator\ProducerConstraint;
25
26
/**
27
 * @ORM\Table(name="performances")
28
 * @ORM\Entity(repositoryClass="App\Repository\PerformanceRepository")
29
 * @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false)
30
 * @Gedmo\TranslationEntity(class="App\Entity\Translations\PerformanceTranslation")
31
 * @ExclusionPolicy("all")
32
 * @MinSizeSliderImage()
33
 * @ProducerConstraint()
34
 */
35
class Performance extends AbstractPersonalTranslatable  implements TranslatableInterface
36
{
37
    use TimestampableTrait, LinksTrait, BlameableEntity, DeletedByTrait;
38
39
    /**
40
     * @var integer
41
     *
42
     * @ORM\Column(name="id", type="integer")
43
     * @ORM\Id
44
     * @ORM\GeneratedValue(strategy="AUTO")
45
     */
46
    private $id;
47
48
    /**
49
     * @var string
50
     * @Gedmo\Translatable
51
     * @Assert\NotBlank()
52
     * @ORM\Column(type="string", length=255)
53
     * @Type("string")
54
     * @Expose
55
     * @Groups({"Default", "poster"})
56
     */
57
    private $title;
58
59
    /**
60
     * @var string
61
     * @Gedmo\Translatable
62
     * @ORM\Column(type="text", length=255, nullable=true)
63
     * @Type("string")
64
     * @Expose
65
     */
66
    private $type;
67
68
    /**
69
     * @var string
70
     * @Gedmo\Translatable
71
     * @Assert\NotBlank()
72
     * @ORM\Column(type="text", nullable=true)
73
     * @Type("string")
74
     * @Expose
75
     */
76
    private $description;
77
78
    /**
79
     * @var /Datetime
80
     *
81
     * @Assert\NotBlank()
82
     * @ORM\Column(type="datetime")
83
     * @Type("DateTime")
84
     * @Expose
85
     */
86
    private $premiere;
87
88
    /**
89
     * @var
90
     *
91
     * @ORM\OneToOne(targetEntity="App\Entity\Media", cascade={"persist"})
92
     * @ORM\JoinColumn(name="mainPicture_id", referencedColumnName="id", nullable=true)
93
     * @Assert\Valid()
94
     * @Groups({"Default", "poster"})
95
     */
96
    private $mainPicture;
97
98
    /**
99
     * @var
100
     *
101
     * @ORM\OneToOne(targetEntity="App\Entity\Media", cascade={"persist"})
102
     * @ORM\JoinColumn(name="sliderImage_id", referencedColumnName="id", nullable=true)
103
     * @Groups({"Default", "poster"})
104
     */
105
    private $sliderImage;
106
107
    /**
108
     * @var array
109
     * @Expose
110
     * @Type("array")
111
     * @SerializedName("mainPicture")
112
     * @Groups({"Default", "poster"})
113
     */
114
    public $mainPictureThumbnails;
115
116
    /**
117
     * @var array
118
     * @Expose
119
     * @Type("array")
120
     * @SerializedName("sliderImage")
121
     * @Groups({"Default", "poster"})
122
     */
123
    public $sliderImageThumbnails;
124
125
    /**
126
     * @var PerformanceEvent[]
127
     *
128
     * @ORM\OneToMany(targetEntity="App\Entity\PerformanceEvent", mappedBy="performance", cascade={"persist"}, orphanRemoval=true)
129
     */
130
    private $performanceEvents;
131
132
    /**
133
     * @var Role[]
134
     *
135
     * @ORM\OneToMany(targetEntity="App\Entity\Role", mappedBy="performance", cascade={"persist", "remove"}, orphanRemoval=true)
136
     * @Assert\Valid()
137
     */
138
    private $roles;
139
140
    /**
141
     * @var \App\Entity\GalleryHasMedia
142
     *
143
     * @ORM\ManyToMany(targetEntity="App\Entity\GalleryHasMedia", cascade={"persist"}, fetch="EAGER")
144
     * @ORM\JoinTable(name="performance_galleryHasMedia",
145
     *     joinColumns={@ORM\JoinColumn(name="performance_id",referencedColumnName="id")},
146
     *     inverseJoinColumns={@ORM\JoinColumn(name="galleryHasMedia_id",referencedColumnName="id")}
147
     *     )
148
     */
149
    private $galleryHasMedia;
150
151
    /**
152
     * @var array
153
     * @Expose
154
     * @Type("array")
155
     * @SerializedName("gallery")
156
     */
157
    public $galleryHasMediaThumbnails;
158
159
    /**
160
     * @Gedmo\Slug(fields={"title"})
161
     * @ORM\Column(name="slug", type="string", length=255)
162
     * @Type("string")
163
     * @Expose
164
     * @Groups({"Default", "poster"})
165
     */
166
    private $slug;
167
168
    /**
169
     * @var ArrayCollection
170
     *
171
     * @ORM\OneToMany(
172
     *     targetEntity="App\Entity\Translations\PerformanceTranslation",
173
     *     mappedBy="object",
174
     *     cascade={"persist", "remove"}
175
     * )
176
     */
177
    protected $translations;
178
179
    /**
180
     * @var \App\Entity\History
181 16
     *
182
     * @ORM\ManyToOne(targetEntity="App\Entity\History", inversedBy="performances")
183 16
     * @Assert\Valid()
184 16
     */
185 16
    protected $festival;
186 16
187 16
    /**
188 16
     * @ORM\ManyToMany(targetEntity="App\Entity\RepertoireSeason", inversedBy="performances")
189
     * @Expose
190
     * @Serializer\MaxDepth(1)
191
     * @Assert\Valid()
192
     */
193
    private $seasons;
194
195 7
    /**
196
     * @ORM\Column(type="AudienceEnum", options={"default":"adults"})
197 7
     * @DoctrineAssert\Enum(entity="App\Enum\AudienceEnum")
198
     * @Type("string")
199 7
     * @Expose
200
     * @Assert\Valid()
201
     */
202
    private string $audience;
0 ignored issues
show
Bug introduced by
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected T_STRING, expecting T_FUNCTION or T_CONST
Loading history...
203
204
    /**
205
     * @ORM\Column(type="integer", nullable=false, options={"default":0})
206
     * @Assert\PositiveOrZero
207 3
     * @Type("integer")
208
     * @Groups({"Default", "poster"})
209 3
     * @Expose
210
     */
211
    private int $ageLimit;
212
213
    /**
214
     * @ORM\Column(type="integer", nullable=false)
215
     * @Assert\PositiveOrZero
216
     * @Type("integer")
217 3
     * @Groups({"Default", "poster"})
218
     * @Expose
219 3
     */
220
    private int $durationInMin;
221
222
    /**
223
     * @ORM\ManyToOne(targetEntity="App\Entity\Employee", inversedBy="produce")
224
     * @ORM\JoinColumn(name="producer_id", referencedColumnName="id", onDelete="SET NULL")
225
     * @Expose
226
     */
227
    private ?Employee $producer;
228
229
    /**
230
     * @ORM\Column(type="string", length=255, nullable=true)
231
     * @Expose
232
     */
233
    private ?string $extProducer;
234
235
    /**
236
     * Constructor
237
     */
238
    public function __construct()
239
    {
240 1
        parent::__construct();
241
        $this->performanceEvents = new ArrayCollection();
242 1
        $this->roles = new ArrayCollection();
243
        $this->galleryHasMedia = new ArrayCollection();
244
        $this->seasons = new ArrayCollection();
245
    }
246
247
    /**
248
     * Unset translations
249
     *
250
     * @return Performance
251
     */
252
    public function unsetTranslations()
253
    {
254
        $this->translations = null;
255
256
        return $this;
257
    }
258
259
    /**
260
     * Get id
261
     *
262
     * @return integer
263 3
     */
264
    public function getId()
265 3
    {
266
        return $this->id;
267
    }
268
269
    /**
270
     * Get type
271
     *
272
     * @return string
273
     */
274
    public function getType()
275
    {
276
        return $this->type;
277
    }
278
279
    /**
280
     * Set type
281
     *
282
     * @param  string      $type
283
     * @return Performance
284
     */
285
    public function setType($type)
286 11
    {
287
        $this->type = $type;
288 11
289
        return $this;
290
    }
291
292
    /**
293
     * Get description
294
     *
295
     * @return string
296
     */
297
    public function getDescription()
298
    {
299
        return $this->description;
300
    }
301
302
    /**
303
     * Set description
304
     *
305
     * @param  string      $description
306
     * @return Performance
307
     */
308
    public function setDescription($description)
309 24
    {
310
        $this->description = $description;
311 24
312
        return $this;
313
    }
314
315
    /**
316
     * Get premiere
317
     *
318
     * @return \DateTime
319
     */
320 14
    public function getPremiere()
321
    {
322 14
        return $this->premiere;
323
    }
324 14
325
    /**
326
     * Set premiere
327
     *
328
     * @param  \DateTime   $premiere
329
     * @return Performance
330
     */
331
    public function setPremiere($premiere)
332 5
    {
333
        $this->premiere = $premiere;
334 5
335
        return $this;
336
    }
337
338
    /**
339
     * Get mainPicture
340
     *
341
     * @return \App\Entity\Media
342
     */
343
    public function getMainPicture()
344
    {
345
        return $this->mainPicture;
346
    }
347
348
    /**
349
     * Set mainPicture
350
     *
351
     * @param  \App\Entity\Media $mainPicture
352
     * @return Performance
353
     */
354
    public function setMainPicture(\App\Entity\Media $mainPicture = null)
355
    {
356
        $this->mainPicture = $mainPicture;
357
358
        return $this;
359
    }
360
361
    /**
362
     * Get sliderImage
363
     *
364
     * @return \App\Entity\Media
365
     */
366
    public function getSliderImage()
367
    {
368
        return $this->sliderImage;
369
    }
370
371
    /**
372
     * Set sliderImage
373
     *
374
     * @param  \App\Entity\Media $sliderImage
375
     * @return Performance
376
     */
377
    public function setSliderImage(\App\Entity\Media $sliderImage = null)
378 2
    {
379
        $this->sliderImage = $sliderImage;
380 2
381
        return $this;
382
    }
383
384
    /**
385
     * Get slug
386
     *
387
     * @return string
388
     */
389
    public function getSlug()
390
    {
391
        return $this->slug;
392
    }
393
394
    /**
395
     * Set slug
396
     *
397
     * @param  string      $slug
398
     * @return Performance
399
     */
400
    public function setSlug($slug)
401
    {
402
        $this->slug = $slug;
403
404
        return $this;
405
    }
406
407
    /**
408
     * Add performanceEvent
409
     *
410
     * @param  \App\Entity\PerformanceEvent $performanceEvent
411
     * @return Performance
412 4
     */
413
    public function addPerformanceEvent(\App\Entity\PerformanceEvent $performanceEvent)
414 4
    {
415
        $this->performanceEvents[] = $performanceEvent;
416
417 6
        return $this;
418
    }
419 6
420
    /**
421
     * Remove performanceEvent
422
     *
423
     * @param \App\Entity\PerformanceEvent $performanceEvent
424
     */
425
    public function removePerformanceEvent(\App\Entity\PerformanceEvent $performanceEvent)
426
    {
427 8
        $this->performanceEvents->removeElement($performanceEvent);
428
    }
429 8
430
    /**
431
     * Get performanceEvents
432
     *
433
     * @return \Doctrine\Common\Collections\Collection
434
     */
435
    public function getPerformanceEvents()
436
    {
437
        return $this->performanceEvents;
438
    }
439
440
    /**
441
     * Add role
442
     *
443
     * @param  \App\Entity\Role $role
444
     * @return Performance
445
     */
446
    public function addRole(\App\Entity\Role $role)
447
    {
448
        $role->setPerformance($this);
449
        $this->roles[] = $role;
450
451
        return $this;
452
    }
453
454
    /**
455
     * Remove role
456
     *
457
     * @param \App\Entity\Role $role
458
     */
459
    public function removeRole(\App\Entity\Role $role)
460
    {
461
        $this->roles->removeElement($role);
462
    }
463
464
    /**
465
     * Get roles
466
     *
467
     * @return Role[]|\Doctrine\Common\Collections\Collection
468
     */
469
    public function getRoles()
470
    {
471
        return $this->roles;
472
    }
473 9
474
    public function __toString()
475 9
    {
476
        return $this->getTitle() ?: '';
477
    }
478
479
    /**
480
     * Get title
481 3
     *
482
     * @return string
483 3
     */
484
    public function getTitle()
485
    {
486
        return $this->title;
487
    }
488
489
    /**
490
     * Set title
491
     *
492
     * @param  string      $title
493
     * @return Performance
494
     */
495
    public function setTitle($title)
496
    {
497
        $this->title = $title;
498
499
        return $this;
500 5
    }
501
502 5
    /**
503
     * Add galleryHasMedia
504
     *
505 1
     * @param  \App\Entity\GalleryHasMedia $galleryHasMedia
506
     * @return Performance
507 1
     */
508 1
    public function addGalleryHasMedion(\App\Entity\GalleryHasMedia $galleryHasMedia)
509
    {
510
        $this->galleryHasMedia[] = $galleryHasMedia;
511 1
512
        return $this;
513
    }
514
515
    public function addGalleryHasMedia(\App\Entity\GalleryHasMedia $galleryHasMedia)
516
    {
517
        return $this->addGalleryHasMedion($galleryHasMedia);
518
    }
519
520
    /**
521
     * Remove galleryHasMedia
522
     *
523
     * @param \App\Entity\GalleryHasMedia $galleryHasMedia
524
     */
525
    public function removeGalleryHasMedion(\App\Entity\GalleryHasMedia $galleryHasMedia)
526
    {
527
        $this->galleryHasMedia->removeElement($galleryHasMedia);
528
    }
529
530
    /**
531
     * Get galleryHasMedia
532
     *
533
     * @return \Doctrine\Common\Collections\Collection
534
     */
535
    public function getGalleryHasMedia()
536
    {
537
        return $this->galleryHasMedia;
538
    }
539
540
    /**
541
     * @return Festival
542
     */
543
    public function getFestival()
544
    {
545
        return $this->festival;
546
    }
547
548
    /**
549
     * @param Festival $festival
550
     * @return $this
551
     */
552
    public function setFestival($festival)
553
    {
554
        $this->festival = $festival;
555
556
        return $this;
557
    }
558
559
    /**
560
     * @return Collection|RepertoireSeason[]
561
     */
562
    public function getSeasons(): Collection
563
    {
564
        return $this->seasons;
565
    }
566
567
    public function addSeason(RepertoireSeason $season): self
568
    {
569
        if (!$this->seasons->contains($season)) {
570
            $this->seasons[] = $season;
571
        }
572
573
        return $this;
574
    }
575
576
    public function removeSeason(RepertoireSeason $season): self
577
    {
578
        if ($this->seasons->contains($season)) {
579
            $this->seasons->removeElement($season);
580
        }
581
582
        return $this;
583
    }
584
585
    public function setAudience(string $audience): self
586
    {
587
        $this->audience = $audience;
588
589
        return $this;
590
    }
591
592
    public function getAudience(): string
593
    {
594
        return $this->audience;
595
    }
596
597
    public function getAgeLimit(): int
598
    {
599
        return $this->ageLimit;
600
    }
601
602
    public function setAgeLimit(int $ageLimit): Performance
603
    {
604
        $this->ageLimit = $ageLimit;
605
        return $this;
606
    }
607
608
    public function getDurationInMin(): int
609
    {
610
        return $this->durationInMin;
611
    }
612
613
    public function setDurationInMin(int $durationInMin): Performance
614
    {
615
        $this->durationInMin = $durationInMin;
616
        return $this;
617
    }
618
619
    public function getProducer(): ?Employee
620
    {
621
        return $this->producer;
622
    }
623
624
    public function setProducer(?Employee $producer): Performance
625
    {
626
        $this->producer = $producer;
627
        return $this;
628
    }
629
630
    public function getExtProducer(): ?string
631
    {
632
        return $this->extProducer;
633
    }
634
635
    public function setExtProducer(?string $extProducer): Performance
636
    {
637
        $this->extProducer = $extProducer;
638
        return $this;
639
    }
640
}
641