Completed
Push — master ( 8a3179...d462e2 )
by greg
24:52 queued 21:12
created

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