Completed
Push — develop ( 01c778...da6203 )
by greg
02:37
created

Game::setFbShareImage()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
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
     * @Gedmo\Translatable
141
     * @ORM\Column(name="mail_looser_block", type="text", nullable=true)
142
     */
143
    protected $mailLooserBlock;
144
145
    /**
146
     * @ORM\Column(type="boolean", nullable=false)
147
     */
148
    protected $active = 0;
149
150
    /**
151
     * @ORM\Column(type="boolean", nullable=false)
152
     */
153
    protected $onInvitation = false;
154
155
    /**
156
     * @ORM\OneToMany(targetEntity="Invitation", mappedBy="game", cascade={"persist","remove"}, orphanRemoval=true)
157
     */
158
    private $invitations;
159
160
    /**
161
     * @ORM\Column(name="anonymous_allowed",type="boolean", nullable=true)
162
     */
163
    protected $anonymousAllowed = 0;
164
    
165
    /**
166
     * This column can be filled in when anonymousAllowed = 1.
167
     * If you put a value, it has to be a field key from playerdata. This key will
168
     * then be used to identify a player (generally 'email')
169
     *
170
     * @ORM\Column(name="anonymous_identifier", type="text", nullable=true)
171
     */
172
    protected $anonymousIdentifier;
173
174
    /**
175
     * @ORM\Column(name="publication_date", type="datetime", nullable=true)
176
     */
177
    protected $publicationDate;
178
179
    /**
180
     * @ORM\Column(name="start_date", type="datetime", nullable=true)
181
     */
182
    protected $startDate;
183
184
    /**
185
     * @ORM\Column(name="end_date", type="datetime", nullable=true)
186
     */
187
    protected $endDate;
188
189
    /**
190
     * @ORM\Column(name="close_date", type="datetime", nullable=true)
191
     */
192
    protected $closeDate;
193
194
    /**
195
     * play limitation. 0 : No limit
196
     *
197
     * @ORM\Column(name="play_limit", type="integer", nullable=false)
198
     */
199
    protected $playLimit = 0;
200
201
    /**
202
     * this field is taken into account only if playLimit<>0.
203
     * if 'always' only $playLimit play by person for this game
204
     * if 'day' only $playLimit play by person a day
205
     * if 'week' only $playLimit play by person a week
206
     * if 'month' only $playLimit play by person a month
207
     * if 'year' only $playLimit play by person a year
208
     *
209
     * @ORM\Column(name="play_limit_scale", type="string", nullable=true)
210
     */
211
    protected $playLimitScale;
212
213
    /**
214
     * this field is used for offering a complementary play entry
215
     * (for example, when the player share the game). The entries
216
     * of type 'bonus' won't be taken into account in the calaculation
217
     * of the authorized playLimit.
218
     *
219
     * if 'none' or null no play bonus is offered
220
     * if 'per_entry' a play bonus is offered for each entry
221
     * if 'one' only one play bonus is offered for every entries of the game
222
     *
223
     * @ORM\Column(name="play_bonus", type="string", nullable=true)
224
     */
225
    protected $playBonus;
226
227
    /**
228
     * @ORM\Column(type="string", length=255, nullable=true)
229
     */
230
    protected $layout;
231
232
    /**
233
     * @ORM\Column(type="string", length=255, nullable=true)
234
     */
235
    protected $stylesheet;
236
237
    /**
238
     * @Gedmo\Translatable
239
     * @ORM\Column(name="welcome_block", type="text", nullable=true)
240
     */
241
    protected $welcomeBlock;
242
243
    /**
244
     * @Gedmo\Translatable
245
     * @ORM\Column(type="text", nullable=true)
246
     */
247
    protected $termsBlock;
248
249
    /**
250
     * @ORM\Column(name="terms_optin", type="boolean", nullable=true)
251
     */
252
    protected $termsOptin = 0;
253
254
    /**
255
     * @Gedmo\Translatable
256
     * @ORM\Column(type="text", nullable=true)
257
     */
258
    protected $conditionsBlock;
259
260
    /**
261
     * @ORM\OneToMany(targetEntity="Prize", mappedBy="game", cascade={"persist","remove"}, orphanRemoval=true)
262
     */
263
    private $prizes;
264
265
    /**
266
     * @ORM\Column(name="fb_page_id", type="string", nullable=true)
267
     */
268
    protected $fbPageId;
269
270
    /**
271
     * @ORM\Column(name="fb_app_id", type="string", nullable=true)
272
     */
273
    protected $fbAppId;
274
275
    /**
276
     * @ORM\Column(name="fb_post_id", type="string", nullable=true)
277
     */
278
    protected $fbPostId;
279
280
    /**
281
     * @Gedmo\Translatable
282
     * @ORM\Column(name="fb_page_tab_title", type="string", length=255, nullable=true)
283
     */
284
    protected $fbPageTabTitle;
285
286
    /**
287
     * @ORM\Column(name="fb_page_tab_image", type="string", length=255, nullable=true)
288
     */
289
    protected $fbPageTabImage;
290
291
    /**
292
     * What is the tab's position. 0 : the highest
293
     *
294
     * @ORM\Column(name="fb_page_tab_position", type="integer", nullable=false)
295
     */
296
    protected $fbPageTabPosition = 0;
297
298
    /**
299
     * @Gedmo\Translatable
300
     * @ORM\Column(name="fb_share_message", type="text", nullable=true)
301
     */
302
    protected $fbShareMessage;
303
304
    /**
305
     * @ORM\Column(name="fb_share_image", type="string", length=255, nullable=true)
306
     */
307
    protected $fbShareImage;
308
309
    /**
310
     * @Gedmo\Translatable
311
     * @ORM\Column(name="fb_request_message", type="text", nullable=true)
312
     */
313
    protected $fbRequestMessage;
314
315
    /**
316
     * @Gedmo\Translatable
317
     * @ORM\Column(name="tw_share_message", type="string", length=255, nullable=true)
318
     */
319
    protected $twShareMessage;
320
321
    /**
322
     * @ORM\Column(name="steps", type="string", length=255, nullable=true)
323
     */
324
    protected $steps = '{"0":"index","1":"play","2":"result","3":"bounce"}';
325
326
    /**
327
     * @ORM\Column(name="steps_views", type="string", length=255, nullable=true)
328
     */
329
    protected $stepsViews = '{"index":{},"play":{},"result":{},"bounce":{}}';
330
331
    /**
332
     * Doctrine accessible value of discriminator (field 'type' is not
333
     * accessible through query)
334
     * And I want to be able to sort game collection based on type
335
     * http://www.doctrine-project.org/jira/browse/DDC-707
336
     * @ORM\Column(name="class_type", type="string", length=255, nullable=false)
337
     */
338
    protected $classType;
339
340
    /**
341
     * @ORM\Column(name="created_at", type="datetime")
342
     */
343
    protected $createdAt;
344
345
    /**
346
     * @ORM\Column(name="updated_at", type="datetime")
347
     */
348
    protected $updatedAt;
349
350
    public function __construct()
351
    {
352
        $this->prizes = new ArrayCollection();
353
        $this->invitations = new ArrayCollection();
354
    }
355
356
    /**
357
     * @PrePersist
358
     */
359
    public function createChrono()
360
    {
361
        $this->createdAt = new \DateTime("now");
362
        $this->updatedAt = new \DateTime("now");
363
    }
364
365
    /**
366
     * @PreUpdate
367
     */
368
    public function updateChrono()
369
    {
370
        $this->updatedAt = new \DateTime("now");
371
    }
372
373
    /**
374
     *
375
     * @return the $id
376
     */
377
    public function getId()
378
    {
379
        return $this->id;
380
    }
381
382
    /**
383
     *
384
     * @param field_type $id
385
     */
386
    public function setId($id)
387
    {
388
        $this->id = $id;
389
390
        return $this;
391
    }
392
393
    /**
394
     * @return the $playerForm
395
     */
396
    public function getPlayerForm()
397
    {
398
        return $this->playerForm;
399
    }
400
401
    /**
402
     * @param field_type $playerForm
403
     */
404
    public function setPlayerForm($playerForm)
405
    {
406
        $this->playerForm = $playerForm;
407
408
        return $this;
409
    }
410
411
    /**
412
     *
413
     * @return the unknown_type
414
     */
415
    public function getPartner()
416
    {
417
        return $this->partner;
418
    }
419
420
    /**
421
     *
422
     * @param unknown_type $partner
423
     */
424
    public function setPartner($partner)
425
    {
426
        $this->partner = $partner;
427
428
        return $this;
429
    }
430
431
    /**
432
     *
433
     * @param unknown_type $prizeCategory
434
     */
435
    public function setPrizeCategory($prizeCategory)
436
    {
437
        $this->prizeCategory = $prizeCategory;
438
439
        return $this;
440
    }
441
442
    /**
443
     *
444
     * @return the unknown_type
445
     */
446
    public function getPrizeCategory()
447
    {
448
        return $this->prizeCategory;
449
    }
450
451
    /**
452
     *
453
     * @return the $title
454
     */
455
    public function getTitle()
456
    {
457
        return $this->title;
458
    }
459
460
    /**
461
     *
462
     * @param field_type $title
463
     */
464
    public function setTitle($title)
465
    {
466
        $this->title = $title;
467
468
        return $this;
469
    }
470
471
    /**
472
     *
473
     * @return the $identifier
474
     */
475
    public function getIdentifier()
476
    {
477
        return $this->identifier;
478
    }
479
480
    /**
481
     *
482
     * @param field_type $identifier
483
     */
484
    public function setIdentifier($identifier)
485
    {
486
        $this->identifier = $identifier;
487
488
        return $this;
489
    }
490
491
    /**
492
     * @return integer $anonymousAllowed
493
     */
494
    public function getAnonymousAllowed()
495
    {
496
        return $this->anonymousAllowed;
497
    }
498
499
    /**
500
     * @param number $anonymousAllowed
501
     */
502
    public function setAnonymousAllowed($anonymousAllowed)
503
    {
504
        $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...
505
506
        return $this;
507
    }
508
509
    /**
510
     * @return the $anonymousIdentifier
511
     */
512
    public function getAnonymousIdentifier()
513
    {
514
        return $this->anonymousIdentifier;
515
    }
516
517
    /**
518
     * @param field_type $anonymousIdentifier
519
     */
520
    public function setAnonymousIdentifier($anonymousIdentifier)
521
    {
522
        $this->anonymousIdentifier = $anonymousIdentifier;
523
    }
524
525
    /**
526
     *
527
     * @return the $mainImage
528
     */
529
    public function getMainImage()
530
    {
531
        return $this->mainImage;
532
    }
533
534
    /**
535
     *
536
     * @param field_type $mainImage
537
     */
538
    public function setMainImage($mainImage)
539
    {
540
        $this->mainImage = $mainImage;
541
542
        return $this;
543
    }
544
545
    /**
546
     *
547
     * @return the $secondImage
548
     */
549
    public function getSecondImage()
550
    {
551
        return $this->secondImage;
552
    }
553
554
    /**
555
     *
556
     * @param field_type $secondImage
557
     */
558
    public function setSecondImage($secondImage)
559
    {
560
        $this->secondImage = $secondImage;
561
562
        return $this;
563
    }
564
565
    /**
566
     *
567
     * @return integer $broadcastFacebook
568
     */
569
    public function getBroadcastFacebook()
570
    {
571
        return $this->broadcastFacebook;
572
    }
573
574
    /**
575
     *
576
     * @param field_type $broadcastFacebook
577
     */
578
    public function setBroadcastFacebook($broadcastFacebook)
579
    {
580
        $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...
581
582
        return $this;
583
    }
584
585
    /**
586
     *
587
     * @return integer $domain
588
     */
589
    public function getDomain()
590
    {
591
        return $this->domain;
592
    }
593
594
    /**
595
     *
596
     * @param field_type $domain
597
     */
598
    public function setDomain($domain)
599
    {
600
        $this->domain = $domain;
601
602
        return $this;
603
    }
604
605
    /**
606
     *
607
     * @return integer $broadcastPlatform
608
     */
609
    public function getBroadcastPlatform()
610
    {
611
        return $this->broadcastPlatform;
612
    }
613
614
    /**
615
     *
616
     * @param field_type $broadcastPlatform
617
     */
618
    public function setBroadcastPlatform($broadcastPlatform)
619
    {
620
        $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...
621
622
        return $this;
623
    }
624
625
    /**
626
     * @return integer $broadcastPostFacebook
627
     */
628
    public function getBroadcastPostFacebook()
629
    {
630
        return $this->broadcastPostFacebook;
631
    }
632
633
    /**
634
     * @param number $broadcastPostFacebook
635
     */
636
    public function setBroadcastPostFacebook($broadcastPostFacebook)
637
    {
638
        $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...
639
640
        return $this;
641
    }
642
643
    /**
644
     * @return integer $mailWinner
645
     */
646
    public function getMailWinner()
647
    {
648
        return $this->mailWinner;
649
    }
650
651
    /**
652
     * @param number $mailWinner
653
     */
654
    public function setMailWinner($mailWinner)
655
    {
656
        $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...
657
    }
658
659
    /**
660
     * @return the $mailWinnerBlock
661
     */
662
    public function getMailWinnerBlock()
663
    {
664
        return $this->mailWinnerBlock;
665
    }
666
667
    /**
668
     * @param field_type $mailWinnerBlock
669
     */
670
    public function setMailWinnerBlock($mailWinnerBlock)
671
    {
672
        $this->mailWinnerBlock = $mailWinnerBlock;
673
    }
674
675
    /**
676
     * @return integer $mailLooser
677
     */
678
    public function getMailLooser()
679
    {
680
        return $this->mailLooser;
681
    }
682
683
    /**
684
     * @param number $mailLooser
685
     */
686
    public function setMailLooser($mailLooser)
687
    {
688
        $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...
689
    }
690
691
    /**
692
     * @return the $mailLooserBlock
693
     */
694
    public function getMailLooserBlock()
695
    {
696
        return $this->mailLooserBlock;
697
    }
698
699
    /**
700
     * @param field_type $mailLooserBlock
701
     */
702
    public function setMailLooserBlock($mailLooserBlock)
703
    {
704
        $this->mailLooserBlock = $mailLooserBlock;
705
    }
706
707
    /**
708
     *
709
     * @return integer $pushHome
710
     */
711
    public function getPushHome()
712
    {
713
        return $this->pushHome;
714
    }
715
716
    /**
717
     *
718
     * @param field_type $pushHome
719
     */
720
    public function setPushHome($pushHome)
721
    {
722
        $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...
723
724
        return $this;
725
    }
726
727
    /**
728
     *
729
     * @return integer $displayHome
730
     */
731
    public function getDisplayHome()
732
    {
733
        return $this->displayHome;
734
    }
735
736
    /**
737
     *
738
     * @param field_type $displayHome
739
     */
740
    public function setDisplayHome($displayHome)
741
    {
742
        $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...
743
744
        return $this;
745
    }
746
747
    /**
748
     *
749
     * @return the $publicationDate
750
     */
751
    public function getPublicationDate()
752
    {
753
        return $this->publicationDate;
754
    }
755
756
    /**
757
     *
758
     * @param field_type $publicationDate
759
     */
760
    public function setPublicationDate($publicationDate)
761
    {
762
        $this->publicationDate = $publicationDate;
763
764
        return $this;
765
    }
766
767
    /**
768
     *
769
     * @return the $startDate
770
     */
771
    public function getStartDate()
772
    {
773
        return $this->startDate;
774
    }
775
776
    /**
777
     *
778
     * @param field_type $startDate
779
     */
780
    public function setStartDate($startDate)
781
    {
782
        $this->startDate = $startDate;
783
784
        return $this;
785
    }
786
787
    /**
788
     *
789
     * @return the $endDate
790
     */
791
    public function getEndDate()
792
    {
793
        return $this->endDate;
794
    }
795
796
    /**
797
     *
798
     * @param field_type $endDate
799
     */
800
    public function setEndDate($endDate)
801
    {
802
        $this->endDate = $endDate;
803
804
        return $this;
805
    }
806
807
    /**
808
     *
809
     * @return the $closeDate
810
     */
811
    public function getCloseDate()
812
    {
813
        return $this->closeDate;
814
    }
815
816
    /**
817
     *
818
     * @param field_type $closeDate
819
     */
820
    public function setCloseDate($closeDate)
821
    {
822
        $this->closeDate = $closeDate;
823
824
        return $this;
825
    }
826
827
    public function isClosed()
828
    {
829
        $today = new DateTime('now');
830
        if (($this->getCloseDate() && $this->getCloseDate() < $today)
831
            ||
832
            ($this->getPublicationDate() && $this->getPublicationDate() > $today)
833
        ) {
834
            return true;
835
        }
836
837
        return false;
838
    }
839
840
    public function isOpen()
841
    {
842
        return !$this->isClosed();
843
    }
844
845 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...
846
    {
847
        $today = new DateTime('now');
848
        if (((!$this->getStartDate() || $this->getStartDate() <= $today))
849
                &&
850
                (!$this->getEndDate() || $this->getEndDate() > $today)
851
        ) {
852
            return true;
853
        }
854
855
        return false;
856
    }
857
858 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...
859
    {
860
        $today = new DateTime('now');
861
        if ($this->getEndDate() && $this->getEndDate() <= $today
862
            ||
863
            ($this->getCloseDate() && $this->getCloseDate() <= $today)
864
        ) {
865
            return true;
866
        }
867
868
        return false;
869
    }
870
871
    public function isOnline()
872
    {
873
        if ($this->getActive() && $this->getBroadcastPlatform()) {
874
            return true;
875
        }
876
877
        return false;
878
    }
879
880
    // json array : {"0":"index","1":"play","2":"result","3":"bounce"}
881 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...
882
    {
883
        $steps = null;
884
885
        if ($this->getSteps()) {
886
            $steps = json_decode($this->getSteps(), true);
887
        }
888
        if (!$steps) {
889
            $steps = array('index','play','result','bounce');
890
        }
891
        return $steps;
892
    }
893
894
895
896 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...
897
    {
898
        $viewSteps = null;
899
900
        if ($this->getStepsViews()) {
901
            $viewSteps = json_decode($this->getStepsViews(), true);
902
        }
903
        if (!$viewSteps) {
904
            $viewSteps = array('index','play','result','bounce');
905
        }
906
907
        return $viewSteps;
908
    }
909
910
    public function getSteps()
911
    {
912
        return $this->steps;
913
    }
914
915
    public function setSteps($steps)
916
    {
917
        $this->steps = $steps;
918
919
        return $this;
920
    }
921
922
    /**
923
     * This method returns the first step in the game workflow
924
     * @return string
925
     */
926
    public function firstStep()
927
    {
928
        $steps = $this->getStepsArray();
929
930
        return $steps[0];
931
    }
932
933
    /**
934
     * This method returns the last step in the game workflow
935
     * @return string
936
     */
937
    public function lastStep()
938
    {
939
        $steps = $this->getStepsArray();
940
        $nbSteps = count($steps);
941
942
        return $steps[$nbSteps-1];
943
    }
944
945
    /**
946
     * This method returns the previous step in the game workflow
947
     * @param string $step
948
     * @return string
949
     */
950 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...
951
    {
952
        $steps = $this->getStepsArray();
953
        $key = array_search($step, $steps);
954
955
        if (is_int($key) && $key > 0) {
956
            return $steps[$key-1];
957
        }
958
959
        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...
960
    }
961
962
    /**
963
     * This method returns the next step in the game workflow
964
     * @param string $step
965
     * @return string
966
     */
967 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...
968
    {
969
        $steps = $this->getStepsArray();
970
        $key = array_search($step, $steps);
971
972
        if (is_int($key) && $key < count($steps)-1) {
973
            return $steps[$key+1];
974
        }
975
976
        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...
977
    }
978
979
    /**
980
     * @return string $stepsViews
981
     */
982
    public function getStepsViews()
983
    {
984
        return $this->stepsViews;
985
    }
986
987
    /**
988
     * @param string $stepsViews
989
     */
990
    public function setStepsViews($stepsViews)
991
    {
992
        $this->stepsViews = $stepsViews;
993
994
        return $this;
995
    }
996
997
    public function getState()
998
    {
999
        if ($this->isOpen()) {
1000
            if (!$this->isStarted() && !$this->isFinished()) {
1001
                return self::GAME_PUBLISHED;
1002
            } elseif ($this->isStarted()) {
1003
                return self::GAME_IN_PROGRESS;
1004
            } elseif ($this->isFinished()) {
1005
                return self::GAME_FINISHED;
1006
            }
1007
        } else {
1008
            if ($this->isFinished()) {
1009
                return self::GAME_CLOSED;
1010
            } else {
1011
                return self::GAME_SCHEDULE;
1012
            }
1013
        }
1014
    }
1015
1016
    /**
1017
     * @return integer unknown_type
1018
     */
1019
    public function getPlayLimit()
1020
    {
1021
        return $this->playLimit;
1022
    }
1023
1024
    /**
1025
     * @param unknown_type $playLimit
1026
     */
1027
    public function setPlayLimit($playLimit)
1028
    {
1029
        $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...
1030
1031
        return $this;
1032
    }
1033
1034
    /**
1035
     * @return the unknown_type
1036
     */
1037
    public function getPlayLimitScale()
1038
    {
1039
        return $this->playLimitScale;
1040
    }
1041
1042
    /**
1043
     * @param unknown_type $playLimitScale
1044
     */
1045
    public function setPlayLimitScale($playLimitScale)
1046
    {
1047
        $this->playLimitScale = $playLimitScale;
1048
1049
        return $this;
1050
    }
1051
1052
    /**
1053
     * @return the unknown_type
1054
     */
1055
    public function getPlayBonus()
1056
    {
1057
        return $this->playBonus;
1058
    }
1059
1060
    /**
1061
     * @param unknown_type $playBonus
1062
     */
1063
    public function setPlayBonus($playBonus)
1064
    {
1065
        $this->playBonus = $playBonus;
1066
1067
        return $this;
1068
    }
1069
1070
    /**
1071
     *
1072
     * @return the $layout
1073
     */
1074
    public function getLayout()
1075
    {
1076
        return $this->layout;
1077
    }
1078
1079
    /**
1080
     *
1081
     * @param field_type $layout
1082
     */
1083
    public function setLayout($layout)
1084
    {
1085
        $this->layout = $layout;
1086
1087
        return $this;
1088
    }
1089
1090
    /**
1091
     *
1092
     * @return the $stylesheet
1093
     */
1094
    public function getStylesheet()
1095
    {
1096
        return $this->stylesheet;
1097
    }
1098
1099
    /**
1100
     *
1101
     * @param field_type $stylesheet
1102
     */
1103
    public function setStylesheet($stylesheet)
1104
    {
1105
        $this->stylesheet = $stylesheet;
1106
1107
        return $this;
1108
    }
1109
1110
    /**
1111
     *
1112
     * @return the $welcomeBlock
1113
     */
1114
    public function getWelcomeBlock()
1115
    {
1116
        return $this->welcomeBlock;
1117
    }
1118
1119
    /**
1120
     *
1121
     * @param field_type $welcomeBlock
1122
     */
1123
    public function setWelcomeBlock($welcomeBlock)
1124
    {
1125
        $this->welcomeBlock = $welcomeBlock;
1126
1127
        return $this;
1128
    }
1129
1130
    /**
1131
     *
1132
     * @return the $termsBlock
1133
     */
1134
    public function getTermsBlock()
1135
    {
1136
        return $this->termsBlock;
1137
    }
1138
1139
    /**
1140
     *
1141
     * @param text $termsBlock
1142
     */
1143
    public function setTermsBlock($termsBlock)
1144
    {
1145
        $this->termsBlock = $termsBlock;
1146
1147
        return $this;
1148
    }
1149
1150
    /**
1151
     *
1152
     * @return integer $termsOptin
1153
     */
1154
    public function getTermsOptin()
1155
    {
1156
        return $this->termsOptin;
1157
    }
1158
1159
    /**
1160
     *
1161
     * @param text $termsOptin
1162
     */
1163
    public function setTermsOptin($termsOptin)
1164
    {
1165
        $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...
1166
1167
        return $this;
1168
    }
1169
1170
    /**
1171
     *
1172
     * @return the $conditionsBlock
1173
     */
1174
    public function getConditionsBlock()
1175
    {
1176
        return $this->conditionsBlock;
1177
    }
1178
1179
    /**
1180
     *
1181
     * @param text $conditionsBlock
1182
     */
1183
    public function setConditionsBlock($conditionsBlock)
1184
    {
1185
        $this->conditionsBlock = $conditionsBlock;
1186
1187
        return $this;
1188
    }
1189
1190
    /**
1191
     * @return ArrayCollection unknown_type
1192
     */
1193
    public function getPrizes()
1194
    {
1195
        return $this->prizes;
1196
    }
1197
1198
    /**
1199
     * frm collection solution
1200
     * @param ArrayCollection $prizes
1201
     */
1202
    public function setPrizes(ArrayCollection $prizes)
1203
    {
1204
        $this->prizes = $prizes;
1205
1206
        return $this;
1207
    }
1208
1209
    public function addPrizes(ArrayCollection $prizes)
1210
    {
1211
        foreach ($prizes as $prize) {
1212
            $prize->setGame($this);
1213
            $this->prizes->add($prize);
1214
        }
1215
    }
1216
1217
1218
    public function removePrizes(ArrayCollection $prizes)
1219
    {
1220
        foreach ($prizes as $prize) {
1221
            $prize->setGame(null);
1222
            $this->prizes->removeElement($prize);
1223
        }
1224
    }
1225
1226
    /**
1227
     * Add a prize to the game.
1228
     *
1229
     * @param Prize $prize
1230
     *
1231
     * @return void
1232
     */
1233
    public function addPrize($prize)
1234
    {
1235
        $this->prizes[] = $prize;
1236
    }
1237
1238
    /**
1239
     *
1240
     * @return string $classType
1241
     */
1242
    public function getClassType()
1243
    {
1244
        return $this->classType;
1245
    }
1246
1247
    /**
1248
     *
1249
     * @param string classType
1250
     * @param string $classType
1251
     */
1252
    public function setClassType($classType)
1253
    {
1254
        $this->classType = $classType;
1255
1256
        return $this;
1257
    }
1258
1259
    /**
1260
     *
1261
     * @return integer unknown_type
1262
     */
1263
    public function getActive()
1264
    {
1265
        return $this->active;
1266
    }
1267
1268
    /**
1269
     *
1270
     * @param unknown_type $active
1271
     */
1272
    public function setActive($active)
1273
    {
1274
        $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...
1275
1276
        return $this;
1277
    }
1278
1279
    /**
1280
     *
1281
     * @return boolean $onInvitation
1282
     */
1283
    public function getOnInvitation()
1284
    {
1285
        return $this->onInvitation;
1286
    }
1287
1288
    /**
1289
     *
1290
     * @param boolean $onInvitation
1291
     */
1292
    public function setOnInvitation($onInvitation)
1293
    {
1294
        $this->onInvitation = $onInvitation;
1295
1296
        return $this;
1297
    }
1298
1299
    /**
1300
     * @return ArrayCollection unknown_type
1301
     */
1302
    public function getInvitations()
1303
    {
1304
        return $this->invitations;
1305
    }
1306
1307
    /**
1308
     * @param ArrayCollection $invitations
1309
     */
1310
    public function setInvitations(ArrayCollection $invitations)
1311
    {
1312
        $this->invitations = $invitations;
1313
1314
        return $this;
1315
    }
1316
1317
    public function addInvitations(ArrayCollection $invitations)
1318
    {
1319
        foreach ($invitations as $invitation) {
1320
            $invitation->setGame($this);
1321
            $this->invitations->add($invitation);
1322
        }
1323
    }
1324
1325
    public function removeInvitations(ArrayCollection $invitations)
1326
    {
1327
        foreach ($invitations as $invitation) {
1328
            $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...
1329
            $this->invitations->removeElement($invitation);
1330
        }
1331
    }
1332
1333
    /**
1334
     * Add an invitation to the game.
1335
     *
1336
     * @param Invitation $invitation
1337
     *
1338
     * @return void
1339
     */
1340
    public function addInvitation($invitation)
1341
    {
1342
        $this->invitations[] = $invitation;
1343
    }
1344
1345
1346
    /**
1347
     *
1348
     * @return string the Facebook app_id
1349
     */
1350
    public function getFbPageId()
1351
    {
1352
        return $this->fbPageId;
1353
    }
1354
1355
    /**
1356
     *
1357
     * @param string $fbPageId
1358
     */
1359
    public function setFbPageId($fbPageId)
1360
    {
1361
        $this->fbPageId = $fbPageId;
1362
1363
        return $this;
1364
    }
1365
1366
    /**
1367
     *
1368
     * @return string the Facebook app_id
1369
     */
1370
    public function getFbAppId()
1371
    {
1372
        return $this->fbAppId;
1373
    }
1374
1375
    /**
1376
     *
1377
     * @param string $fbAppId
1378
     */
1379
    public function setFbAppId($fbAppId)
1380
    {
1381
        $this->fbAppId = $fbAppId;
1382
1383
        return $this;
1384
    }
1385
1386
    /**
1387
     *
1388
     * @return string the Facebook app_id
1389
     */
1390
    public function getFbPostId()
1391
    {
1392
        return $this->fbPostId;
1393
    }
1394
1395
    /**
1396
     *
1397
     * @param string $fbPostId
1398
     */
1399
    public function setFbPostId($fbPostId)
1400
    {
1401
        $this->fbPostId = $fbPostId;
1402
1403
        return $this;
1404
    }
1405
1406
    /**
1407
     *
1408
     * @return string the Facebook fbPageTabTitle
1409
     */
1410
    public function getFbPageTabTitle()
1411
    {
1412
        return $this->fbPageTabTitle;
1413
    }
1414
1415
    /**
1416
     *
1417
     * @param string $fbPageTabTitle
1418
     */
1419
    public function setFbPageTabTitle($fbPageTabTitle)
1420
    {
1421
        $this->fbPageTabTitle = $fbPageTabTitle;
1422
1423
        return $this;
1424
    }
1425
1426
    /**
1427
     *
1428
     * @return string the Facebook fbPageTabImage
1429
     */
1430
    public function getFbPageTabImage()
1431
    {
1432
        return $this->fbPageTabImage;
1433
    }
1434
1435
    /**
1436
     *
1437
     * @param string $fbPageTabImage
1438
     */
1439
    public function setFbPageTabImage($fbPageTabImage)
1440
    {
1441
        $this->fbPageTabImage = $fbPageTabImage;
1442
1443
        return $this;
1444
    }
1445
1446
    /**
1447
     *
1448
     * @return string the Facebook fbPageTabPosition
1449
     */
1450
    public function getFbPageTabPosition()
1451
    {
1452
        return $this->fbPageTabPosition;
1453
    }
1454
1455
    /**
1456
     *
1457
     * @param string $fbPageTabPosition
1458
     */
1459
    public function setFbPageTabPosition($fbPageTabPosition)
1460
    {
1461
        $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...
1462
1463
        return $this;
1464
    }
1465
1466
    /**
1467
     *
1468
     * @return the unknown_type
1469
     */
1470
    public function getFbShareMessage()
1471
    {
1472
        return $this->fbShareMessage;
1473
    }
1474
1475
    /**
1476
     *
1477
     * @param unknown_type $fbShareMessage
1478
     */
1479
    public function setFbShareMessage($fbShareMessage)
1480
    {
1481
        $this->fbShareMessage = $fbShareMessage;
1482
1483
        return $this;
1484
    }
1485
1486
    /**
1487
     *
1488
     * @return the unknown_type
1489
     */
1490
    public function getFbShareImage()
1491
    {
1492
        return $this->fbShareImage;
1493
    }
1494
1495
    /**
1496
     *
1497
     * @param unknown_type $fbShareImage
1498
     */
1499
    public function setFbShareImage($fbShareImage)
1500
    {
1501
        $this->fbShareImage = $fbShareImage;
1502
1503
        return $this;
1504
    }
1505
1506
    /**
1507
     *
1508
     * @return string unknown_type
1509
     */
1510
    public function getFbRequestMessage()
1511
    {
1512
        return $this->fbRequestMessage;
1513
    }
1514
1515
    /**
1516
     *
1517
     * @param unknown_type $fbRequestMessage
1518
     */
1519
    public function setFbRequestMessage($fbRequestMessage)
1520
    {
1521
        $this->fbRequestMessage = $fbRequestMessage;
1522
1523
        return $this;
1524
    }
1525
1526
    /**
1527
     *
1528
     * @return the unknown_type
1529
     */
1530
    public function getTwShareMessage()
1531
    {
1532
        return $this->twShareMessage;
1533
    }
1534
1535
    /**
1536
     *
1537
     * @param unknown_type $twShareMessage
1538
     */
1539
    public function setTwShareMessage($twShareMessage)
1540
    {
1541
        $this->twShareMessage = $twShareMessage;
1542
1543
        return $this;
1544
    }
1545
1546
    /**
1547
     *
1548
     * @return DateTime $createdAt
1549
     */
1550
    public function getCreatedAt()
1551
    {
1552
        return $this->createdAt;
1553
    }
1554
1555
    /**
1556
     *
1557
     * @param \DateTime $createdAt
1558
     */
1559
    public function setCreatedAt($createdAt)
1560
    {
1561
        $this->createdAt = $createdAt;
1562
1563
        return $this;
1564
    }
1565
1566
    /**
1567
     *
1568
     * @return DateTime $updatedAt
1569
     */
1570
    public function getUpdatedAt()
1571
    {
1572
        return $this->updatedAt;
1573
    }
1574
1575
    /**
1576
     *
1577
     * @param \DateTime $updatedAt
1578
     */
1579
    public function setUpdatedAt($updatedAt)
1580
    {
1581
        $this->updatedAt = $updatedAt;
1582
1583
        return $this;
1584
    }
1585
1586
    /**
1587
     * Convert the object to an array.
1588
     *
1589
     * @return array
1590
     */
1591
    public function getArrayCopy()
1592
    {
1593
        $obj_vars = get_object_vars($this);
1594
1595 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...
1596
            $obj_vars['publicationDate'] = $obj_vars['publicationDate']->format('d/m/Y H:i:s');
1597
        }
1598 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...
1599
            $obj_vars['endDate'] = $obj_vars['endDate']->format('d/m/Y H:i:s');
1600
        }
1601 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...
1602
            $obj_vars['startDate'] = $obj_vars['startDate']->format('d/m/Y H:i:s');
1603
        }
1604
1605
        return $obj_vars;
1606
    }
1607
1608
    /**
1609
     * Convert the object to json.
1610
     *
1611
     * @return array
1612
     */
1613
    public function jsonSerialize()
1614
    {
1615
        return $this->getArrayCopy();
1616
    }
1617
1618
    /**
1619
     * Populate from an array.
1620
     *
1621
     * @param array $data
1622
     */
1623
    public function populate($data = array())
1624
    {
1625
        if (isset($data['partner']) && $data['partner'] !== null) {
1626
            $this->partner = $data['partner'];
1627
        }
1628
1629
        $this->title = (isset($data['title'])) ? $data['title'] : null;
1630
        $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...
1631
1632
        if (isset($data['mainImage']) && $data['mainImage'] !== null) {
1633
            $this->mainImage = $data['mainImage'];
1634
        }
1635
1636
        if (isset($data['secondImage']) && $data['secondImage'] !== null) {
1637
            $this->secondImage = $data['secondImage'];
1638
        }
1639
1640 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...
1641
            $this->active = $data['active'];
1642
        }
1643
1644
        $this->layout           = (isset($data['layout'])) ? $data['layout'] : null;
1645
        $this->stylesheet       = (isset($data['stylesheet'])) ? $data['stylesheet'] : null;
1646
1647
        $this->pushHome         = (isset($data['pushHome']) && $data['pushHome'] !== null) ? $data['pushHome'] : 0;
1648
        $this->displayHome      = (isset($data['displayHome']) && $data['displayHome'] !== null) ?
1649
            $data['displayHome'] :
1650
            0;
1651
        $this->prizeCategory   = (isset($data['prizeCategory'])) ? $data['prizeCategory'] : null;
1652
1653
        $this->publicationDate  = (isset($data['publicationDate']) && $data['publicationDate'] !== null) ?
1654
            DateTime::createFromFormat('d/m/Y', $data['publicationDate']) :
1655
            null;
1656
        $this->endDate         = (isset($data['endDate']) && $data['endDate'] !== null) ?
1657
            DateTime::createFromFormat('d/m/Y', $data['endDate']) :
1658
            null;
1659
        $this->startDate       = (isset($data['startDate']) && $data['startDate'] !== null) ?
1660
            DateTime::createFromFormat('d/m/Y', $data['startDate']) :
1661
            null;
1662
1663
        $this->identifier       = (isset($data['identifier'])) ? $data['identifier'] : null;
1664
        $this->welcomeBlock    = (isset($data['welcomeBlock'])) ? $data['welcomeBlock'] : null;
1665
        $this->termsBlock       = (isset($data['termsBlock'])) ? $data['termsBlock'] : null;
1666
        $this->conditionsBlock  = (isset($data['conditionsBlock'])) ? $data['conditionsBlock'] : null;
1667
1668
        $this->fbShareMessage   = (isset($data['fbShareMessage'])) ? $data['fbShareMessage'] : null;
1669
        $this->fbShareImage     = (isset($data['fbShareImage'])) ? $data['fbShareImage'] : null;
1670
        $this->fbRequestMessage = (isset($data['fbRequestMessage'])) ? $data['fbRequestMessage'] : null;
1671
        $this->twShareMessage   = (isset($data['twShareMessage'])) ? $data['twShareMessage'] : null;
1672
    }
1673
1674
    public function setInputFilter(InputFilterInterface $inputFilter)
1675
    {
1676
        throw new \Exception("Not used");
1677
    }
1678
1679
    public function getInputFilter()
1680
    {
1681
        if (! $this->inputFilter) {
1682
            $inputFilter = new InputFilter();
1683
            $factory = new InputFactory();
1684
1685
            $inputFilter->add($factory->createInput(array(
1686
                'name' => 'id',
1687
                'required' => true,
1688
                'filters' => array(
1689
                    array(
1690
                        'name' => 'Int'
1691
                    )
1692
                )
1693
            )));
1694
1695
            $inputFilter->add($factory->createInput(array(
1696
                'name' => 'partner',
1697
                'required' => false
1698
            )));
1699
1700
            $inputFilter->add($factory->createInput(array(
1701
                'name' => 'fbAppId',
1702
                'required' => false
1703
            )));
1704
1705
            $inputFilter->add($factory->createInput(array(
1706
                'name' => 'fbPageId',
1707
                'required' => false
1708
            )));
1709
1710
            $inputFilter->add($factory->createInput(array(
1711
                'name' => 'fbPostId',
1712
                'required' => false
1713
            )));
1714
1715
            $inputFilter->add($factory->createInput(array(
1716
                'name' => 'prizes',
1717
                'required' => false
1718
            )));
1719
1720
            $inputFilter->add($factory->createInput(array(
1721
                'name' => 'invitations',
1722
                'required' => false
1723
            )));
1724
1725
            $inputFilter->add($factory->createInput(array(
1726
                'name' => 'title',
1727
                'required' => true,
1728
                'filters' => array(
1729
                    array(
1730
                        'name' => 'StripTags'
1731
                    ),
1732
                    array(
1733
                        'name' => 'StringTrim'
1734
                    )
1735
                ),
1736
                'validators' => array(
1737
                    array(
1738
                        'name' => 'StringLength',
1739
                        'options' => array(
1740
                            'encoding' => 'UTF-8',
1741
                            'min' => 5,
1742
                            'max' => 255
1743
                        )
1744
                    )
1745
                )
1746
            )));
1747
1748
            $inputFilter->add($factory->createInput(array(
1749
                'name' => 'publicationDate',
1750
                'required' => false,
1751
            )));
1752
1753
            $inputFilter->add($factory->createInput(array(
1754
                'name' => 'startDate',
1755
                'required' => false,
1756
            )));
1757
1758
            $inputFilter->add($factory->createInput(array(
1759
                'name' => 'endDate',
1760
                'required' => false,
1761
            )));
1762
1763
            $inputFilter->add($factory->createInput(array(
1764
               'name' => 'closeDate',
1765
               'required' => false,
1766
            )));
1767
1768
            $inputFilter->add($factory->createInput(array(
1769
                'name' => 'termsOptin',
1770
                'required' => false,
1771
            )));
1772
1773
            $inputFilter->add($factory->createInput(array(
1774
                'name' => 'identifier',
1775
                'required' => true,
1776
                'filters' => array(
1777
                    array(
1778
                        'name' => 'StripTags'
1779
                    ),
1780
                    array(
1781
                        'name' => 'StringTrim'
1782
                    ),
1783
                    array(
1784
                        'name' => 'PlaygroundCore\Filter\Slugify'
1785
                    )
1786
                ),
1787
                'validators' => array(
1788
                    array(
1789
                        'name' => 'StringLength',
1790
                        'options' => array(
1791
                            'encoding' => 'UTF-8',
1792
                            'min' => 3,
1793
                            'max' => 255
1794
                        )
1795
                    )
1796
                )
1797
            )));
1798
1799
            $inputFilter->add($factory->createInput(array(
1800
                'name'     => 'playLimit',
1801
                'required' => false,
1802
                'validators' => array(
1803
                    array(
1804
                        'name'    => 'Between',
1805
                        'options' => array(
1806
                            'min'      => 0,
1807
                            'max'      => 999999,
1808
                        ),
1809
                    ),
1810
                ),
1811
            )));
1812
1813
            $inputFilter->add($factory->createInput(array(
1814
                'name' => 'playLimitScale',
1815
                'required' => false,
1816
                'validators' => array(
1817
                    array(
1818
                        'name' => 'InArray',
1819
                        'options' => array(
1820
                            'haystack' => array('day', 'week', 'month', 'year', 'always'),
1821
                        ),
1822
                    ),
1823
                ),
1824
            )));
1825
1826
            $inputFilter->add($factory->createInput(array(
1827
                'name' => 'playBonus',
1828
                'required' => false,
1829
                'validators' => array(
1830
                    array(
1831
                        'name' => 'InArray',
1832
                        'options' => array(
1833
                            'haystack' => array('none', 'per_entry', 'one'),
1834
                        ),
1835
                    ),
1836
                ),
1837
            )));
1838
1839
            $inputFilter->add($factory->createInput(array(
1840
                'name' => 'active',
1841
                'required' => true
1842
            )));
1843
1844
            $inputFilter->add($factory->createInput(array(
1845
                'name' => 'onInvitation',
1846
                'required' => false
1847
            )));
1848
1849
            $inputFilter->add($factory->createInput(array(
1850
                'name' => 'displayHome',
1851
                'required' => false
1852
            )));
1853
1854
            $inputFilter->add($factory->createInput(array(
1855
                'name' => 'pushHome',
1856
                'required' => false
1857
            )));
1858
1859
            $inputFilter->add($factory->createInput(array(
1860
                'name' => 'anonymousAllowed',
1861
                'required' => false
1862
            )));
1863
1864
            $inputFilter->add($factory->createInput(array(
1865
                'name' => 'mailWinner',
1866
                'required' => false
1867
            )));
1868
1869
            $inputFilter->add($factory->createInput(array(
1870
                'name' => 'mailLooser',
1871
                'required' => false
1872
            )));
1873
1874
            $inputFilter->add($factory->createInput(array(
1875
                'name' => 'prizeCategory',
1876
                'required' => false,
1877
                'filters' => array(
1878
                    array(
1879
                        'name' => 'Int'
1880
                    )
1881
                )
1882
            )));
1883
1884
            $inputFilter->add($factory->createInput(array(
1885
                'name' => 'fbPageTabTitle',
1886
                'required' => false
1887
            )));
1888
1889
            $inputFilter->add($factory->createInput(array(
1890
                'name' => 'fbPageTabImage',
1891
                'required' => false
1892
            )));
1893
            $inputFilter->add($factory->createInput(array(
1894
                'name' => 'fbPageTabPosition',
1895
                'required' => false
1896
            )));
1897
1898
            $inputFilter->add($factory->createInput(array(
1899
                'name' => 'layout',
1900
                'required' => false,
1901
                'filters' => array(
1902
                    array(
1903
                        'name' => 'StripTags'
1904
                    ),
1905
                    array(
1906
                        'name' => 'StringTrim'
1907
                    )
1908
                ),
1909
                'validators' => array(
1910
                    array(
1911
                        'name' => 'StringLength',
1912
                        'options' => array(
1913
                            'encoding' => 'UTF-8',
1914
                            'min' => 0,
1915
                            'max' => 255
1916
                        )
1917
                    )
1918
                )
1919
            )));
1920
1921
            $inputFilter->add($factory->createInput(array(
1922
                'name' => 'stylesheet',
1923
                'required' => false,
1924
                'filters' => array(
1925
                    array(
1926
                        'name' => 'StripTags'
1927
                    ),
1928
                    array(
1929
                        'name' => 'StringTrim'
1930
                    )
1931
                ),
1932
                'validators' => array(
1933
                    array(
1934
                        'name' => 'StringLength',
1935
                        'options' => array(
1936
                            'encoding' => 'UTF-8',
1937
                            'min' => 0,
1938
                            'max' => 255
1939
                        )
1940
                    )
1941
                )
1942
            )));
1943
1944
            $inputFilter->add($factory->createInput(array(
1945
                'name' => 'fbShareImage',
1946
                'required' => false,
1947
                'filters' => array(
1948
                    array(
1949
                        'name' => 'StripTags'
1950
                    ),
1951
                    array(
1952
                        'name' => 'StringTrim'
1953
                    )
1954
                ),
1955
                'validators' => array(
1956
                    array(
1957
                        'name' => 'StringLength',
1958
                        'options' => array(
1959
                            'encoding' => 'UTF-8',
1960
                            'min' => 1,
1961
                            'max' => 255
1962
                        )
1963
                    )
1964
                )
1965
            )));
1966
1967
            $inputFilter->add($factory->createInput(array(
1968
                    'name' => 'fbShareMessage',
1969
                    'required' => false,
1970
                    'filters' => array(
1971
                            array(
1972
                                    'name' => 'StripTags'
1973
                            ),
1974
                            array(
1975
                                    'name' => 'StringTrim'
1976
                            )
1977
                    ),
1978
                    'validators' => array(
1979
                        array(
1980
                            'name' => 'StringLength',
1981
                            'options' => array(
1982
                                'encoding' => 'UTF-8',
1983
                                'min' => 1,
1984
                                'max' => 500
1985
                             )
1986
                        )
1987
                    )
1988
            )));
1989
1990
            $inputFilter->add($factory->createInput(array(
1991
                'name' => 'fbRequestMessage',
1992
                'required' => false,
1993
                'filters' => array(
1994
                    array(
1995
                        'name' => 'StripTags'
1996
                    ),
1997
                    array(
1998
                        'name' => 'StringTrim'
1999
                    )
2000
                ),
2001
                'validators' => array(
2002
                    array(
2003
                        'name' => 'StringLength',
2004
                        'options' => array(
2005
                            'encoding' => 'UTF-8',
2006
                            'min' => 1,
2007
                            'max' => 500
2008
                        )
2009
                    )
2010
                )
2011
            )));
2012
2013
            $inputFilter->add($factory->createInput(array(
2014
                'name' => 'twShareMessage',
2015
                'required' => false,
2016
                'filters' => array(
2017
                    array(
2018
                        'name' => 'StripTags'
2019
                    ),
2020
                    array(
2021
                        'name' => 'StringTrim'
2022
                    )
2023
                ),
2024
                'validators' => array(
2025
                    array(
2026
                        'name' => 'StringLength',
2027
                        'options' => array(
2028
                            'encoding' => 'UTF-8',
2029
                            'min' => 1,
2030
                            'max' => 255
2031
                        )
2032
                    )
2033
                )
2034
            )));
2035
            
2036
            $inputFilter->add($factory->createInput(array(
2037
                'name' => 'anonymousIdentifier',
2038
                'required' => false,
2039
                'filters' => array(
2040
                    array(
2041
                        'name' => 'StripTags'
2042
                    ),
2043
                    array(
2044
                        'name' => 'StringTrim'
2045
                    )
2046
                ),
2047
                'validators' => array(
2048
                    array(
2049
                        'name' => 'StringLength',
2050
                        'options' => array(
2051
                            'encoding' => 'UTF-8',
2052
                            'min' => 0,
2053
                            'max' => 255
2054
                        )
2055
                    )
2056
                )
2057
            )));
2058
2059
            $this->inputFilter = $inputFilter;
2060
        }
2061
2062
        return $this->inputFilter;
2063
    }
2064
2065
    public function setTranslatableLocale($locale)
2066
    {
2067
        $this->locale = $locale;
2068
    }
2069
}
2070