Completed
Push — master ( 7b2583...39a295 )
by Serhii
17s queued 12s
created

PerformanceEvent::getBuyTicketLink()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace App\Entity;
4
5
use Doctrine\Common\Collections\ArrayCollection;
6
use Doctrine\ORM\Mapping as ORM;
7
use Gedmo\Mapping\Annotation as Gedmo;
8
use Gedmo\Blameable\Traits\BlameableEntity;
9
use Symfony\Component\Validator\Constraints as Assert;
10
use App\Traits\TimestampableTrait;
11
use App\Traits\DeletedByTrait;
12
use JMS\Serializer\Annotation\ExclusionPolicy;
13
use JMS\Serializer\Annotation\Expose;
14
use JMS\Serializer\Annotation\Type;
15
use JMS\Serializer\Annotation\Accessor;
16
use App\Validator\TwoPerformanceEventsPerDay;
17
use Sonata\TranslationBundle\Model\Gedmo\TranslatableInterface;
18
use Sonata\TranslationBundle\Model\Gedmo\AbstractPersonalTranslatable;
19
20
/**
21
 * @ORM\Table(name="performance_schedule")
22
 * @ORM\Entity(repositoryClass="App\Repository\PerformanceEventRepository")
23
 * @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false)
24
 * @ExclusionPolicy("all")
25
 * @Gedmo\TranslationEntity(class="App\Entity\Translations\PerformanceEventTranslation")
26
 * @TwoPerformanceEventsPerDay()
27
 */
28
class PerformanceEvent extends AbstractPersonalTranslatable  implements TranslatableInterface
29
{
30
    use TimestampableTrait, BlameableEntity, DeletedByTrait;
31
32
    const VENUE_PHILHARMONIC = "venue-philharmonic";
33
    const VENUE_KULIC_HOUSE  = "venue-kilic-house";
34
    const VENUE_THEATRE      = "venue-theatre";
35
    const VENUE_SALUT        = 'venue-salut';
36
    const VENUE_PALAC_MOLODI = 'venue-palac_molodi';
37
    const VENUE_CENTER_OF_KIDS_ARTS = 'venue-center_of_kids_arts';
38
    const VENUE_CHERKASY_ART_MUSEUM = 'venue-cherkasy-art-museum';
39
    const VENUE_NATIONS_FRIENDSHIP = 'venue-nations-friendship';
40
41
    public static $venues = [
42
        self::VENUE_PHILHARMONIC => self::VENUE_PHILHARMONIC,
43
        self::VENUE_KULIC_HOUSE  => self::VENUE_KULIC_HOUSE,
44
        self::VENUE_THEATRE      => self::VENUE_THEATRE,
45
        self::VENUE_SALUT        => self::VENUE_SALUT,
46
        self::VENUE_PALAC_MOLODI => self::VENUE_PALAC_MOLODI,
47
        self::VENUE_CENTER_OF_KIDS_ARTS => self::VENUE_CENTER_OF_KIDS_ARTS,
48
        self::VENUE_CHERKASY_ART_MUSEUM => self::VENUE_CHERKASY_ART_MUSEUM,
49
        self::VENUE_NATIONS_FRIENDSHIP => self::VENUE_NATIONS_FRIENDSHIP,
50
    ];
51
52
    /**
53
     * @var integer
54
     *
55
     * @ORM\Column(name="id", type="integer")
56
     * @ORM\Id
57
     * @ORM\GeneratedValue(strategy="AUTO")
58
     * @Type("integer")
59
     * @Expose
60
     */
61
    private $id;
62
63
    /**
64
     * @var Performance
65
     *
66
     * @ORM\ManyToOne(targetEntity="App\Entity\Performance", inversedBy="performanceEvents")
67
     * @Type("App\Entity\Performance")
68
     * @Expose
69
     */
70
    private $performance;
71
72
    /**
73
     * @var /Datetime
74
     *
75
     * @Assert\NotBlank()
76
     * @ORM\Column(type="datetime")
77
     * @Type("DateTime")
78
     * @Expose
79
     */
80
    private $dateTime;
81
82
    /**
83
     * Place where performance happens
84
     * @var string
85
     * @ORM\Column(type="string")
86
     * @Type("string")
87
     * @Expose
88
     */
89
    private $venue;
90
91
    /**
92
     * @var int
93
     *
94
     * @Type("integer")
95
     * @Expose
96
     * @Accessor(getter="getYear")
97
     */
98
    private $year;
99
100
    /**
101
     * @var int
102
     *
103
     * @Expose
104
     * @Accessor(getter="getMonth")
105
     */
106
    private $month;
107
108
    /**
109
     * @var int
110
     *
111
     * @Expose
112
     * @Accessor(getter="getDay")
113
     */
114
    private $day;
115
116
    /**
117
     * @var string
118
     *
119
     * @Expose
120
     * @Accessor(getter="getTime")
121
     */
122
    private $time;
123
124
    /**
125
     * @var string
126
     * @ORM\Column(type="string", nullable=true)
127
     * @Type("string")
128
     * @Expose
129
     */
130
    private $buyTicketLink;
131
132
    /**
133
     * @var ArrayCollection
134
     *
135
     * @ORM\OneToMany(
136
     *     targetEntity="App\Entity\Translations\PerformanceEventTranslation",
137
     *     mappedBy="object",
138
     *     cascade={"persist", "remove"}
139
     * )
140
     */
141
    protected $translations;
142
143
    /**
144
     * Unset translations
145
     *
146
     * @return PerformanceEvent
147
     */
148 4
    public function unsetTranslations()
149
    {
150 4
        $this->translations = null;
151
152 4
        return $this;
153
    }
154
155
    /**
156
     * Get id
157
     *
158
     * @return integer
159
     */
160 10
    public function getId()
161
    {
162 10
        return $this->id;
163
    }
164
165
    /**
166
     * Set dateTime
167
     *
168
     * @param  \DateTime        $dateTime
169
     * @return PerformanceEvent
170
     */
171
    public function setDateTime($dateTime)
172
    {
173
        $this->dateTime = $dateTime;
174
175
        return $this;
176
    }
177
178
    /**
179
     * Get dateTime
180
     *
181
     * @return \DateTime
182
     */
183 15
    public function getDateTime()
184
    {
185 15
        return $this->dateTime;
186
    }
187
188
    /**
189
     * Set performance
190
     *
191
     * @param  \App\Entity\Performance $performance
192
     * @return PerformanceEvent
193
     */
194
    public function setPerformance(\App\Entity\Performance $performance = null)
195
    {
196
        $this->performance = $performance;
197
198
        return $this;
199
    }
200
201
    /**
202
     * Get performance
203
     *
204
     * @return \App\Entity\Performance
205
     */
206 6
    public function getPerformance()
207
    {
208 6
        return $this->performance;
209
    }
210
211 1
    public function __toString()
212
    {
213 1
        if ($this->getDateTime()) {
214 1
            return $this->getDateTime()->format('d-m-Y H:i');
215
        } else {
216
            return date("F j, Y, g:i a");
217
        }
218
    }
219
220
    /**
221
     * @return mixed
222
     */
223 4
    public function getYear()
224
    {
225 4
        return $this->getDateTime()->format('Y');
226
    }
227
228
    /**
229
     * @param mixed $year
230
     */
231
    public function setYear($year)
232
    {
233
        $this->year = $year;
234
    }
235
236
    /**
237
     * @return int
238
     */
239 4
    public function getMonth()
240
    {
241 4
        return $this->getDateTime()->format('n');
242
    }
243
244
    /**
245
     * @param int $month
246
     */
247
    public function setMonth($month)
248
    {
249
        $this->month = $month;
250
    }
251
252
    /**
253
     * @return int
254
     */
255 4
    public function getDay()
256
    {
257 4
        return $this->getDateTime()->format('j');
258
    }
259
260
    /**
261
     * @param int $day
262
     */
263
    public function setDay($day)
264
    {
265
        $this->day = $day;
266
    }
267
268
    /**
269
     * @return string
270
     */
271 4
    public function getTime()
272
    {
273 4
        return $this->getDateTime()->format('G:i');
274
    }
275
276
    /**
277
     * @param string $time
278
     */
279
    public function setTime($time)
280
    {
281
        $this->time = $time;
282
    }
283
284
    /**
285
     * @return string
286
     */
287 7
    public function getVenue()
288
    {
289 7
        return $this->venue;
290
    }
291
292
    /**
293
     * @param string $venue
294
     */
295 4
    public function setVenue($venue)
296
    {
297 4
        $this->venue = $venue;
298 4
    }
299
300 3
    public function getBuyTicketLink(): ?string
301
    {
302 3
        return $this->buyTicketLink;
303
    }
304
305
    public function setBuyTicketLink(?string $buyTicketLink): self
306
    {
307
        $this->buyTicketLink = $buyTicketLink;
308
        return $this;
309
    }
310
}
311