Completed
Pull Request — master (#380)
by greg
04:29 queued 02:01
created

Game::setMailEntry()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
namespace PlaygroundGame\Entity;
3
4
use DateTime;
5
use Doctrine\ORM\Mapping as ORM;
6
use Gedmo\Mapping\Annotation as Gedmo;
7
use Gedmo\Translatable\Translatable;
8
use Doctrine\ORM\Mapping\HasLifecycleCallbacks;
9
use Doctrine\ORM\Mapping\PrePersist;
10
use Doctrine\ORM\Mapping\PreUpdate;
11
use Doctrine\Common\Collections\ArrayCollection;
12
use Zend\InputFilter\InputFilter;
13
use Zend\InputFilter\Factory as InputFactory;
14
use Zend\InputFilter\InputFilterAwareInterface;
15
use Zend\InputFilter\InputFilterInterface;
16
17
/**
18
 * @ORM\Entity @HasLifecycleCallbacks
19
 *
20
 * @ORM\InheritanceType("JOINED")
21
 * @ORM\DiscriminatorColumn(name="type", type="string")
22
 * @ORM\DiscriminatorMap({"quiz" = "Quiz", "lottery" = "Lottery", "instantwin" =
23
 * "InstantWin", "postvote" = "PostVote", "mission" = "Mission", "tradingcard" = "TradingCard"})
24
 * @ORM\Table(name="game")
25
 * @Gedmo\TranslationEntity(class="PlaygroundGame\Entity\GameTranslation")
26
 */
27
abstract class Game implements InputFilterAwareInterface, Translatable, \JsonSerializable
28
{
29
    // not yet published
30
    const GAME_SCHEDULE  = 'scheduled';
31
    // published and not yet started
32
    const GAME_PUBLISHED  = 'published';
33
    // published and game in progress
34
    const GAME_IN_PROGRESS = 'in progress';
35
    // published and game finished
36
    const GAME_FINISHED   = 'finished';
37
    // closed
38
    const GAME_CLOSED = 'closed';
39
40
    /**
41
     * @Gedmo\Locale
42
     * Used locale to override Translation listener`s locale
43
     * this is not a mapped field of entity metadata, just a simple property
44
     */
45
    protected $locale;
46
47
    protected $inputFilter;
48
49
    /**
50
     * @ORM\Id
51
     * @ORM\Column(type="integer");
52
     * @ORM\GeneratedValue(strategy="AUTO")
53
     */
54
    protected $id;
55
56
    /**
57
     * @ORM\ManyToOne(targetEntity="\PlaygroundPartnership\Entity\Partner")
58
     */
59
    protected $partner;
60
61
    /**
62
     * Implementer ManyToOne(targetEntity="PrizeCategory") avec hydrator sur le formulaire
63
     * @ORM\Column(name="prize_category", type="integer", nullable=true)
64
     */
65
    protected $prizeCategory;
66
67
    /**
68
     * @Gedmo\Translatable
69
     * @ORM\Column(type="string", length=255, nullable=false)
70
     */
71
    protected $title;
72
73
    /**
74
     * @ORM\Column(type="string", length=255, unique=true, nullable=false)
75
     */
76
    protected $identifier;
77
78
    /**
79
     * @ORM\OneToOne(targetEntity="PlayerForm", mappedBy="game", cascade={"persist","remove"})
80
     **/
81
    protected $playerForm;
82
83
    /**
84
     * @ORM\Column(name="main_image", type="string", length=255, nullable=true)
85
     */
86
    protected $mainImage;
87
88
    /**
89
     * @ORM\Column(name="second_image", type="string", length=255, nullable=true)
90
     */
91
    protected $secondImage;
92
93
    /**
94
     * @ORM\Column(name="broadcast_facebook",type="boolean", nullable=true)
95
     */
96
    protected $broadcastFacebook = 0;
97
98
    /**
99
     * @ORM\Column(name="broadcast_platform",type="boolean", nullable=true)
100
     */
101
    protected $broadcastPlatform = 0;
102
103
    /**
104
     * @ORM\Column(type="string", length=255, nullable=true)
105
     */
106
    protected $domain = null;
107
108
    /**
109
     * @ORM\Column(name="broadcast_post_facebook",type="boolean", nullable=true)
110
     */
111
    protected $broadcastPostFacebook = 0;
112
113
    /**
114
     * @ORM\Column(name="push_home",type="boolean", nullable=true)
115
     */
116
    protected $pushHome = 0;
117
118
    /**
119
     * @ORM\Column(name="display_home",type="boolean", nullable=true)
120
     */
121
    protected $displayHome = 0;
122
123
    /**
124
     * @ORM\Column(name="mail_winner",type="boolean", nullable=true)
125
     */
126
    protected $mailWinner = 0;
127
128
    /**
129
     * @Gedmo\Translatable
130
     * @ORM\Column(name="mail_winner_block", type="text", nullable=true)
131
     */
132
    protected $mailWinnerBlock;
133
134
    /**
135
     * @ORM\Column(name="mail_looser",type="boolean", nullable=true)
136
     */
137
    protected $mailLooser = 0;
138
139
    /**
140
     * @ORM\Column(name="mail_entry",type="boolean", nullable=true)
141
     */
142
    protected $mailEntry = 0;
143
144
    /**
145
     * @Gedmo\Translatable
146
     * @ORM\Column(name="mail_looser_block", type="text", nullable=true)
147
     */
148
    protected $mailLooserBlock;
149
150
    /**
151
     * @ORM\Column(type="boolean", nullable=false)
152
     */
153
    protected $active = 0;
154
155
    /**
156
     * @ORM\Column(type="boolean", nullable=false)
157
     */
158
    protected $onInvitation = false;
159
160
    /**
161
     * @ORM\OneToMany(targetEntity="Invitation", mappedBy="game", cascade={"persist","remove"}, orphanRemoval=true)
162
     */
163
    private $invitations;
164
165
    /**
166
     * @ORM\Column(name="anonymous_allowed",type="boolean", nullable=true)
167
     */
168
    protected $anonymousAllowed = 0;
169
    
170
    /**
171
     * This column can be filled in when anonymousAllowed = 1.
172
     * If you put a value, it has to be a field key from playerdata. This key will
173
     * then be used to identify a player (generally 'email')
174
     *
175
     * @ORM\Column(name="anonymous_identifier", type="text", nullable=true)
176
     */
177
    protected $anonymousIdentifier;
178
179
    /**
180
     * @ORM\Column(name="publication_date", type="datetime", nullable=true)
181
     */
182
    protected $publicationDate;
183
184
    /**
185
     * @ORM\Column(name="start_date", type="datetime", nullable=true)
186
     */
187
    protected $startDate;
188
189
    /**
190
     * @ORM\Column(name="end_date", type="datetime", nullable=true)
191
     */
192
    protected $endDate;
193
194
    /**
195
     * @ORM\Column(name="close_date", type="datetime", nullable=true)
196
     */
197
    protected $closeDate;
198
199
    /**
200
     * play limitation. 0 : No limit
201
     *
202
     * @ORM\Column(name="play_limit", type="integer", nullable=false)
203
     */
204
    protected $playLimit = 0;
205
206
    /**
207
     * this field is taken into account only if playLimit<>0.
208
     * if 'always' only $playLimit play by person for this game
209
     * if 'day' only $playLimit play by person a day
210
     * if 'week' only $playLimit play by person a week
211
     * if 'month' only $playLimit play by person a month
212
     * if 'year' only $playLimit play by person a year
213
     *
214
     * @ORM\Column(name="play_limit_scale", type="string", nullable=true)
215
     */
216
    protected $playLimitScale;
217
218
    /**
219
     * this field is used for offering a complementary play entry
220
     * (for example, when the player share the game). The entries
221
     * of type 'bonus' won't be taken into account in the calaculation
222
     * of the authorized playLimit.
223
     *
224
     * if 'none' or null no play bonus is offered
225
     * if 'per_entry' a play bonus is offered for each entry
226
     * if 'one' only one play bonus is offered for every entries of the game
227
     *
228
     * @ORM\Column(name="play_bonus", type="string", nullable=true)
229
     */
230
    protected $playBonus;
231
232
    /**
233
     * @ORM\Column(type="string", length=255, nullable=true)
234
     */
235
    protected $layout;
236
237
    /**
238
     * @ORM\Column(type="string", length=255, nullable=true)
239
     */
240
    protected $stylesheet;
241
242
    /**
243
     * @Gedmo\Translatable
244
     * @ORM\Column(name="welcome_block", type="text", nullable=true)
245
     */
246
    protected $welcomeBlock;
247
248
    /**
249
     * @Gedmo\Translatable
250
     * @ORM\Column(type="text", nullable=true)
251
     */
252
    protected $termsBlock;
253
254
    /**
255
     * @ORM\Column(name="terms_optin", type="boolean", nullable=true)
256
     */
257
    protected $termsOptin = 0;
258
259
    /**
260
     * @Gedmo\Translatable
261
     * @ORM\Column(type="text", nullable=true)
262
     */
263
    protected $conditionsBlock;
264
265
    /**
266
     * @ORM\OneToMany(targetEntity="Prize", mappedBy="game", cascade={"persist","remove"}, orphanRemoval=true)
267
     */
268
    private $prizes;
269
270
    /**
271
     * @ORM\Column(name="fb_page_id", type="string", nullable=true)
272
     */
273
    protected $fbPageId;
274
275
    /**
276
     * @ORM\Column(name="fb_app_id", type="string", nullable=true)
277
     */
278
    protected $fbAppId;
279
280
    /**
281
     * @ORM\Column(name="fb_post_id", type="string", nullable=true)
282
     */
283
    protected $fbPostId;
284
285
    /**
286
     * @Gedmo\Translatable
287
     * @ORM\Column(name="fb_page_tab_title", type="string", length=255, nullable=true)
288
     */
289
    protected $fbPageTabTitle;
290
291
    /**
292
     * @ORM\Column(name="fb_page_tab_image", type="string", length=255, nullable=true)
293
     */
294
    protected $fbPageTabImage;
295
296
    /**
297
     * What is the tab's position. 0 : the highest
298
     *
299
     * @ORM\Column(name="fb_page_tab_position", type="integer", nullable=false)
300
     */
301
    protected $fbPageTabPosition = 0;
302
303
    /**
304
     * @Gedmo\Translatable
305
     * @ORM\Column(name="fb_share_message", type="text", nullable=true)
306
     */
307
    protected $fbShareMessage;
308
309
    /**
310
     * @ORM\Column(name="fb_share_image", type="string", length=255, nullable=true)
311
     */
312
    protected $fbShareImage;
313
314
    /**
315
     * @Gedmo\Translatable
316
     * @ORM\Column(name="fb_request_message", type="text", nullable=true)
317
     */
318
    protected $fbRequestMessage;
319
320
    /**
321
     * @Gedmo\Translatable
322
     * @ORM\Column(name="tw_share_message", type="string", length=255, nullable=true)
323
     */
324
    protected $twShareMessage;
325
326
    /**
327
     * @ORM\Column(name="steps", type="string", length=255, nullable=true)
328
     */
329
    protected $steps = '{"0":"index","1":"play","2":"result","3":"bounce"}';
330
331
    /**
332
     * @ORM\Column(name="steps_views", type="string", length=255, nullable=true)
333
     */
334
    protected $stepsViews = '{"index":{},"play":{},"result":{},"bounce":{}}';
335
336
    /**
337
     * Doctrine accessible value of discriminator (field 'type' is not
338
     * accessible through query)
339
     * And I want to be able to sort game collection based on type
340
     * http://www.doctrine-project.org/jira/browse/DDC-707
341
     * @ORM\Column(name="class_type", type="string", length=255, nullable=false)
342
     */
343
    protected $classType;
344
345
    /**
346
     * @ORM\Column(name="created_at", type="datetime")
347
     */
348
    protected $createdAt;
349
350
    /**
351
     * @ORM\Column(name="updated_at", type="datetime")
352
     */
353
    protected $updatedAt;
354
355
    public function __construct()
356
    {
357
        $this->prizes = new ArrayCollection();
358
        $this->invitations = new ArrayCollection();
359
    }
360
361
    /**
362
     * @PrePersist
363
     */
364
    public function createChrono()
365
    {
366
        $this->createdAt = new \DateTime("now");
367
        $this->updatedAt = new \DateTime("now");
368
    }
369
370
    /**
371
     * @PreUpdate
372
     */
373
    public function updateChrono()
374
    {
375
        $this->updatedAt = new \DateTime("now");
376
    }
377
378
    /**
379
     *
380
     * @return the $id
381
     */
382
    public function getId()
383
    {
384
        return $this->id;
385
    }
386
387
    /**
388
     *
389
     * @param field_type $id
390
     */
391
    public function setId($id)
392
    {
393
        $this->id = $id;
394
395
        return $this;
396
    }
397
398
    /**
399
     * @return the $playerForm
400
     */
401
    public function getPlayerForm()
402
    {
403
        return $this->playerForm;
404
    }
405
406
    /**
407
     * @param field_type $playerForm
408
     */
409
    public function setPlayerForm($playerForm)
410
    {
411
        $this->playerForm = $playerForm;
412
413
        return $this;
414
    }
415
416
    /**
417
     *
418
     * @return the unknown_type
419
     */
420
    public function getPartner()
421
    {
422
        return $this->partner;
423
    }
424
425
    /**
426
     *
427
     * @param unknown_type $partner
428
     */
429
    public function setPartner($partner)
430
    {
431
        $this->partner = $partner;
432
433
        return $this;
434
    }
435
436
    /**
437
     *
438
     * @param unknown_type $prizeCategory
439
     */
440
    public function setPrizeCategory($prizeCategory)
441
    {
442
        $this->prizeCategory = $prizeCategory;
443
444
        return $this;
445
    }
446
447
    /**
448
     *
449
     * @return the unknown_type
450
     */
451
    public function getPrizeCategory()
452
    {
453
        return $this->prizeCategory;
454
    }
455
456
    /**
457
     *
458
     * @return the $title
459
     */
460
    public function getTitle()
461
    {
462
        return $this->title;
463
    }
464
465
    /**
466
     *
467
     * @param field_type $title
468
     */
469
    public function setTitle($title)
470
    {
471
        $this->title = $title;
472
473
        return $this;
474
    }
475
476
    /**
477
     *
478
     * @return the $identifier
479
     */
480
    public function getIdentifier()
481
    {
482
        return $this->identifier;
483
    }
484
485
    /**
486
     *
487
     * @param field_type $identifier
488
     */
489
    public function setIdentifier($identifier)
490
    {
491
        $this->identifier = $identifier;
492
493
        return $this;
494
    }
495
496
    /**
497
     * @return integer $anonymousAllowed
498
     */
499
    public function getAnonymousAllowed()
500
    {
501
        return $this->anonymousAllowed;
502
    }
503
504
    /**
505
     * @param number $anonymousAllowed
506
     */
507
    public function setAnonymousAllowed($anonymousAllowed)
508
    {
509
        $this->anonymousAllowed = $anonymousAllowed;
0 ignored issues
show
Documentation Bug introduced by
It seems like $anonymousAllowed can also be of type double. However, the property $anonymousAllowed is declared as type integer. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
510
511
        return $this;
512
    }
513
514
    /**
515
     * @return the $anonymousIdentifier
516
     */
517
    public function getAnonymousIdentifier()
518
    {
519
        return $this->anonymousIdentifier;
520
    }
521
522
    /**
523
     * @param field_type $anonymousIdentifier
524
     */
525
    public function setAnonymousIdentifier($anonymousIdentifier)
526
    {
527
        $this->anonymousIdentifier = $anonymousIdentifier;
528
    }
529
530
    /**
531
     *
532
     * @return the $mainImage
533
     */
534
    public function getMainImage()
535
    {
536
        return $this->mainImage;
537
    }
538
539
    /**
540
     *
541
     * @param field_type $mainImage
542
     */
543
    public function setMainImage($mainImage)
544
    {
545
        $this->mainImage = $mainImage;
546
547
        return $this;
548
    }
549
550
    /**
551
     *
552
     * @return the $secondImage
553
     */
554
    public function getSecondImage()
555
    {
556
        return $this->secondImage;
557
    }
558
559
    /**
560
     *
561
     * @param field_type $secondImage
562
     */
563
    public function setSecondImage($secondImage)
564
    {
565
        $this->secondImage = $secondImage;
566
567
        return $this;
568
    }
569
570
    /**
571
     *
572
     * @return integer $broadcastFacebook
573
     */
574
    public function getBroadcastFacebook()
575
    {
576
        return $this->broadcastFacebook;
577
    }
578
579
    /**
580
     *
581
     * @param field_type $broadcastFacebook
582
     */
583
    public function setBroadcastFacebook($broadcastFacebook)
584
    {
585
        $this->broadcastFacebook = $broadcastFacebook;
0 ignored issues
show
Documentation Bug introduced by
It seems like $broadcastFacebook of type object<PlaygroundGame\Entity\field_type> is incompatible with the declared type integer of property $broadcastFacebook.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
586
587
        return $this;
588
    }
589
590
    /**
591
     *
592
     * @return integer $domain
593
     */
594
    public function getDomain()
595
    {
596
        return $this->domain;
597
    }
598
599
    /**
600
     *
601
     * @param field_type $domain
602
     */
603
    public function setDomain($domain)
604
    {
605
        $this->domain = $domain;
606
607
        return $this;
608
    }
609
610
    /**
611
     *
612
     * @return integer $broadcastPlatform
613
     */
614
    public function getBroadcastPlatform()
615
    {
616
        return $this->broadcastPlatform;
617
    }
618
619
    /**
620
     *
621
     * @param field_type $broadcastPlatform
622
     */
623
    public function setBroadcastPlatform($broadcastPlatform)
624
    {
625
        $this->broadcastPlatform = $broadcastPlatform;
0 ignored issues
show
Documentation Bug introduced by
It seems like $broadcastPlatform of type object<PlaygroundGame\Entity\field_type> is incompatible with the declared type integer of property $broadcastPlatform.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
626
627
        return $this;
628
    }
629
630
    /**
631
     * @return integer $broadcastPostFacebook
632
     */
633
    public function getBroadcastPostFacebook()
634
    {
635
        return $this->broadcastPostFacebook;
636
    }
637
638
    /**
639
     * @param number $broadcastPostFacebook
640
     */
641
    public function setBroadcastPostFacebook($broadcastPostFacebook)
642
    {
643
        $this->broadcastPostFacebook = $broadcastPostFacebook;
0 ignored issues
show
Documentation Bug introduced by
It seems like $broadcastPostFacebook can also be of type double. However, the property $broadcastPostFacebook is declared as type integer. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
644
645
        return $this;
646
    }
647
648
    /**
649
     * @return integer $mailWinner
650
     */
651
    public function getMailWinner()
652
    {
653
        return $this->mailWinner;
654
    }
655
656
    /**
657
     * @param number $mailWinner
658
     */
659
    public function setMailWinner($mailWinner)
660
    {
661
        $this->mailWinner = $mailWinner;
0 ignored issues
show
Documentation Bug introduced by
It seems like $mailWinner can also be of type double. However, the property $mailWinner is declared as type integer. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
662
    }
663
664
    /**
665
     * @return the $mailWinnerBlock
666
     */
667
    public function getMailWinnerBlock()
668
    {
669
        return $this->mailWinnerBlock;
670
    }
671
672
    /**
673
     * @param field_type $mailWinnerBlock
674
     */
675
    public function setMailWinnerBlock($mailWinnerBlock)
676
    {
677
        $this->mailWinnerBlock = $mailWinnerBlock;
678
    }
679
680
    /**
681
     * @return integer $mailEntry
682
     */
683
    public function getMailEntry()
684
    {
685
        return $this->mailEntry;
686
    }
687
688
    /**
689
     * @param number $mailEntry
690
     */
691
    public function setMailEntry($mailEntry)
692
    {
693
        $this->mailEntry = $mailEntry;
0 ignored issues
show
Documentation Bug introduced by
It seems like $mailEntry can also be of type double. However, the property $mailEntry is declared as type integer. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
694
    }
695
696
    /**
697
     * @return integer $mailLooser
698
     */
699
    public function getMailLooser()
700
    {
701
        return $this->mailLooser;
702
    }
703
704
    /**
705
     * @param number $mailLooser
706
     */
707
    public function setMailLooser($mailLooser)
708
    {
709
        $this->mailLooser = $mailLooser;
0 ignored issues
show
Documentation Bug introduced by
It seems like $mailLooser can also be of type double. However, the property $mailLooser is declared as type integer. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
710
    }
711
712
    /**
713
     * @return the $mailLooserBlock
714
     */
715
    public function getMailLooserBlock()
716
    {
717
        return $this->mailLooserBlock;
718
    }
719
720
    /**
721
     * @param field_type $mailLooserBlock
722
     */
723
    public function setMailLooserBlock($mailLooserBlock)
724
    {
725
        $this->mailLooserBlock = $mailLooserBlock;
726
    }
727
728
    /**
729
     *
730
     * @return integer $pushHome
731
     */
732
    public function getPushHome()
733
    {
734
        return $this->pushHome;
735
    }
736
737
    /**
738
     *
739
     * @param field_type $pushHome
740
     */
741
    public function setPushHome($pushHome)
742
    {
743
        $this->pushHome = $pushHome;
0 ignored issues
show
Documentation Bug introduced by
It seems like $pushHome of type object<PlaygroundGame\Entity\field_type> is incompatible with the declared type integer of property $pushHome.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
744
745
        return $this;
746
    }
747
748
    /**
749
     *
750
     * @return integer $displayHome
751
     */
752
    public function getDisplayHome()
753
    {
754
        return $this->displayHome;
755
    }
756
757
    /**
758
     *
759
     * @param field_type $displayHome
760
     */
761
    public function setDisplayHome($displayHome)
762
    {
763
        $this->displayHome = $displayHome;
0 ignored issues
show
Documentation Bug introduced by
It seems like $displayHome of type object<PlaygroundGame\Entity\field_type> is incompatible with the declared type integer of property $displayHome.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
764
765
        return $this;
766
    }
767
768
    /**
769
     *
770
     * @return the $publicationDate
771
     */
772
    public function getPublicationDate()
773
    {
774
        return $this->publicationDate;
775
    }
776
777
    /**
778
     *
779
     * @param field_type $publicationDate
780
     */
781
    public function setPublicationDate($publicationDate)
782
    {
783
        $this->publicationDate = $publicationDate;
784
785
        return $this;
786
    }
787
788
    /**
789
     *
790
     * @return the $startDate
791
     */
792
    public function getStartDate()
793
    {
794
        return $this->startDate;
795
    }
796
797
    /**
798
     *
799
     * @param field_type $startDate
800
     */
801
    public function setStartDate($startDate)
802
    {
803
        $this->startDate = $startDate;
804
805
        return $this;
806
    }
807
808
    /**
809
     *
810
     * @return the $endDate
811
     */
812
    public function getEndDate()
813
    {
814
        return $this->endDate;
815
    }
816
817
    /**
818
     *
819
     * @param field_type $endDate
820
     */
821
    public function setEndDate($endDate)
822
    {
823
        $this->endDate = $endDate;
824
825
        return $this;
826
    }
827
828
    /**
829
     *
830
     * @return the $closeDate
831
     */
832
    public function getCloseDate()
833
    {
834
        return $this->closeDate;
835
    }
836
837
    /**
838
     *
839
     * @param field_type $closeDate
840
     */
841
    public function setCloseDate($closeDate)
842
    {
843
        $this->closeDate = $closeDate;
844
845
        return $this;
846
    }
847
848
    public function isClosed()
849
    {
850
        $today = new DateTime('now');
851
        if (($this->getCloseDate() && $this->getCloseDate() < $today)
852
            ||
853
            ($this->getPublicationDate() && $this->getPublicationDate() > $today)
854
        ) {
855
            return true;
856
        }
857
858
        return false;
859
    }
860
861
    public function isOpen()
862
    {
863
        return !$this->isClosed();
864
    }
865
866 View Code Duplication
    public function isStarted()
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...
867
    {
868
        $today = new DateTime('now');
869
        if (((!$this->getStartDate() || $this->getStartDate() <= $today))
870
                &&
871
                (!$this->getEndDate() || $this->getEndDate() > $today)
872
        ) {
873
            return true;
874
        }
875
876
        return false;
877
    }
878
879 View Code Duplication
    public function isFinished()
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...
880
    {
881
        $today = new DateTime('now');
882
        if ($this->getEndDate() && $this->getEndDate() <= $today
883
            ||
884
            ($this->getCloseDate() && $this->getCloseDate() <= $today)
885
        ) {
886
            return true;
887
        }
888
889
        return false;
890
    }
891
892
    public function isOnline()
893
    {
894
        if ($this->getActive() && $this->getBroadcastPlatform()) {
895
            return true;
896
        }
897
898
        return false;
899
    }
900
901
    // json array : {"0":"index","1":"play","2":"result","3":"bounce"}
902 View Code Duplication
    public function getStepsArray()
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...
903
    {
904
        $steps = null;
905
906
        if ($this->getSteps()) {
907
            $steps = json_decode($this->getSteps(), true);
908
        }
909
        if (!$steps) {
910
            $steps = array('index','play','result','bounce');
911
        }
912
        return $steps;
913
    }
914
915
916
917 View Code Duplication
    public function getStepsViewsArray()
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...
918
    {
919
        $viewSteps = null;
920
921
        if ($this->getStepsViews()) {
922
            $viewSteps = json_decode($this->getStepsViews(), true);
923
        }
924
        if (!$viewSteps) {
925
            $viewSteps = array('index','play','result','bounce');
926
        }
927
928
        return $viewSteps;
929
    }
930
931
    public function getSteps()
932
    {
933
        return $this->steps;
934
    }
935
936
    public function setSteps($steps)
937
    {
938
        $this->steps = $steps;
939
940
        return $this;
941
    }
942
943
    /**
944
     * This method returns the first step in the game workflow
945
     * @return string
946
     */
947
    public function firstStep()
948
    {
949
        $steps = $this->getStepsArray();
950
951
        return $steps[0];
952
    }
953
954
    /**
955
     * This method returns the last step in the game workflow
956
     * @return string
957
     */
958
    public function lastStep()
959
    {
960
        $steps = $this->getStepsArray();
961
        $nbSteps = count($steps);
962
963
        return $steps[$nbSteps-1];
964
    }
965
966
    /**
967
     * This method returns the previous step in the game workflow
968
     * @param string $step
969
     * @return string
970
     */
971 View Code Duplication
    public function previousStep($step = null)
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...
972
    {
973
        $steps = $this->getStepsArray();
974
        $key = array_search($step, $steps);
975
976
        if (is_int($key) && $key > 0) {
977
            return $steps[$key-1];
978
        }
979
980
        return false;
0 ignored issues
show
Bug Best Practice introduced by
The return type of return false; (false) is incompatible with the return type documented by PlaygroundGame\Entity\Game::previousStep of type string.

If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design.

Let’s take a look at an example:

class Author {
    private $name;

    public function __construct($name) {
        $this->name = $name;
    }

    public function getName() {
        return $this->name;
    }
}

abstract class Post {
    public function getAuthor() {
        return 'Johannes';
    }
}

class BlogPost extends Post {
    public function getAuthor() {
        return new Author('Johannes');
    }
}

class ForumPost extends Post { /* ... */ }

function my_function(Post $post) {
    echo strtoupper($post->getAuthor());
}

Our function my_function expects a Post object, and outputs the author of the post. The base class Post returns a simple string and outputting a simple string will work just fine. However, the child class BlogPost which is a sub-type of Post instead decided to return an object, and is therefore violating the SOLID principles. If a BlogPost were passed to my_function, PHP would not complain, but ultimately fail when executing the strtoupper call in its body.

Loading history...
981
    }
982
983
    /**
984
     * This method returns the next step in the game workflow
985
     * @param string $step
986
     * @return string
987
     */
988 View Code Duplication
    public function nextStep($step = null)
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...
989
    {
990
        $steps = $this->getStepsArray();
991
        $key = array_search($step, $steps);
992
993
        if (is_int($key) && $key < count($steps)-1) {
994
            return $steps[$key+1];
995
        }
996
997
        return false;
0 ignored issues
show
Bug Best Practice introduced by
The return type of return false; (false) is incompatible with the return type documented by PlaygroundGame\Entity\Game::nextStep of type string.

If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design.

Let’s take a look at an example:

class Author {
    private $name;

    public function __construct($name) {
        $this->name = $name;
    }

    public function getName() {
        return $this->name;
    }
}

abstract class Post {
    public function getAuthor() {
        return 'Johannes';
    }
}

class BlogPost extends Post {
    public function getAuthor() {
        return new Author('Johannes');
    }
}

class ForumPost extends Post { /* ... */ }

function my_function(Post $post) {
    echo strtoupper($post->getAuthor());
}

Our function my_function expects a Post object, and outputs the author of the post. The base class Post returns a simple string and outputting a simple string will work just fine. However, the child class BlogPost which is a sub-type of Post instead decided to return an object, and is therefore violating the SOLID principles. If a BlogPost were passed to my_function, PHP would not complain, but ultimately fail when executing the strtoupper call in its body.

Loading history...
998
    }
999
1000
    /**
1001
     * @return string $stepsViews
1002
     */
1003
    public function getStepsViews()
1004
    {
1005
        return $this->stepsViews;
1006
    }
1007
1008
    /**
1009
     * @param string $stepsViews
1010
     */
1011
    public function setStepsViews($stepsViews)
1012
    {
1013
        $this->stepsViews = $stepsViews;
1014
1015
        return $this;
1016
    }
1017
1018
    public function getState()
1019
    {
1020
        if ($this->isOpen()) {
1021
            if (!$this->isStarted() && !$this->isFinished()) {
1022
                return self::GAME_PUBLISHED;
1023
            } elseif ($this->isStarted()) {
1024
                return self::GAME_IN_PROGRESS;
1025
            } elseif ($this->isFinished()) {
1026
                return self::GAME_FINISHED;
1027
            }
1028
        } else {
1029
            if ($this->isFinished()) {
1030
                return self::GAME_CLOSED;
1031
            } else {
1032
                return self::GAME_SCHEDULE;
1033
            }
1034
        }
1035
    }
1036
1037
    /**
1038
     * @return integer unknown_type
1039
     */
1040
    public function getPlayLimit()
1041
    {
1042
        return $this->playLimit;
1043
    }
1044
1045
    /**
1046
     * @param unknown_type $playLimit
1047
     */
1048
    public function setPlayLimit($playLimit)
1049
    {
1050
        $this->playLimit = $playLimit;
0 ignored issues
show
Documentation Bug introduced by
It seems like $playLimit of type object<PlaygroundGame\Entity\unknown_type> is incompatible with the declared type integer of property $playLimit.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
1051
1052
        return $this;
1053
    }
1054
1055
    /**
1056
     * @return the unknown_type
1057
     */
1058
    public function getPlayLimitScale()
1059
    {
1060
        return $this->playLimitScale;
1061
    }
1062
1063
    /**
1064
     * @param unknown_type $playLimitScale
1065
     */
1066
    public function setPlayLimitScale($playLimitScale)
1067
    {
1068
        $this->playLimitScale = $playLimitScale;
1069
1070
        return $this;
1071
    }
1072
1073
    /**
1074
     * @return the unknown_type
1075
     */
1076
    public function getPlayBonus()
1077
    {
1078
        return $this->playBonus;
1079
    }
1080
1081
    /**
1082
     * @param unknown_type $playBonus
1083
     */
1084
    public function setPlayBonus($playBonus)
1085
    {
1086
        $this->playBonus = $playBonus;
1087
1088
        return $this;
1089
    }
1090
1091
    /**
1092
     *
1093
     * @return the $layout
1094
     */
1095
    public function getLayout()
1096
    {
1097
        return $this->layout;
1098
    }
1099
1100
    /**
1101
     *
1102
     * @param field_type $layout
1103
     */
1104
    public function setLayout($layout)
1105
    {
1106
        $this->layout = $layout;
1107
1108
        return $this;
1109
    }
1110
1111
    /**
1112
     *
1113
     * @return the $stylesheet
1114
     */
1115
    public function getStylesheet()
1116
    {
1117
        return $this->stylesheet;
1118
    }
1119
1120
    /**
1121
     *
1122
     * @param field_type $stylesheet
1123
     */
1124
    public function setStylesheet($stylesheet)
1125
    {
1126
        $this->stylesheet = $stylesheet;
1127
1128
        return $this;
1129
    }
1130
1131
    /**
1132
     *
1133
     * @return the $welcomeBlock
1134
     */
1135
    public function getWelcomeBlock()
1136
    {
1137
        return $this->welcomeBlock;
1138
    }
1139
1140
    /**
1141
     *
1142
     * @param field_type $welcomeBlock
1143
     */
1144
    public function setWelcomeBlock($welcomeBlock)
1145
    {
1146
        $this->welcomeBlock = $welcomeBlock;
1147
1148
        return $this;
1149
    }
1150
1151
    /**
1152
     *
1153
     * @return the $termsBlock
1154
     */
1155
    public function getTermsBlock()
1156
    {
1157
        return $this->termsBlock;
1158
    }
1159
1160
    /**
1161
     *
1162
     * @param text $termsBlock
1163
     */
1164
    public function setTermsBlock($termsBlock)
1165
    {
1166
        $this->termsBlock = $termsBlock;
1167
1168
        return $this;
1169
    }
1170
1171
    /**
1172
     *
1173
     * @return integer $termsOptin
1174
     */
1175
    public function getTermsOptin()
1176
    {
1177
        return $this->termsOptin;
1178
    }
1179
1180
    /**
1181
     *
1182
     * @param text $termsOptin
1183
     */
1184
    public function setTermsOptin($termsOptin)
1185
    {
1186
        $this->termsOptin = $termsOptin;
0 ignored issues
show
Documentation Bug introduced by
It seems like $termsOptin of type object<PlaygroundGame\Entity\text> is incompatible with the declared type integer of property $termsOptin.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
1187
1188
        return $this;
1189
    }
1190
1191
    /**
1192
     *
1193
     * @return the $conditionsBlock
1194
     */
1195
    public function getConditionsBlock()
1196
    {
1197
        return $this->conditionsBlock;
1198
    }
1199
1200
    /**
1201
     *
1202
     * @param text $conditionsBlock
1203
     */
1204
    public function setConditionsBlock($conditionsBlock)
1205
    {
1206
        $this->conditionsBlock = $conditionsBlock;
1207
1208
        return $this;
1209
    }
1210
1211
    /**
1212
     * @return ArrayCollection unknown_type
1213
     */
1214
    public function getPrizes()
1215
    {
1216
        return $this->prizes;
1217
    }
1218
1219
    /**
1220
     * frm collection solution
1221
     * @param ArrayCollection $prizes
1222
     */
1223
    public function setPrizes(ArrayCollection $prizes)
1224
    {
1225
        $this->prizes = $prizes;
1226
1227
        return $this;
1228
    }
1229
1230
    public function addPrizes(ArrayCollection $prizes)
1231
    {
1232
        foreach ($prizes as $prize) {
1233
            $prize->setGame($this);
1234
            $this->prizes->add($prize);
1235
        }
1236
    }
1237
1238
1239
    public function removePrizes(ArrayCollection $prizes)
1240
    {
1241
        foreach ($prizes as $prize) {
1242
            $prize->setGame(null);
1243
            $this->prizes->removeElement($prize);
1244
        }
1245
    }
1246
1247
    /**
1248
     * Add a prize to the game.
1249
     *
1250
     * @param Prize $prize
1251
     *
1252
     * @return void
1253
     */
1254
    public function addPrize($prize)
1255
    {
1256
        $this->prizes[] = $prize;
1257
    }
1258
1259
    /**
1260
     *
1261
     * @return string $classType
1262
     */
1263
    public function getClassType()
1264
    {
1265
        return $this->classType;
1266
    }
1267
1268
    /**
1269
     *
1270
     * @param string classType
1271
     * @param string $classType
1272
     */
1273
    public function setClassType($classType)
1274
    {
1275
        $this->classType = $classType;
1276
1277
        return $this;
1278
    }
1279
1280
    /**
1281
     *
1282
     * @return integer unknown_type
1283
     */
1284
    public function getActive()
1285
    {
1286
        return $this->active;
1287
    }
1288
1289
    /**
1290
     *
1291
     * @param unknown_type $active
1292
     */
1293
    public function setActive($active)
1294
    {
1295
        $this->active = $active;
0 ignored issues
show
Documentation Bug introduced by
It seems like $active of type object<PlaygroundGame\Entity\unknown_type> is incompatible with the declared type integer of property $active.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
1296
1297
        return $this;
1298
    }
1299
1300
    /**
1301
     *
1302
     * @return boolean $onInvitation
1303
     */
1304
    public function getOnInvitation()
1305
    {
1306
        return $this->onInvitation;
1307
    }
1308
1309
    /**
1310
     *
1311
     * @param boolean $onInvitation
1312
     */
1313
    public function setOnInvitation($onInvitation)
1314
    {
1315
        $this->onInvitation = $onInvitation;
1316
1317
        return $this;
1318
    }
1319
1320
    /**
1321
     * @return ArrayCollection unknown_type
1322
     */
1323
    public function getInvitations()
1324
    {
1325
        return $this->invitations;
1326
    }
1327
1328
    /**
1329
     * @param ArrayCollection $invitations
1330
     */
1331
    public function setInvitations(ArrayCollection $invitations)
1332
    {
1333
        $this->invitations = $invitations;
1334
1335
        return $this;
1336
    }
1337
1338
    public function addInvitations(ArrayCollection $invitations)
1339
    {
1340
        foreach ($invitations as $invitation) {
1341
            $invitation->setGame($this);
1342
            $this->invitations->add($invitation);
1343
        }
1344
    }
1345
1346
    public function removeInvitations(ArrayCollection $invitations)
1347
    {
1348
        foreach ($invitations as $invitation) {
1349
            $prize->setGame(null);
0 ignored issues
show
Bug introduced by
The variable $prize does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
1350
            $this->invitations->removeElement($invitation);
1351
        }
1352
    }
1353
1354
    /**
1355
     * Add an invitation to the game.
1356
     *
1357
     * @param Invitation $invitation
1358
     *
1359
     * @return void
1360
     */
1361
    public function addInvitation($invitation)
1362
    {
1363
        $this->invitations[] = $invitation;
1364
    }
1365
1366
1367
    /**
1368
     *
1369
     * @return string the Facebook app_id
1370
     */
1371
    public function getFbPageId()
1372
    {
1373
        return $this->fbPageId;
1374
    }
1375
1376
    /**
1377
     *
1378
     * @param string $fbPageId
1379
     */
1380
    public function setFbPageId($fbPageId)
1381
    {
1382
        $this->fbPageId = $fbPageId;
1383
1384
        return $this;
1385
    }
1386
1387
    /**
1388
     *
1389
     * @return string the Facebook app_id
1390
     */
1391
    public function getFbAppId()
1392
    {
1393
        return $this->fbAppId;
1394
    }
1395
1396
    /**
1397
     *
1398
     * @param string $fbAppId
1399
     */
1400
    public function setFbAppId($fbAppId)
1401
    {
1402
        $this->fbAppId = $fbAppId;
1403
1404
        return $this;
1405
    }
1406
1407
    /**
1408
     *
1409
     * @return string the Facebook app_id
1410
     */
1411
    public function getFbPostId()
1412
    {
1413
        return $this->fbPostId;
1414
    }
1415
1416
    /**
1417
     *
1418
     * @param string $fbPostId
1419
     */
1420
    public function setFbPostId($fbPostId)
1421
    {
1422
        $this->fbPostId = $fbPostId;
1423
1424
        return $this;
1425
    }
1426
1427
    /**
1428
     *
1429
     * @return string the Facebook fbPageTabTitle
1430
     */
1431
    public function getFbPageTabTitle()
1432
    {
1433
        return $this->fbPageTabTitle;
1434
    }
1435
1436
    /**
1437
     *
1438
     * @param string $fbPageTabTitle
1439
     */
1440
    public function setFbPageTabTitle($fbPageTabTitle)
1441
    {
1442
        $this->fbPageTabTitle = $fbPageTabTitle;
1443
1444
        return $this;
1445
    }
1446
1447
    /**
1448
     *
1449
     * @return string the Facebook fbPageTabImage
1450
     */
1451
    public function getFbPageTabImage()
1452
    {
1453
        return $this->fbPageTabImage;
1454
    }
1455
1456
    /**
1457
     *
1458
     * @param string $fbPageTabImage
1459
     */
1460
    public function setFbPageTabImage($fbPageTabImage)
1461
    {
1462
        $this->fbPageTabImage = $fbPageTabImage;
1463
1464
        return $this;
1465
    }
1466
1467
    /**
1468
     *
1469
     * @return string the Facebook fbPageTabPosition
1470
     */
1471
    public function getFbPageTabPosition()
1472
    {
1473
        return $this->fbPageTabPosition;
1474
    }
1475
1476
    /**
1477
     *
1478
     * @param string $fbPageTabPosition
1479
     */
1480
    public function setFbPageTabPosition($fbPageTabPosition)
1481
    {
1482
        $this->fbPageTabPosition = $fbPageTabPosition;
0 ignored issues
show
Documentation Bug introduced by
The property $fbPageTabPosition was declared of type integer, but $fbPageTabPosition is of type string. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
1483
1484
        return $this;
1485
    }
1486
1487
    /**
1488
     *
1489
     * @return the unknown_type
1490
     */
1491
    public function getFbShareMessage()
1492
    {
1493
        return $this->fbShareMessage;
1494
    }
1495
1496
    /**
1497
     *
1498
     * @param unknown_type $fbShareMessage
1499
     */
1500
    public function setFbShareMessage($fbShareMessage)
1501
    {
1502
        $this->fbShareMessage = $fbShareMessage;
1503
1504
        return $this;
1505
    }
1506
1507
    /**
1508
     *
1509
     * @return the unknown_type
1510
     */
1511
    public function getFbShareImage()
1512
    {
1513
        return $this->fbShareImage;
1514
    }
1515
1516
    /**
1517
     *
1518
     * @param unknown_type $fbShareImage
1519
     */
1520
    public function setFbShareImage($fbShareImage)
1521
    {
1522
        $this->fbShareImage = $fbShareImage;
1523
1524
        return $this;
1525
    }
1526
1527
    /**
1528
     *
1529
     * @return string unknown_type
1530
     */
1531
    public function getFbRequestMessage()
1532
    {
1533
        return $this->fbRequestMessage;
1534
    }
1535
1536
    /**
1537
     *
1538
     * @param unknown_type $fbRequestMessage
1539
     */
1540
    public function setFbRequestMessage($fbRequestMessage)
1541
    {
1542
        $this->fbRequestMessage = $fbRequestMessage;
1543
1544
        return $this;
1545
    }
1546
1547
    /**
1548
     *
1549
     * @return the unknown_type
1550
     */
1551
    public function getTwShareMessage()
1552
    {
1553
        return $this->twShareMessage;
1554
    }
1555
1556
    /**
1557
     *
1558
     * @param unknown_type $twShareMessage
1559
     */
1560
    public function setTwShareMessage($twShareMessage)
1561
    {
1562
        $this->twShareMessage = $twShareMessage;
1563
1564
        return $this;
1565
    }
1566
1567
    /**
1568
     *
1569
     * @return DateTime $createdAt
1570
     */
1571
    public function getCreatedAt()
1572
    {
1573
        return $this->createdAt;
1574
    }
1575
1576
    /**
1577
     *
1578
     * @param \DateTime $createdAt
1579
     */
1580
    public function setCreatedAt($createdAt)
1581
    {
1582
        $this->createdAt = $createdAt;
1583
1584
        return $this;
1585
    }
1586
1587
    /**
1588
     *
1589
     * @return DateTime $updatedAt
1590
     */
1591
    public function getUpdatedAt()
1592
    {
1593
        return $this->updatedAt;
1594
    }
1595
1596
    /**
1597
     *
1598
     * @param \DateTime $updatedAt
1599
     */
1600
    public function setUpdatedAt($updatedAt)
1601
    {
1602
        $this->updatedAt = $updatedAt;
1603
1604
        return $this;
1605
    }
1606
1607
    /**
1608
     * Convert the object to an array.
1609
     *
1610
     * @return array
1611
     */
1612
    public function getArrayCopy()
1613
    {
1614
        $obj_vars = get_object_vars($this);
1615
1616 View Code Duplication
        if (isset($obj_vars['publicationDate']) && $obj_vars['publicationDate'] !== null) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
1617
            $obj_vars['publicationDate'] = $obj_vars['publicationDate']->format('d/m/Y H:i:s');
1618
        }
1619 View Code Duplication
        if (isset($obj_vars['endDate']) && $obj_vars['endDate'] !== null) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
1620
            $obj_vars['endDate'] = $obj_vars['endDate']->format('d/m/Y H:i:s');
1621
        }
1622 View Code Duplication
        if (isset($obj_vars['startDate']) && $obj_vars['startDate'] !== null) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
1623
            $obj_vars['startDate'] = $obj_vars['startDate']->format('d/m/Y H:i:s');
1624
        }
1625
1626
        return $obj_vars;
1627
    }
1628
1629
    /**
1630
     * Convert the object to json.
1631
     *
1632
     * @return array
1633
     */
1634
    public function jsonSerialize()
1635
    {
1636
        return $this->getArrayCopy();
1637
    }
1638
1639
    /**
1640
     * Populate from an array.
1641
     *
1642
     * @param array $data
1643
     */
1644
    public function populate($data = array())
1645
    {
1646
        if (isset($data['partner']) && $data['partner'] !== null) {
1647
            $this->partner = $data['partner'];
1648
        }
1649
1650
        $this->title = (isset($data['title'])) ? $data['title'] : null;
1651
        $this->type = (isset($data['type']) && $data['type'] !== null) ? $data['type'] : null;
0 ignored issues
show
Bug introduced by
The property type does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
1652
1653
        if (isset($data['mainImage']) && $data['mainImage'] !== null) {
1654
            $this->mainImage = $data['mainImage'];
1655
        }
1656
1657
        if (isset($data['secondImage']) && $data['secondImage'] !== null) {
1658
            $this->secondImage = $data['secondImage'];
1659
        }
1660
1661 View Code Duplication
        if (isset($data['active']) && $data['active'] !== null) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
1662
            $this->active = $data['active'];
1663
        }
1664
1665
        $this->layout           = (isset($data['layout'])) ? $data['layout'] : null;
1666
        $this->stylesheet       = (isset($data['stylesheet'])) ? $data['stylesheet'] : null;
1667
1668
        $this->pushHome         = (isset($data['pushHome']) && $data['pushHome'] !== null) ? $data['pushHome'] : 0;
1669
        $this->displayHome      = (isset($data['displayHome']) && $data['displayHome'] !== null) ?
1670
            $data['displayHome'] :
1671
            0;
1672
        $this->prizeCategory   = (isset($data['prizeCategory'])) ? $data['prizeCategory'] : null;
1673
1674
        $this->publicationDate  = (isset($data['publicationDate']) && $data['publicationDate'] !== null) ?
1675
            DateTime::createFromFormat('d/m/Y', $data['publicationDate']) :
1676
            null;
1677
        $this->endDate         = (isset($data['endDate']) && $data['endDate'] !== null) ?
1678
            DateTime::createFromFormat('d/m/Y', $data['endDate']) :
1679
            null;
1680
        $this->startDate       = (isset($data['startDate']) && $data['startDate'] !== null) ?
1681
            DateTime::createFromFormat('d/m/Y', $data['startDate']) :
1682
            null;
1683
1684
        $this->identifier       = (isset($data['identifier'])) ? $data['identifier'] : null;
1685
        $this->welcomeBlock    = (isset($data['welcomeBlock'])) ? $data['welcomeBlock'] : null;
1686
        $this->termsBlock       = (isset($data['termsBlock'])) ? $data['termsBlock'] : null;
1687
        $this->conditionsBlock  = (isset($data['conditionsBlock'])) ? $data['conditionsBlock'] : null;
1688
1689
        $this->fbShareMessage   = (isset($data['fbShareMessage'])) ? $data['fbShareMessage'] : null;
1690
        $this->fbShareImage     = (isset($data['fbShareImage'])) ? $data['fbShareImage'] : null;
1691
        $this->fbRequestMessage = (isset($data['fbRequestMessage'])) ? $data['fbRequestMessage'] : null;
1692
        $this->twShareMessage   = (isset($data['twShareMessage'])) ? $data['twShareMessage'] : null;
1693
    }
1694
1695
    public function setInputFilter(InputFilterInterface $inputFilter)
1696
    {
1697
        throw new \Exception("Not used");
1698
    }
1699
1700
    public function getInputFilter()
1701
    {
1702
        if (! $this->inputFilter) {
1703
            $inputFilter = new InputFilter();
1704
            $factory = new InputFactory();
1705
1706
            $inputFilter->add($factory->createInput(array(
1707
                'name' => 'id',
1708
                'required' => true,
1709
                'filters' => array(
1710
                    array(
1711
                        'name' => 'Int'
1712
                    )
1713
                )
1714
            )));
1715
1716
            $inputFilter->add($factory->createInput(array(
1717
                'name' => 'partner',
1718
                'required' => false
1719
            )));
1720
1721
            $inputFilter->add($factory->createInput(array(
1722
                'name' => 'fbAppId',
1723
                'required' => false
1724
            )));
1725
1726
            $inputFilter->add($factory->createInput(array(
1727
                'name' => 'fbPageId',
1728
                'required' => false
1729
            )));
1730
1731
            $inputFilter->add($factory->createInput(array(
1732
                'name' => 'fbPostId',
1733
                'required' => false
1734
            )));
1735
1736
            $inputFilter->add($factory->createInput(array(
1737
                'name' => 'prizes',
1738
                'required' => false
1739
            )));
1740
1741
            $inputFilter->add($factory->createInput(array(
1742
                'name' => 'invitations',
1743
                'required' => false
1744
            )));
1745
1746
            $inputFilter->add($factory->createInput(array(
1747
                'name' => 'title',
1748
                'required' => true,
1749
                'filters' => array(
1750
                    array(
1751
                        'name' => 'StripTags'
1752
                    ),
1753
                    array(
1754
                        'name' => 'StringTrim'
1755
                    )
1756
                ),
1757
                'validators' => array(
1758
                    array(
1759
                        'name' => 'StringLength',
1760
                        'options' => array(
1761
                            'encoding' => 'UTF-8',
1762
                            'min' => 5,
1763
                            'max' => 255
1764
                        )
1765
                    )
1766
                )
1767
            )));
1768
1769
            $inputFilter->add($factory->createInput(array(
1770
                'name' => 'publicationDate',
1771
                'required' => false,
1772
            )));
1773
1774
            $inputFilter->add($factory->createInput(array(
1775
                'name' => 'startDate',
1776
                'required' => false,
1777
            )));
1778
1779
            $inputFilter->add($factory->createInput(array(
1780
                'name' => 'endDate',
1781
                'required' => false,
1782
            )));
1783
1784
            $inputFilter->add($factory->createInput(array(
1785
               'name' => 'closeDate',
1786
               'required' => false,
1787
            )));
1788
1789
            $inputFilter->add($factory->createInput(array(
1790
                'name' => 'termsOptin',
1791
                'required' => false,
1792
            )));
1793
1794
            $inputFilter->add($factory->createInput(array(
1795
                'name' => 'identifier',
1796
                'required' => true,
1797
                'filters' => array(
1798
                    array(
1799
                        'name' => 'StripTags'
1800
                    ),
1801
                    array(
1802
                        'name' => 'StringTrim'
1803
                    ),
1804
                    array(
1805
                        'name' => 'PlaygroundCore\Filter\Slugify'
1806
                    )
1807
                ),
1808
                'validators' => array(
1809
                    array(
1810
                        'name' => 'StringLength',
1811
                        'options' => array(
1812
                            'encoding' => 'UTF-8',
1813
                            'min' => 3,
1814
                            'max' => 255
1815
                        )
1816
                    )
1817
                )
1818
            )));
1819
1820
            $inputFilter->add($factory->createInput(array(
1821
                'name'     => 'playLimit',
1822
                'required' => false,
1823
                'validators' => array(
1824
                    array(
1825
                        'name'    => 'Between',
1826
                        'options' => array(
1827
                            'min'      => 0,
1828
                            'max'      => 999999,
1829
                        ),
1830
                    ),
1831
                ),
1832
            )));
1833
1834
            $inputFilter->add($factory->createInput(array(
1835
                'name' => 'playLimitScale',
1836
                'required' => false,
1837
                'validators' => array(
1838
                    array(
1839
                        'name' => 'InArray',
1840
                        'options' => array(
1841
                            'haystack' => array('day', 'week', 'month', 'year', 'always'),
1842
                        ),
1843
                    ),
1844
                ),
1845
            )));
1846
1847
            $inputFilter->add($factory->createInput(array(
1848
                'name' => 'playBonus',
1849
                'required' => false,
1850
                'validators' => array(
1851
                    array(
1852
                        'name' => 'InArray',
1853
                        'options' => array(
1854
                            'haystack' => array('none', 'per_entry', 'one'),
1855
                        ),
1856
                    ),
1857
                ),
1858
            )));
1859
1860
            $inputFilter->add($factory->createInput(array(
1861
                'name' => 'active',
1862
                'required' => true
1863
            )));
1864
1865
            $inputFilter->add($factory->createInput(array(
1866
                'name' => 'onInvitation',
1867
                'required' => false
1868
            )));
1869
1870
            $inputFilter->add($factory->createInput(array(
1871
                'name' => 'displayHome',
1872
                'required' => false
1873
            )));
1874
1875
            $inputFilter->add($factory->createInput(array(
1876
                'name' => 'pushHome',
1877
                'required' => false
1878
            )));
1879
1880
            $inputFilter->add($factory->createInput(array(
1881
                'name' => 'anonymousAllowed',
1882
                'required' => false
1883
            )));
1884
1885
            $inputFilter->add($factory->createInput(array(
1886
                'name' => 'mailWinner',
1887
                'required' => false
1888
            )));
1889
1890
            $inputFilter->add($factory->createInput(array(
1891
                'name' => 'mailLooser',
1892
                'required' => false
1893
            )));
1894
1895
            $inputFilter->add($factory->createInput(array(
1896
                'name' => 'mailEntry',
1897
                'required' => false
1898
            )));
1899
1900
            $inputFilter->add($factory->createInput(array(
1901
                'name' => 'prizeCategory',
1902
                'required' => false,
1903
                'filters' => array(
1904
                    array(
1905
                        'name' => 'Int'
1906
                    )
1907
                )
1908
            )));
1909
1910
            $inputFilter->add($factory->createInput(array(
1911
                'name' => 'fbPageTabTitle',
1912
                'required' => false
1913
            )));
1914
1915
            $inputFilter->add($factory->createInput(array(
1916
                'name' => 'fbPageTabImage',
1917
                'required' => false
1918
            )));
1919
            $inputFilter->add($factory->createInput(array(
1920
                'name' => 'fbPageTabPosition',
1921
                'required' => false
1922
            )));
1923
1924
            $inputFilter->add($factory->createInput(array(
1925
                'name' => 'layout',
1926
                'required' => false,
1927
                'filters' => array(
1928
                    array(
1929
                        'name' => 'StripTags'
1930
                    ),
1931
                    array(
1932
                        'name' => 'StringTrim'
1933
                    )
1934
                ),
1935
                'validators' => array(
1936
                    array(
1937
                        'name' => 'StringLength',
1938
                        'options' => array(
1939
                            'encoding' => 'UTF-8',
1940
                            'min' => 0,
1941
                            'max' => 255
1942
                        )
1943
                    )
1944
                )
1945
            )));
1946
1947
            $inputFilter->add($factory->createInput(array(
1948
                'name' => 'stylesheet',
1949
                'required' => false,
1950
                'filters' => array(
1951
                    array(
1952
                        'name' => 'StripTags'
1953
                    ),
1954
                    array(
1955
                        'name' => 'StringTrim'
1956
                    )
1957
                ),
1958
                'validators' => array(
1959
                    array(
1960
                        'name' => 'StringLength',
1961
                        'options' => array(
1962
                            'encoding' => 'UTF-8',
1963
                            'min' => 0,
1964
                            'max' => 255
1965
                        )
1966
                    )
1967
                )
1968
            )));
1969
1970
            $inputFilter->add($factory->createInput(array(
1971
                'name' => 'fbShareImage',
1972
                'required' => false,
1973
                'filters' => array(
1974
                    array(
1975
                        'name' => 'StripTags'
1976
                    ),
1977
                    array(
1978
                        'name' => 'StringTrim'
1979
                    )
1980
                ),
1981
                'validators' => array(
1982
                    array(
1983
                        'name' => 'StringLength',
1984
                        'options' => array(
1985
                            'encoding' => 'UTF-8',
1986
                            'min' => 1,
1987
                            'max' => 255
1988
                        )
1989
                    )
1990
                )
1991
            )));
1992
1993
            $inputFilter->add($factory->createInput(array(
1994
                    'name' => 'fbShareMessage',
1995
                    'required' => false,
1996
                    'filters' => array(
1997
                            array(
1998
                                    'name' => 'StripTags'
1999
                            ),
2000
                            array(
2001
                                    'name' => 'StringTrim'
2002
                            )
2003
                    ),
2004
                    'validators' => array(
2005
                        array(
2006
                            'name' => 'StringLength',
2007
                            'options' => array(
2008
                                'encoding' => 'UTF-8',
2009
                                'min' => 1,
2010
                                'max' => 500
2011
                             )
2012
                        )
2013
                    )
2014
            )));
2015
2016
            $inputFilter->add($factory->createInput(array(
2017
                'name' => 'fbRequestMessage',
2018
                'required' => false,
2019
                'filters' => array(
2020
                    array(
2021
                        'name' => 'StripTags'
2022
                    ),
2023
                    array(
2024
                        'name' => 'StringTrim'
2025
                    )
2026
                ),
2027
                'validators' => array(
2028
                    array(
2029
                        'name' => 'StringLength',
2030
                        'options' => array(
2031
                            'encoding' => 'UTF-8',
2032
                            'min' => 1,
2033
                            'max' => 500
2034
                        )
2035
                    )
2036
                )
2037
            )));
2038
2039
            $inputFilter->add($factory->createInput(array(
2040
                'name' => 'twShareMessage',
2041
                'required' => false,
2042
                'filters' => array(
2043
                    array(
2044
                        'name' => 'StripTags'
2045
                    ),
2046
                    array(
2047
                        'name' => 'StringTrim'
2048
                    )
2049
                ),
2050
                'validators' => array(
2051
                    array(
2052
                        'name' => 'StringLength',
2053
                        'options' => array(
2054
                            'encoding' => 'UTF-8',
2055
                            'min' => 1,
2056
                            'max' => 255
2057
                        )
2058
                    )
2059
                )
2060
            )));
2061
            
2062
            $inputFilter->add($factory->createInput(array(
2063
                'name' => 'anonymousIdentifier',
2064
                'required' => false,
2065
                'filters' => array(
2066
                    array(
2067
                        'name' => 'StripTags'
2068
                    ),
2069
                    array(
2070
                        'name' => 'StringTrim'
2071
                    )
2072
                ),
2073
                'validators' => array(
2074
                    array(
2075
                        'name' => 'StringLength',
2076
                        'options' => array(
2077
                            'encoding' => 'UTF-8',
2078
                            'min' => 0,
2079
                            'max' => 255
2080
                        )
2081
                    )
2082
                )
2083
            )));
2084
2085
            $this->inputFilter = $inputFilter;
2086
        }
2087
2088
        return $this->inputFilter;
2089
    }
2090
2091
    public function setTranslatableLocale($locale)
2092
    {
2093
        $this->locale = $locale;
2094
    }
2095
}
2096