Registration::getDonation()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace BCRM\BackendBundle\Entity\Event;
4
5
use BCRM\BackendBundle\Entity\Payment;
6
use Doctrine\ORM\Mapping as ORM;
7
use Gedmo\Mapping\Annotation as Gedmo;
8
use LiteCQRS\Plugin\CRUD\AggregateResource;
9
use Symfony\Component\Validator\Constraints as Assert;
10
11
12
/**
13
 * Registration
14
 *
15
 * @ORM\Table(name="registration",indexes={@ORM\Index(name="email_idx", columns={"email"})})})
16
 * @ORM\Entity(repositoryClass="BCRM\BackendBundle\Entity\Event\DoctrineRegistrationRepository")
17
 */
18
class Registration extends AggregateResource
19
{
20
    const FOOD_VEGAN = 'vegan';
21
22
    const FOOD_VEGETARIAN = 'vegetarian';
23
24
    const FOOD_DEFAULT = 'default';
25
26
    const TYPE_NORMAL = 1;
27
28
    const TYPE_VIP = 2;
29
30
    const TYPE_SPONSOR = 3;
31
32
    /**
33
     * @var integer
34
     * @ORM\Column(name="id", type="integer")
35
     * @ORM\Id
36
     * @ORM\GeneratedValue(strategy="AUTO")
37
     */
38
    protected $id;
39
40
    /**
41
     * @var string
42
     * @ORM\Column(type="string", nullable=false)
43
     */
44
    protected $uuid;
45
46
    /**
47
     * @Assert\NotBlank()
48
     * @ORM\ManyToOne(targetEntity="BCRM\BackendBundle\Entity\Event\Event", inversedBy="registrations")
49
     * @ORM\JoinColumn(name="event_id", referencedColumnName="id", nullable=false)
50
     * @var Event
51
     */
52
    protected $event;
53
54
    /**
55
     * @var string
56
     * @Assert\NotBlank()
57
     * @ORM\Column(type="text")
58
     */
59
    protected $name;
60
61
    /**
62
     * @var string
63
     * @ORM\Column(type="string", nullable=true)
64
     * @Assert\Regex("/^@[a-zA-Z0-9_]{1,15}$/")
65
     */
66
    protected $twitter;
67
68
    /**
69
     * @var string
70
     * @Assert\Regex(pattern="/^#[^\s]{1,25}( #[^\s]{1,25}){0,2}$/")
71
     * @ORM\Column(type="text", nullable=true)
72
     */
73
    protected $tags;
74
75
    /**
76
     * @var string
77
     * @Assert\NotBlank()
78
     * @Assert\Email()
79
     * @ORM\Column(type="string")
80
     */
81
    protected $email;
82
83
    /**
84
     * @var boolean
85
     * @Assert\Type(type="boolean")
86
     * @ORM\Column(type="boolean")
87
     */
88
    protected $saturday = false;
89
90
    /**
91
     * @var boolean
92
     * @Assert\Type(type="boolean")
93
     * @ORM\Column(type="boolean")
94
     */
95
    protected $sunday = false;
96
97
    /**
98
     * @var string
99
     * @ORM\Column(type="string", nullable=true)
100
     */
101
    protected $food;
102
103
    /**
104
     * @var boolean
105
     * @Assert\Type(type="boolean")
106
     * @ORM\Column(type="boolean")
107
     */
108
    protected $participantList = false;
109
110
    /**
111
     * @var integer
112
     * @Assert\NotBlank()
113
     * @Assert\Type(type="integer")
114
     * @ORM\Column(type="integer")
115
     */
116
    protected $type = self::TYPE_NORMAL;
117
118
    /**
119
     * @var int Donation
120
     * @Assert\Range(min=0)
121
     * @ORM\Column(type="integer", nullable=false)
122
     */
123
    protected $donation = 0;
124
125
    /**
126
     * @var string Payment method
127
     * @ORM\Column(name="payment_method", type="string", nullable=true)
128
     * @Assert\Choice(choices={"barzahlen.de", "paypal"})
129
     */
130
    protected $paymentMethod;
131
132
    /**
133
     * @ORM\ManyToOne(targetEntity="BCRM\BackendBundle\Entity\Payment")
134
     * @ORM\JoinColumn(name="payment_id", referencedColumnName="id", nullable=true)
135
     * @var Payment
136
     */
137
    protected $payment;
138
139
    /**
140
     * @ORM\Column(name="payment_notified", type="datetime", nullable=true)
141
     * @var \DateTime
142
     */
143
    protected $paymentNotified;
144
145
    /**
146
     * @Gedmo\Timestampable(on="create")
147
     * @ORM\Column(type="datetime")
148
     * @var \DateTime
149
     */
150
    protected $created;
151
152
    /**
153
     * @Gedmo\Timestampable(on="update")
154
     * @ORM\Column(type="datetime", nullable=true)
155
     * @var \DateTime
156
     */
157
    protected $updated;
158
159
    /**
160
     * Get id
161
     *
162
     * @return integer
163
     */
164
    public function getId()
165
    {
166
        return $this->id;
167
    }
168
169
    /**
170
     * @param string $uuid
171
     */
172
    public function setUuid($uuid)
173
    {
174
        $this->uuid = $uuid;
175
    }
176
177
    /**
178
     * @return string
179
     */
180
    public function getUuid()
181
    {
182
        return $this->uuid;
183
    }
184
185
    /**
186
     * @return string
187
     */
188
    public function getEmail()
189
    {
190
        return $this->email;
191
    }
192
193
    /**
194
     * @param string $email
195
     */
196
    public function setEmail($email)
197
    {
198
        $this->email = strtolower($email);
199
    }
200
201
    /**
202
     * @return string
203
     */
204
    public function getName()
205
    {
206
        return $this->name;
207
    }
208
209
    /**
210
     * @param string $name
211
     */
212
    public function setName($name)
213
    {
214
        $this->name = $name;
215
    }
216
217
    /**
218
     * @return string
219
     */
220 View Code Duplication
    public function __toString()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
221
    {
222
        $str  = $this->email;
223
        $days = array();
224
        if ($this->saturday) {
225
            $days[] = 'SA';
226
        }
227
        if ($this->sunday) {
228
            $days[] = 'SU';
229
        }
230
        $str .= ' (' . join('+', $days) . ')';
231
        return $str;
232
    }
233
234
    /**
235
     * @return boolean
236
     */
237
    public function getSunday()
238
    {
239
        return $this->sunday;
240
    }
241
242
    /**
243
     * @param boolean $sunday
244
     */
245
    public function setSunday($sunday)
246
    {
247
        $this->sunday = (bool)$sunday;
248
    }
249
250
    /**
251
     * @return boolean
252
     */
253
    public function getSaturday()
254
    {
255
        return $this->saturday;
256
    }
257
258
    /**
259
     * @param boolean $saturday
260
     */
261
    public function setSaturday($saturday)
262
    {
263
        $this->saturday = (bool)$saturday;
264
    }
265
266
    /**
267
     * @return string
268
     */
269
    public function getFood()
270
    {
271
        return $this->food;
272
    }
273
274
    /**
275
     * @param string $food
276
     */
277 View Code Duplication
    public function setFood($food)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
278
    {
279
        if (!in_array($food, array(self::FOOD_VEGAN, self::FOOD_VEGETARIAN, self::FOOD_DEFAULT))) {
280
            throw new \InvalidArgumentException("Invalid food");
281
        }
282
        $this->food = $food;
283
    }
284
285
    /**
286
     * @param \BCRM\BackendBundle\Entity\Event\Event $event
287
     */
288
    public function setEvent(Event $event)
289
    {
290
        $this->event = $event;
291
    }
292
293
    /**
294
     * @return Event
295
     */
296
    public function getEvent()
297
    {
298
        return $this->event;
299
    }
300
301
    /**
302
     * @return string
303
     */
304
    public function getTags()
305
    {
306
        return $this->tags;
307
    }
308
309
    /**
310
     * @param string $tags
311
     */
312
    public function setTags($tags)
313
    {
314
        $this->tags = $tags;
315
    }
316
317
    /**
318
     * @param int $type
319
     */
320 View Code Duplication
    public function setType($type)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
321
    {
322
        if (!in_array($type, array(self::TYPE_NORMAL, self::TYPE_VIP, self::TYPE_SPONSOR))) {
323
            throw new \InvalidArgumentException("Invalid type");
324
        }
325
        $this->type = $type;
326
    }
327
328
    /**
329
     * @return int
330
     */
331
    public function getType()
332
    {
333
        return $this->type;
334
    }
335
336
    /**
337
     * @return string|null
338
     */
339
    public function getTwitter()
340
    {
341
        return $this->twitter;
342
    }
343
344
    /**
345
     * @param string|null $twitter
346
     */
347
    public function setTwitter($twitter = null)
348
    {
349
        $this->twitter = $twitter;
350
    }
351
352
    /**
353
     * @return boolean
354
     */
355
    public function isParticipantList()
356
    {
357
        return $this->participantList;
358
    }
359
360
    /**
361
     * @param boolean $participantList
362
     */
363
    public function setParticipantList($participantList)
364
    {
365
        $this->participantList = (bool)$participantList;
366
    }
367
368
    /**
369
     * @return mixed
370
     */
371
    public function getPaymentMethod()
372
    {
373
        return $this->paymentMethod;
374
    }
375
376
    /**
377
     * @param mixed $paymentMethod
378
     */
379
    public function setPaymentMethod($paymentMethod)
380
    {
381
        $this->paymentMethod = $paymentMethod;
382
    }
383
384
    /**
385
     * @return boolean
386
     */
387
    public function isPaid()
388
    {
389
        return $this->payment !== null;
390
    }
391
392
    /**
393
     * @param Payment $payment
394
     */
395
    public function setPayment(Payment $payment)
396
    {
397
        $this->payment = $payment;
398
    }
399
400
    /**
401
     * @return Payment
402
     */
403
    public function getPayment()
404
    {
405
        return $this->payment;
406
    }
407
408
    /**
409
     * @return \DateTime
410
     */
411
    public function getPaymentNotified()
412
    {
413
        return $this->paymentNotified;
414
    }
415
416
    /**
417
     * @return bool
418
     */
419
    public function isPaymentNotified()
420
    {
421
        return $this->paymentNotified !== null;
422
    }
423
424
    /**
425
     * @param \DateTime $paymentNotified
426
     */
427
    public function setPaymentNotified($paymentNotified)
428
    {
429
        $this->paymentNotified = $paymentNotified;
430
    }
431
432
    /**
433
     * @return int
434
     */
435
    public function getDonation()
436
    {
437
        return $this->donation;
438
    }
439
440
    /**
441
     * @param int $donation
442
     */
443
    public function setDonation($donation)
444
    {
445
        $this->donation = $donation;
446
    }
447
}
448