Completed
Pull Request — master (#139)
by
unknown
16:38 queued 06:45
created

PerformanceEvent::getPerformance()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

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