Completed
Push — master ( 6e2d8e...315e5f )
by greg
03:16
created

Game::getBroadcastEmbed()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
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"})
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(name="broadcast_embed",type="boolean", nullable=true)
105
     */
106
    protected $broadcastEmbed = 0;
107
108
    /**
109
     * @ORM\Column(name="push_home",type="boolean", nullable=true)
110
     */
111
    protected $pushHome = 0;
112
113
    /**
114
     * @ORM\Column(name="display_home",type="boolean", nullable=true)
115
     */
116
    protected $displayHome = 0;
117
118
    /**
119
     * @ORM\Column(name="mail_winner",type="boolean", nullable=true)
120
     */
121
    protected $mailWinner = 0;
122
123
    /**
124
     * @Gedmo\Translatable
125
     * @ORM\Column(name="mail_winner_block", type="text", nullable=true)
126
     */
127
    protected $mailWinnerBlock;
128
129
    /**
130
     * @ORM\Column(name="mail_looser",type="boolean", nullable=true)
131
     */
132
    protected $mailLooser = 0;
133
134
    /**
135
     * @Gedmo\Translatable
136
     * @ORM\Column(name="mail_looser_block", type="text", nullable=true)
137
     */
138
    protected $mailLooserBlock;
139
140
    /**
141
     * @ORM\Column(type="boolean", nullable=false)
142
     */
143
    protected $active = 0;
144
145
    /**
146
     * @ORM\Column(name="anonymous_allowed",type="boolean", nullable=true)
147
     */
148
    protected $anonymousAllowed = 0;
149
    
150
    /**
151
     * This column can be filled in when anonymousAllowed = 1.
152
     * If you put a value, it has to be a field key from playerdata. This key will
153
     * then be used to identify a player (generally 'email')
154
     *
155
     * @ORM\Column(name="anonymous_identifier", type="text", nullable=true)
156
     */
157
    protected $anonymousIdentifier;
158
159
    /**
160
     * @ORM\Column(name="publication_date", type="datetime", nullable=true)
161
     */
162
    protected $publicationDate;
163
164
    /**
165
     * @ORM\Column(name="start_date", type="datetime", nullable=true)
166
     */
167
    protected $startDate;
168
169
    /**
170
     * @ORM\Column(name="end_date", type="datetime", nullable=true)
171
     */
172
    protected $endDate;
173
174
    /**
175
     * @ORM\Column(name="close_date", type="datetime", nullable=true)
176
     */
177
    protected $closeDate;
178
179
    /**
180
     * play limitation. 0 : No limit
181
     *
182
     * @ORM\Column(name="play_limit", type="integer", nullable=false)
183
     */
184
    protected $playLimit = 0;
185
186
    /**
187
     * this field is taken into account only if playLimit<>0.
188
     * if 'always' only $playLimit play by person for this game
189
     * if 'day' only $playLimit play by person a day
190
     * if 'week' only $playLimit play by person a week
191
     * if 'month' only $playLimit play by person a month
192
     * if 'year' only $playLimit play by person a year
193
     *
194
     * @ORM\Column(name="play_limit_scale", type="string", nullable=true)
195
     */
196
    protected $playLimitScale;
197
198
    /**
199
     * this field is used for offering a complementary play entry
200
     * (for example, when the player share the game). The entries
201
     * of type 'bonus' won't be taken into account in the calaculation
202
     * of the authorized playLimit.
203
     *
204
     * if 'none' or null no play bonus is offered
205
     * if 'per_entry' a play bonus is offered for each entry
206
     * if 'one' only one play bonus is offered for every entries of the game
207
     *
208
     * @ORM\Column(name="play_bonus", type="string", nullable=true)
209
     */
210
    protected $playBonus;
211
212
    /**
213
     * @ORM\Column(type="string", length=255, nullable=true)
214
     */
215
    protected $layout;
216
217
    /**
218
     * @ORM\Column(type="string", length=255, nullable=true)
219
     */
220
    protected $stylesheet;
221
222
    /**
223
     * @Gedmo\Translatable
224
     * @ORM\Column(name="welcome_block", type="text", nullable=true)
225
     */
226
    protected $welcomeBlock;
227
228
    /**
229
     * @Gedmo\Translatable
230
     * @ORM\Column(type="text", nullable=true)
231
     */
232
    protected $termsBlock;
233
234
    /**
235
     * @ORM\Column(name="terms_optin", type="boolean", nullable=true)
236
     */
237
    protected $termsOptin = 0;
238
239
    /**
240
     * @Gedmo\Translatable
241
     * @ORM\Column(type="text", nullable=true)
242
     */
243
    protected $conditionsBlock;
244
245
    // Adherence CMS de ces blocs à revoir
246
    /**
247
     * @Gedmo\Translatable
248
     * @ORM\Column(type="text", nullable=true)
249
     */
250
    protected $columnBlock1;
251
252
    /**
253
     * @Gedmo\Translatable
254
     * @ORM\Column(type="text", nullable=true)
255
     */
256
    protected $columnBlock2;
257
258
    /**
259
     * @Gedmo\Translatable
260
     * @ORM\Column(type="text", nullable=true)
261
     */
262
    protected $columnBlock3;
263
264
    /**
265
     * @ORM\OneToMany(targetEntity="Prize", mappedBy="game", cascade={"persist","remove"}, orphanRemoval=true)
266
     */
267
    private $prizes;
268
269
    /**
270
     * @ORM\Column(name="fb_app_id", type="string", nullable=true)
271
     */
272
    protected $fbAppId;
273
274
    /**
275
     * @Gedmo\Translatable
276
     * @ORM\Column(name="fb_page_tab_title", type="string", length=255, nullable=true)
277
     */
278
    protected $fbPageTabTitle;
279
280
    /**
281
     * @ORM\Column(name="fb_page_tab_image", type="string", length=255, nullable=true)
282
     */
283
    protected $fbPageTabImage;
284
285
    /**
286
     * @Gedmo\Translatable
287
     * @ORM\Column(name="fb_share_message", type="text", nullable=true)
288
     */
289
    protected $fbShareMessage;
290
291
    /**
292
     * @ORM\Column(name="fb_share_image", type="string", length=255, nullable=true)
293
     */
294
    protected $fbShareImage;
295
296
    /**
297
     * @Gedmo\Translatable
298
     * @ORM\Column(name="fb_request_message", type="text", nullable=true)
299
     */
300
    protected $fbRequestMessage;
301
302
    /**
303
     * @ORM\Column(type="boolean", nullable=true)
304
     */
305
    protected $fbFan = 0;
306
307
    /**
308
     * @Gedmo\Translatable
309
     * @ORM\Column(name="fb_fan_gate", type="text", nullable=true)
310
     */
311
    protected $fbFanGate;
312
313
    /**
314
     * @Gedmo\Translatable
315
     * @ORM\Column(name="tw_share_message", type="string", length=255, nullable=true)
316
     */
317
    protected $twShareMessage;
318
319
    /**
320
     * @ORM\Column(name="steps", type="string", length=255, nullable=true)
321
     */
322
    protected $steps = '{"0":"index","1":"play","2":"result","3":"bounce"}';
323
324
    /**
325
     * @ORM\Column(name="steps_views", type="string", length=255, nullable=true)
326
     */
327
    protected $stepsViews = '{"index":{},"play":{},"result":{},"bounce":{}}';
328
329
    /**
330
     * Doctrine accessible value of discriminator (field 'type' is not
331
     * accessible through query)
332
     * And I want to be able to sort game collection based on type
333
     * http://www.doctrine-project.org/jira/browse/DDC-707
334
     * @ORM\Column(name="class_type", type="string", length=255, nullable=false)
335
     */
336
    protected $classType;
337
338
    /**
339
     * @ORM\Column(name="created_at", type="datetime")
340
     */
341
    protected $createdAt;
342
343
    /**
344
     * @ORM\Column(name="updated_at", type="datetime")
345
     */
346
    protected $updatedAt;
347
348
    public function __construct()
349
    {
350
        $this->prizes = new ArrayCollection();
351
    }
352
353
    /**
354
     * @PrePersist
355
     */
356
    public function createChrono()
357
    {
358
        $this->createdAt = new \DateTime("now");
359
        $this->updatedAt = new \DateTime("now");
360
    }
361
362
    /**
363
     * @PreUpdate
364
     */
365
    public function updateChrono()
366
    {
367
        $this->updatedAt = new \DateTime("now");
368
    }
369
370
    /**
371
     *
372
     * @return the $id
373
     */
374
    public function getId()
375
    {
376
        return $this->id;
377
    }
378
379
    /**
380
     *
381
     * @param field_type $id
382
     */
383
    public function setId($id)
384
    {
385
        $this->id = $id;
386
387
        return $this;
388
    }
389
390
    /**
391
     * @return the $playerForm
392
     */
393
    public function getPlayerForm()
394
    {
395
        return $this->playerForm;
396
    }
397
398
    /**
399
     * @param field_type $playerForm
400
     */
401
    public function setPlayerForm($playerForm)
402
    {
403
        $this->playerForm = $playerForm;
404
405
        return $this;
406
    }
407
408
    /**
409
     *
410
     * @return the unknown_type
411
     */
412
    public function getPartner()
413
    {
414
        return $this->partner;
415
    }
416
417
    /**
418
     *
419
     * @param unknown_type $partner
420
     */
421
    public function setPartner($partner)
422
    {
423
        $this->partner = $partner;
424
425
        return $this;
426
    }
427
428
    /**
429
     *
430
     * @param unknown_type $prizeCategory
431
     */
432
    public function setPrizeCategory($prizeCategory)
433
    {
434
        $this->prizeCategory = $prizeCategory;
435
436
        return $this;
437
    }
438
439
    /**
440
     *
441
     * @return the unknown_type
442
     */
443
    public function getPrizeCategory()
444
    {
445
        return $this->prizeCategory;
446
    }
447
448
    /**
449
     *
450
     * @return the $title
451
     */
452
    public function getTitle()
453
    {
454
        return $this->title;
455
    }
456
457
    /**
458
     *
459
     * @param field_type $title
460
     */
461
    public function setTitle($title)
462
    {
463
        $this->title = $title;
464
465
        return $this;
466
    }
467
468
    /**
469
     *
470
     * @return the $identifier
471
     */
472
    public function getIdentifier()
473
    {
474
        return $this->identifier;
475
    }
476
477
    /**
478
     *
479
     * @param field_type $identifier
480
     */
481
    public function setIdentifier($identifier)
482
    {
483
        $this->identifier = $identifier;
484
485
        return $this;
486
    }
487
488
    /**
489
     * @return integer $anonymousAllowed
490
     */
491
    public function getAnonymousAllowed()
492
    {
493
        return $this->anonymousAllowed;
494
    }
495
496
    /**
497
     * @param number $anonymousAllowed
498
     */
499
    public function setAnonymousAllowed($anonymousAllowed)
500
    {
501
        $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...
502
503
        return $this;
504
    }
505
506
    /**
507
     * @return the $anonymousIdentifier
508
     */
509
    public function getAnonymousIdentifier()
510
    {
511
        return $this->anonymousIdentifier;
512
    }
513
514
    /**
515
     * @param field_type $anonymousIdentifier
516
     */
517
    public function setAnonymousIdentifier($anonymousIdentifier)
518
    {
519
        $this->anonymousIdentifier = $anonymousIdentifier;
520
    }
521
522
    /**
523
     *
524
     * @return the $mainImage
525
     */
526
    public function getMainImage()
527
    {
528
        return $this->mainImage;
529
    }
530
531
    /**
532
     *
533
     * @param field_type $mainImage
534
     */
535
    public function setMainImage($mainImage)
536
    {
537
        $this->mainImage = $mainImage;
538
539
        return $this;
540
    }
541
542
    /**
543
     *
544
     * @return the $secondImage
545
     */
546
    public function getSecondImage()
547
    {
548
        return $this->secondImage;
549
    }
550
551
    /**
552
     *
553
     * @param field_type $secondImage
554
     */
555
    public function setSecondImage($secondImage)
556
    {
557
        $this->secondImage = $secondImage;
558
559
        return $this;
560
    }
561
562
    /**
563
     *
564
     * @return integer $broadcastFacebook
565
     */
566
    public function getBroadcastFacebook()
567
    {
568
        return $this->broadcastFacebook;
569
    }
570
571
    /**
572
     *
573
     * @param field_type $broadcastFacebook
574
     */
575
    public function setBroadcastFacebook($broadcastFacebook)
576
    {
577
        $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...
578
579
        return $this;
580
    }
581
582
    /**
583
     *
584
     * @return integer $broadcastPlatform
585
     */
586
    public function getBroadcastPlatform()
587
    {
588
        return $this->broadcastPlatform;
589
    }
590
591
    /**
592
     *
593
     * @param field_type $broadcastPlatform
594
     */
595
    public function setBroadcastPlatform($broadcastPlatform)
596
    {
597
        $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...
598
599
        return $this;
600
    }
601
602
    /**
603
     * @return integer $broadcastEmbed
604
     */
605
    public function getBroadcastEmbed()
606
    {
607
        return $this->broadcastEmbed;
608
    }
609
610
    /**
611
     * @param number $broadcastEmbed
612
     */
613
    public function setBroadcastEmbed($broadcastEmbed)
614
    {
615
        $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...
616
617
        return $this;
618
    }
619
620
    /**
621
     * @return integer $mailWinner
622
     */
623
    public function getMailWinner()
624
    {
625
        return $this->mailWinner;
626
    }
627
628
    /**
629
     * @param number $mailWinner
630
     */
631
    public function setMailWinner($mailWinner)
632
    {
633
        $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...
634
    }
635
636
    /**
637
     * @return the $mailWinnerBlock
638
     */
639
    public function getMailWinnerBlock()
640
    {
641
        return $this->mailWinnerBlock;
642
    }
643
644
    /**
645
     * @param field_type $mailWinnerBlock
646
     */
647
    public function setMailWinnerBlock($mailWinnerBlock)
648
    {
649
        $this->mailWinnerBlock = $mailWinnerBlock;
650
    }
651
652
    /**
653
     * @return integer $mailLooser
654
     */
655
    public function getMailLooser()
656
    {
657
        return $this->mailLooser;
658
    }
659
660
    /**
661
     * @param number $mailLooser
662
     */
663
    public function setMailLooser($mailLooser)
664
    {
665
        $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...
666
    }
667
668
    /**
669
     * @return the $mailLooserBlock
670
     */
671
    public function getMailLooserBlock()
672
    {
673
        return $this->mailLooserBlock;
674
    }
675
676
    /**
677
     * @param field_type $mailLooserBlock
678
     */
679
    public function setMailLooserBlock($mailLooserBlock)
680
    {
681
        $this->mailLooserBlock = $mailLooserBlock;
682
    }
683
684
    /**
685
     *
686
     * @return integer $pushHome
687
     */
688
    public function getPushHome()
689
    {
690
        return $this->pushHome;
691
    }
692
693
    /**
694
     *
695
     * @param field_type $pushHome
696
     */
697
    public function setPushHome($pushHome)
698
    {
699
        $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...
700
701
        return $this;
702
    }
703
704
    /**
705
     *
706
     * @return integer $displayHome
707
     */
708
    public function getDisplayHome()
709
    {
710
        return $this->displayHome;
711
    }
712
713
    /**
714
     *
715
     * @param field_type $displayHome
716
     */
717
    public function setDisplayHome($displayHome)
718
    {
719
        $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...
720
721
        return $this;
722
    }
723
724
    /**
725
     *
726
     * @return the $publicationDate
727
     */
728
    public function getPublicationDate()
729
    {
730
        return $this->publicationDate;
731
    }
732
733
    /**
734
     *
735
     * @param field_type $publicationDate
736
     */
737
    public function setPublicationDate($publicationDate)
738
    {
739
        $this->publicationDate = $publicationDate;
740
741
        return $this;
742
    }
743
744
    /**
745
     *
746
     * @return the $startDate
747
     */
748
    public function getStartDate()
749
    {
750
        return $this->startDate;
751
    }
752
753
    /**
754
     *
755
     * @param field_type $startDate
756
     */
757
    public function setStartDate($startDate)
758
    {
759
        $this->startDate = $startDate;
760
761
        return $this;
762
    }
763
764
    /**
765
     *
766
     * @return the $endDate
767
     */
768
    public function getEndDate()
769
    {
770
        return $this->endDate;
771
    }
772
773
    /**
774
     *
775
     * @param field_type $endDate
776
     */
777
    public function setEndDate($endDate)
778
    {
779
        $this->endDate = $endDate;
780
781
        return $this;
782
    }
783
784
    /**
785
     *
786
     * @return the $closeDate
787
     */
788
    public function getCloseDate()
789
    {
790
        return $this->closeDate;
791
    }
792
793
    /**
794
     *
795
     * @param field_type $closeDate
796
     */
797
    public function setCloseDate($closeDate)
798
    {
799
        $this->closeDate = $closeDate;
800
801
        return $this;
802
    }
803
804 View Code Duplication
    public function isClosed()
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...
805
    {
806
        $today = new DateTime('now');
807
        if (($this->getCloseDate() && $this->getCloseDate()->setTime(23, 59, 59) < $today)
808
            ||
809
            ($this->getPublicationDate() && $this->getPublicationDate()->setTime(0, 0, 0) > $today)
810
        ) {
811
            return true;
812
        }
813
814
        return false;
815
    }
816
817
    public function isOpen()
818
    {
819
        return !$this->isClosed();
820
    }
821
822 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...
823
    {
824
        $today = new DateTime('now');
825
        if (((!$this->getStartDate() || $this->getStartDate()->setTime(0, 0, 0) <= $today))
826
                &&
827
                (!$this->getEndDate() || $this->getEndDate()->setTime(23, 59, 59) > $today)
828
        ) {
829
            return true;
830
        }
831
832
        return false;
833
    }
834
835 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...
836
    {
837
        $today = new DateTime('now');
838
        if ($this->getEndDate() && $this->getEndDate()->setTime(23, 59, 59) <= $today
839
            ||
840
            ($this->getCloseDate() && $this->getCloseDate()->setTime(23, 59, 59) <= $today)
841
        ) {
842
            return true;
843
        }
844
845
        return false;
846
    }
847
848
    public function isOnline()
849
    {
850
        if ($this->getActive() && $this->getBroadcastPlatform()) {
851
            return true;
852
        }
853
854
        return false;
855
    }
856
857
    // json array : {"0":"index","1":"play","2":"result","3":"bounce"}
858 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...
859
    {
860
        $steps = null;
861
862
        if ($this->getSteps()) {
863
            $steps = json_decode($this->getSteps(), true);
864
        }
865
        if (!$steps) {
866
            $steps = array('index','play','result','bounce');
867
        }
868
        return $steps;
869
    }
870
871
872
873 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...
874
    {
875
        $viewSteps = null;
876
877
        if ($this->getStepsViews()) {
878
            $viewSteps = json_decode($this->getStepsViews(), true);
879
        }
880
        if (!$viewSteps) {
881
            $viewSteps = array('index','play','result','bounce');
882
        }
883
884
        return $viewSteps;
885
    }
886
887
    public function getSteps()
888
    {
889
        return $this->steps;
890
    }
891
892
    public function setSteps($steps)
893
    {
894
        $this->steps = $steps;
895
896
        return $this;
897
    }
898
899
    /**
900
     * This method returns the first step in the game workflow
901
     * @return string
902
     */
903
    public function firstStep()
904
    {
905
        $steps = $this->getStepsArray();
906
907
        return $steps[0];
908
    }
909
910
    /**
911
     * This method returns the last step in the game workflow
912
     * @return string
913
     */
914
    public function lastStep()
915
    {
916
        $steps = $this->getStepsArray();
917
        $nbSteps = count($steps);
918
919
        return $steps[$nbSteps-1];
920
    }
921
922
    /**
923
     * This method returns the previous step in the game workflow
924
     * @param string $step
925
     * @return string
926
     */
927 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...
928
    {
929
        $steps = $this->getStepsArray();
930
        $key = array_search($step, $steps);
931
932
        if (is_int($key) && $key > 0) {
933
            return $steps[$key-1];
934
        }
935
936
        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...
937
    }
938
939
    /**
940
     * This method returns the next step in the game workflow
941
     * @param string $step
942
     * @return string
943
     */
944 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...
945
    {
946
        $steps = $this->getStepsArray();
947
        $key = array_search($step, $steps);
948
949
        if (is_int($key) && $key < count($steps)-1) {
950
            return $steps[$key+1];
951
        }
952
953
        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...
954
    }
955
956
    /**
957
     * @return string $stepsViews
958
     */
959
    public function getStepsViews()
960
    {
961
        return $this->stepsViews;
962
    }
963
964
    /**
965
     * @param string $stepsViews
966
     */
967
    public function setStepsViews($stepsViews)
968
    {
969
        $this->stepsViews = $stepsViews;
970
971
        return $this;
972
    }
973
974
    public function getState()
975
    {
976
        if ($this->isOpen()) {
977
            if (!$this->isStarted() && !$this->isFinished()) {
978
                return self::GAME_PUBLISHED;
979
            } elseif ($this->isStarted()) {
980
                return self::GAME_IN_PROGRESS;
981
            } elseif ($this->isFinished()) {
982
                return self::GAME_FINISHED;
983
            }
984
        } else {
985
            if ($this->isFinished()) {
986
                return self::GAME_CLOSED;
987
            } else {
988
                return self::GAME_SCHEDULE;
989
            }
990
        }
991
    }
992
993
    /**
994
     * @return integer unknown_type
995
     */
996
    public function getPlayLimit()
997
    {
998
        return $this->playLimit;
999
    }
1000
1001
    /**
1002
     * @param unknown_type $playLimit
1003
     */
1004
    public function setPlayLimit($playLimit)
1005
    {
1006
        $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...
1007
1008
        return $this;
1009
    }
1010
1011
    /**
1012
     * @return the unknown_type
1013
     */
1014
    public function getPlayLimitScale()
1015
    {
1016
        return $this->playLimitScale;
1017
    }
1018
1019
    /**
1020
     * @param unknown_type $playLimitScale
1021
     */
1022
    public function setPlayLimitScale($playLimitScale)
1023
    {
1024
        $this->playLimitScale = $playLimitScale;
1025
1026
        return $this;
1027
    }
1028
1029
    /**
1030
     * @return the unknown_type
1031
     */
1032
    public function getPlayBonus()
1033
    {
1034
        return $this->playBonus;
1035
    }
1036
1037
    /**
1038
     * @param unknown_type $playBonus
1039
     */
1040
    public function setPlayBonus($playBonus)
1041
    {
1042
        $this->playBonus = $playBonus;
1043
1044
        return $this;
1045
    }
1046
1047
    /**
1048
     *
1049
     * @return the $layout
1050
     */
1051
    public function getLayout()
1052
    {
1053
        return $this->layout;
1054
    }
1055
1056
    /**
1057
     *
1058
     * @param field_type $layout
1059
     */
1060
    public function setLayout($layout)
1061
    {
1062
        $this->layout = $layout;
1063
1064
        return $this;
1065
    }
1066
1067
    /**
1068
     *
1069
     * @return the $stylesheet
1070
     */
1071
    public function getStylesheet()
1072
    {
1073
        return $this->stylesheet;
1074
    }
1075
1076
    /**
1077
     *
1078
     * @param field_type $stylesheet
1079
     */
1080
    public function setStylesheet($stylesheet)
1081
    {
1082
        $this->stylesheet = $stylesheet;
1083
1084
        return $this;
1085
    }
1086
1087
    /**
1088
     *
1089
     * @return the $welcomeBlock
1090
     */
1091
    public function getWelcomeBlock()
1092
    {
1093
        return $this->welcomeBlock;
1094
    }
1095
1096
    /**
1097
     *
1098
     * @param field_type $welcomeBlock
1099
     */
1100
    public function setWelcomeBlock($welcomeBlock)
1101
    {
1102
        $this->welcomeBlock = $welcomeBlock;
1103
1104
        return $this;
1105
    }
1106
1107
    /**
1108
     *
1109
     * @return the $termsBlock
1110
     */
1111
    public function getTermsBlock()
1112
    {
1113
        return $this->termsBlock;
1114
    }
1115
1116
    /**
1117
     *
1118
     * @param text $termsBlock
1119
     */
1120
    public function setTermsBlock($termsBlock)
1121
    {
1122
        $this->termsBlock = $termsBlock;
1123
1124
        return $this;
1125
    }
1126
1127
    /**
1128
     *
1129
     * @return integer $termsOptin
1130
     */
1131
    public function getTermsOptin()
1132
    {
1133
        return $this->termsOptin;
1134
    }
1135
1136
    /**
1137
     *
1138
     * @param text $termsOptin
1139
     */
1140
    public function setTermsOptin($termsOptin)
1141
    {
1142
        $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...
1143
1144
        return $this;
1145
    }
1146
1147
    /**
1148
     *
1149
     * @return the $conditionsBlock
1150
     */
1151
    public function getConditionsBlock()
1152
    {
1153
        return $this->conditionsBlock;
1154
    }
1155
1156
    /**
1157
     *
1158
     * @param text $conditionsBlock
1159
     */
1160
    public function setConditionsBlock($conditionsBlock)
1161
    {
1162
        $this->conditionsBlock = $conditionsBlock;
1163
1164
        return $this;
1165
    }
1166
1167
    /**
1168
     *
1169
     * @return the $columnBlock1
1170
     */
1171
    public function getColumnBlock1()
1172
    {
1173
        return $this->columnBlock1;
1174
    }
1175
1176
    /**
1177
     *
1178
     * @param text $columnBlock1
1179
     */
1180
    public function setColumnBlock1($columnBlock1)
1181
    {
1182
        $this->columnBlock1 = $columnBlock1;
1183
1184
        return $this;
1185
    }
1186
1187
    /**
1188
     *
1189
     * @return the $columnBlock2
1190
     */
1191
    public function getColumnBlock2()
1192
    {
1193
        return $this->columnBlock2;
1194
    }
1195
1196
    /**
1197
     *
1198
     * @param text $columnBlock2
1199
     */
1200
    public function setColumnBlock2($columnBlock2)
1201
    {
1202
        $this->columnBlock2 = $columnBlock2;
1203
1204
        return $this;
1205
    }
1206
1207
    /**
1208
     *
1209
     * @return the $columnBlock3
1210
     */
1211
    public function getColumnBlock3()
1212
    {
1213
        return $this->columnBlock3;
1214
    }
1215
1216
    /**
1217
     *
1218
     * @param text $columnBlock3
1219
     */
1220
    public function setColumnBlock3($columnBlock3)
1221
    {
1222
        $this->columnBlock3 = $columnBlock3;
1223
1224
        return $this;
1225
    }
1226
1227
    /**
1228
     * @return ArrayCollection unknown_type
1229
     */
1230
    public function getPrizes()
1231
    {
1232
        return $this->prizes;
1233
    }
1234
1235
    /**
1236
     * frm collection solution
1237
     * @param ArrayCollection $prizes
1238
     */
1239
    public function setPrizes(ArrayCollection $prizes)
1240
    {
1241
        $this->prizes = $prizes;
1242
1243
        return $this;
1244
    }
1245
1246
    public function addPrizes(ArrayCollection $prizes)
1247
    {
1248
        foreach ($prizes as $prize) {
1249
            $prize->setGame($this);
1250
            $this->prizes->add($prize);
1251
        }
1252
    }
1253
1254
1255
    public function removePrizes(ArrayCollection $prizes)
1256
    {
1257
        foreach ($prizes as $prize) {
1258
            $prize->setGame(null);
1259
            $this->prizes->removeElement($prize);
1260
        }
1261
    }
1262
1263
    /**
1264
     * Add a prize to the game.
1265
     *
1266
     * @param Prize $prize
1267
     *
1268
     * @return void
1269
     */
1270
    public function addPrize($prize)
1271
    {
1272
        $this->prizes[] = $prize;
1273
    }
1274
1275
    /**
1276
     *
1277
     * @return string $classType
1278
     */
1279
    public function getClassType()
1280
    {
1281
        return $this->classType;
1282
    }
1283
1284
    /**
1285
     *
1286
     * @param string classType
1287
     * @param string $classType
1288
     */
1289
    public function setClassType($classType)
1290
    {
1291
        $this->classType = $classType;
1292
1293
        return $this;
1294
    }
1295
1296
    /**
1297
     *
1298
     * @return integer unknown_type
1299
     */
1300
    public function getActive()
1301
    {
1302
        return $this->active;
1303
    }
1304
1305
    /**
1306
     *
1307
     * @param unknown_type $active
1308
     */
1309
    public function setActive($active)
1310
    {
1311
        $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...
1312
1313
        return $this;
1314
    }
1315
1316
    /**
1317
     *
1318
     * @return string the Facebook app_id
1319
     */
1320
    public function getFbAppId()
1321
    {
1322
        return $this->fbAppId;
1323
    }
1324
1325
    /**
1326
     *
1327
     * @param string $fbAppId
1328
     */
1329
    public function setFbAppId($fbAppId)
1330
    {
1331
        $this->fbAppId = $fbAppId;
1332
1333
        return $this;
1334
    }
1335
1336
    /**
1337
     *
1338
     * @return string the Facebook fbPageTabTitle
1339
     */
1340
    public function getFbPageTabTitle()
1341
    {
1342
        return $this->fbPageTabTitle;
1343
    }
1344
1345
    /**
1346
     *
1347
     * @param string $fbPageTabTitle
1348
     */
1349
    public function setFbPageTabTitle($fbPageTabTitle)
1350
    {
1351
        $this->fbPageTabTitle = $fbPageTabTitle;
1352
1353
        return $this;
1354
    }
1355
1356
    /**
1357
     *
1358
     * @return string the Facebook fbPageTabImage
1359
     */
1360
    public function getFbPageTabImage()
1361
    {
1362
        return $this->fbPageTabImage;
1363
    }
1364
1365
    /**
1366
     *
1367
     * @param string $fbPageTabImage
1368
     */
1369
    public function setFbPageTabImage($fbPageTabImage)
1370
    {
1371
        $this->fbPageTabImage = $fbPageTabImage;
1372
1373
        return $this;
1374
    }
1375
1376
    /**
1377
     *
1378
     * @return the unknown_type
1379
     */
1380
    public function getFbShareMessage()
1381
    {
1382
        return $this->fbShareMessage;
1383
    }
1384
1385
    /**
1386
     *
1387
     * @param unknown_type $fbShareMessage
1388
     */
1389
    public function setFbShareMessage($fbShareMessage)
1390
    {
1391
        $this->fbShareMessage = $fbShareMessage;
1392
1393
        return $this;
1394
    }
1395
1396
    /**
1397
     *
1398
     * @return the unknown_type
1399
     */
1400
    public function getFbShareImage()
1401
    {
1402
        return $this->fbShareImage;
1403
    }
1404
1405
    /**
1406
     *
1407
     * @param unknown_type $fbShareImage
1408
     */
1409
    public function setFbShareImage($fbShareImage)
1410
    {
1411
        $this->fbShareImage = $fbShareImage;
1412
1413
        return $this;
1414
    }
1415
1416
    /**
1417
     *
1418
     * @return string unknown_type
1419
     */
1420
    public function getFbRequestMessage()
1421
    {
1422
        return $this->fbRequestMessage;
1423
    }
1424
1425
    /**
1426
     *
1427
     * @param unknown_type $fbRequestMessage
1428
     */
1429
    public function setFbRequestMessage($fbRequestMessage)
1430
    {
1431
        $this->fbRequestMessage = $fbRequestMessage;
1432
1433
        return $this;
1434
    }
1435
1436
    /**
1437
     *
1438
     * @return integer fbFan
1439
     */
1440
    public function getFbFan()
1441
    {
1442
        return $this->fbFan;
1443
    }
1444
1445
    /**
1446
     *
1447
     * @param unknown_type $fbFan
1448
     */
1449
    public function setFbFan($fbFan)
1450
    {
1451
        $this->fbFan = $fbFan;
0 ignored issues
show
Documentation Bug introduced by
It seems like $fbFan of type object<PlaygroundGame\Entity\unknown_type> is incompatible with the declared type integer of property $fbFan.

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...
1452
1453
        return $this;
1454
    }
1455
1456
    /**
1457
     *
1458
     * @return the fbFanGate
1459
     */
1460
    public function getFbFanGate()
1461
    {
1462
        return $this->fbFanGate;
1463
    }
1464
1465
    /**
1466
     *
1467
     * @param unknown_type $fbFanGate
1468
     */
1469
    public function setFbFanGate($fbFanGate)
1470
    {
1471
        $this->fbFanGate = $fbFanGate;
1472
1473
        return $this;
1474
    }
1475
1476
    /**
1477
     *
1478
     * @return the unknown_type
1479
     */
1480
    public function getTwShareMessage()
1481
    {
1482
        return $this->twShareMessage;
1483
    }
1484
1485
    /**
1486
     *
1487
     * @param unknown_type $twShareMessage
1488
     */
1489
    public function setTwShareMessage($twShareMessage)
1490
    {
1491
        $this->twShareMessage = $twShareMessage;
1492
1493
        return $this;
1494
    }
1495
1496
    /**
1497
     *
1498
     * @return DateTime $createdAt
1499
     */
1500
    public function getCreatedAt()
1501
    {
1502
        return $this->createdAt;
1503
    }
1504
1505
    /**
1506
     *
1507
     * @param \DateTime $createdAt
1508
     */
1509
    public function setCreatedAt($createdAt)
1510
    {
1511
        $this->createdAt = $createdAt;
1512
1513
        return $this;
1514
    }
1515
1516
    /**
1517
     *
1518
     * @return DateTime $updatedAt
1519
     */
1520
    public function getUpdatedAt()
1521
    {
1522
        return $this->updatedAt;
1523
    }
1524
1525
    /**
1526
     *
1527
     * @param \DateTime $updatedAt
1528
     */
1529
    public function setUpdatedAt($updatedAt)
1530
    {
1531
        $this->updatedAt = $updatedAt;
1532
1533
        return $this;
1534
    }
1535
1536
    /**
1537
     * Convert the object to an array.
1538
     *
1539
     * @return array
1540
     */
1541
    public function getArrayCopy()
1542
    {
1543
        $obj_vars = get_object_vars($this);
1544
1545 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...
1546
            $obj_vars['publicationDate'] = $obj_vars['publicationDate']->format('d/m/Y');
1547
        }
1548
1549 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...
1550
            $obj_vars['endDate'] = $obj_vars['endDate']->format('d/m/Y');
1551
        }
1552 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...
1553
            $obj_vars['startDate'] = $obj_vars['startDate']->format('d/m/Y');
1554
        }
1555
1556
        return $obj_vars;
1557
    }
1558
1559
    /**
1560
     * Convert the object to json.
1561
     *
1562
     * @return array
1563
     */
1564
    public function jsonSerialize()
1565
    {
1566
        return $this->getArrayCopy();
1567
    }
1568
1569
    /**
1570
     * Populate from an array.
1571
     *
1572
     * @param array $data
1573
     */
1574
    public function populate($data = array())
1575
    {
1576
        if (isset($data['partner']) && $data['partner'] !== null) {
1577
            $this->partner = $data['partner'];
1578
        }
1579
1580
        $this->title = (isset($data['title'])) ? $data['title'] : null;
1581
        $this->type = (isset($data['type']) && $data['type'] !== null) ? $data['type'] : null;
1582
1583
        if (isset($data['mainImage']) && $data['mainImage'] !== null) {
1584
            $this->mainImage = $data['mainImage'];
1585
        }
1586
1587
        if (isset($data['secondImage']) && $data['secondImage'] !== null) {
1588
            $this->secondImage = $data['secondImage'];
1589
        }
1590
1591 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...
1592
            $this->active = $data['active'];
1593
        }
1594
1595
        $this->layout           = (isset($data['layout'])) ? $data['layout'] : null;
1596
        $this->stylesheet       = (isset($data['stylesheet'])) ? $data['stylesheet'] : null;
1597
1598
        $this->pushHome         = (isset($data['pushHome']) && $data['pushHome'] !== null) ? $data['pushHome'] : 0;
1599
        $this->displayHome      = (isset($data['displayHome']) && $data['displayHome'] !== null) ?
1600
            $data['displayHome'] :
1601
            0;
1602
        $this->prizeCategory   = (isset($data['prizeCategory'])) ? $data['prizeCategory'] : null;
1603
1604
        $this->publicationDate  = (isset($data['publicationDate']) && $data['publicationDate'] !== null) ?
1605
            DateTime::createFromFormat('d/m/Y', $data['publicationDate']) :
1606
            null;
1607
        $this->endDate         = (isset($data['endDate']) && $data['endDate'] !== null) ?
1608
            DateTime::createFromFormat('d/m/Y', $data['endDate']) :
1609
            null;
1610
        $this->startDate       = (isset($data['startDate']) && $data['startDate'] !== null) ?
1611
            DateTime::createFromFormat('d/m/Y', $data['startDate']) :
1612
            null;
1613
1614
        $this->identifier       = (isset($data['identifier'])) ? $data['identifier'] : null;
1615
        $this->welcomeBlock    = (isset($data['welcomeBlock'])) ? $data['welcomeBlock'] : null;
1616
        $this->termsBlock       = (isset($data['termsBlock'])) ? $data['termsBlock'] : null;
1617
        $this->conditionsBlock  = (isset($data['conditionsBlock'])) ? $data['conditionsBlock'] : null;
1618
        $this->columnBlock1     = (isset($data['columnBlock1'])) ? $data['columnBlock1'] : null;
1619
        $this->columnBlock2     = (isset($data['columnBlock2'])) ? $data['columnBlock2'] : null;
1620
        $this->columnBlock3     = (isset($data['columnBlock3'])) ? $data['columnBlock3'] : null;
1621
1622
        $this->fbShareMessage   = (isset($data['fbShareMessage'])) ? $data['fbShareMessage'] : null;
1623
        $this->fbShareImage     = (isset($data['fbShareImage'])) ? $data['fbShareImage'] : null;
1624
        $this->fbRequestMessage = (isset($data['fbRequestMessage'])) ? $data['fbRequestMessage'] : null;
1625
        $this->twShareMessage   = (isset($data['twShareMessage'])) ? $data['twShareMessage'] : null;
1626
    }
1627
1628
    public function setInputFilter(InputFilterInterface $inputFilter)
1629
    {
1630
        throw new \Exception("Not used");
1631
    }
1632
1633
    public function getInputFilter()
1634
    {
1635
        if (! $this->inputFilter) {
1636
            $inputFilter = new InputFilter();
1637
            $factory = new InputFactory();
1638
1639
            $inputFilter->add($factory->createInput(array(
1640
                'name' => 'id',
1641
                'required' => true,
1642
                'filters' => array(
1643
                    array(
1644
                        'name' => 'Int'
1645
                    )
1646
                )
1647
            )));
1648
1649
            $inputFilter->add($factory->createInput(array(
1650
                    'name' => 'partner',
1651
                    'required' => false
1652
            )));
1653
1654
            $inputFilter->add($factory->createInput(array(
1655
                'name' => 'fbAppId',
1656
                'required' => false
1657
            )));
1658
1659
            $inputFilter->add($factory->createInput(array(
1660
                   'name' => 'fbFan',
1661
                   'required' => false
1662
            )));
1663
1664
            $inputFilter->add($factory->createInput(array(
1665
                    'name' => 'fbFanGate',
1666
                    'required' => false
1667
            )));
1668
1669
            $inputFilter->add($factory->createInput(array(
1670
                'name' => 'prizes',
1671
                'required' => false
1672
            )));
1673
1674
            $inputFilter->add($factory->createInput(array(
1675
                'name' => 'title',
1676
                'required' => true,
1677
                'filters' => array(
1678
                    array(
1679
                        'name' => 'StripTags'
1680
                    ),
1681
                    array(
1682
                        'name' => 'StringTrim'
1683
                    )
1684
                ),
1685
                'validators' => array(
1686
                    array(
1687
                        'name' => 'StringLength',
1688
                        'options' => array(
1689
                            'encoding' => 'UTF-8',
1690
                            'min' => 5,
1691
                            'max' => 255
1692
                        )
1693
                    )
1694
                )
1695
            )));
1696
1697
            $inputFilter->add($factory->createInput(array(
1698
                    'name' => 'publicationDate',
1699
                    'required' => false,
1700
            )));
1701
1702
            $inputFilter->add($factory->createInput(array(
1703
                'name' => 'startDate',
1704
                'required' => false,
1705
            )));
1706
1707
            $inputFilter->add($factory->createInput(array(
1708
                'name' => 'endDate',
1709
                'required' => false,
1710
            )));
1711
1712
            $inputFilter->add($factory->createInput(array(
1713
               'name' => 'closeDate',
1714
               'required' => false,
1715
            )));
1716
1717
            $inputFilter->add($factory->createInput(array(
1718
                'name' => 'termsOptin',
1719
                'required' => false,
1720
            )));
1721
1722
            $inputFilter->add($factory->createInput(array(
1723
                'name' => 'identifier',
1724
                'required' => true,
1725
                'filters' => array(
1726
                    array(
1727
                        'name' => 'StripTags'
1728
                    ),
1729
                    array(
1730
                        'name' => 'StringTrim'
1731
                    ),
1732
                    array(
1733
                        'name' => 'PlaygroundCore\Filter\Slugify'
1734
                    )
1735
                ),
1736
                'validators' => array(
1737
                    array(
1738
                        'name' => 'StringLength',
1739
                        'options' => array(
1740
                            'encoding' => 'UTF-8',
1741
                            'min' => 3,
1742
                            'max' => 255
1743
                        )
1744
                    )
1745
                )
1746
            )));
1747
1748
            $inputFilter->add($factory->createInput(array(
1749
                'name'     => 'playLimit',
1750
                'required' => false,
1751
                'validators' => array(
1752
                    array(
1753
                        'name'    => 'Between',
1754
                        'options' => array(
1755
                            'min'      => 0,
1756
                            'max'      => 999999,
1757
                        ),
1758
                    ),
1759
                ),
1760
            )));
1761
1762
            $inputFilter->add($factory->createInput(array(
1763
                'name' => 'playLimitScale',
1764
                'required' => false,
1765
                'validators' => array(
1766
                    array(
1767
                        'name' => 'InArray',
1768
                        'options' => array(
1769
                            'haystack' => array('day', 'week', 'month', 'year', 'always'),
1770
                        ),
1771
                    ),
1772
                ),
1773
            )));
1774
1775
            $inputFilter->add($factory->createInput(array(
1776
                'name' => 'playBonus',
1777
                'required' => false,
1778
                'validators' => array(
1779
                    array(
1780
                        'name' => 'InArray',
1781
                        'options' => array(
1782
                            'haystack' => array('none', 'per_entry', 'one'),
1783
                        ),
1784
                    ),
1785
                ),
1786
            )));
1787
1788
            $inputFilter->add($factory->createInput(array(
1789
                'name' => 'active',
1790
                'required' => true
1791
            )));
1792
1793
            $inputFilter->add($factory->createInput(array(
1794
                'name' => 'displayHome',
1795
                'required' => false
1796
            )));
1797
1798
            $inputFilter->add($factory->createInput(array(
1799
                'name' => 'pushHome',
1800
                'required' => false
1801
            )));
1802
1803
            $inputFilter->add($factory->createInput(array(
1804
                'name' => 'prizeCategory',
1805
                'required' => false,
1806
                'filters' => array(
1807
                    array(
1808
                        'name' => 'Int'
1809
                    )
1810
                )
1811
            )));
1812
1813
            $inputFilter->add($factory->createInput(array(
1814
                'name' => 'fbPageTabTitle',
1815
                'required' => false
1816
            )));
1817
1818
            $inputFilter->add($factory->createInput(array(
1819
                'name' => 'fbPageTabImage',
1820
                'required' => false
1821
            )));
1822
1823
            $inputFilter->add($factory->createInput(array(
1824
                'name' => 'layout',
1825
                'required' => false,
1826
                'filters' => array(
1827
                    array(
1828
                        'name' => 'StripTags'
1829
                    ),
1830
                    array(
1831
                        'name' => 'StringTrim'
1832
                    )
1833
                ),
1834
                'validators' => array(
1835
                    array(
1836
                        'name' => 'StringLength',
1837
                        'options' => array(
1838
                            'encoding' => 'UTF-8',
1839
                            'min' => 0,
1840
                            'max' => 255
1841
                        )
1842
                    )
1843
                )
1844
            )));
1845
1846
            $inputFilter->add($factory->createInput(array(
1847
                'name' => 'stylesheet',
1848
                'required' => false,
1849
                'filters' => array(
1850
                    array(
1851
                        'name' => 'StripTags'
1852
                    ),
1853
                    array(
1854
                        'name' => 'StringTrim'
1855
                    )
1856
                ),
1857
                'validators' => array(
1858
                    array(
1859
                        'name' => 'StringLength',
1860
                        'options' => array(
1861
                            'encoding' => 'UTF-8',
1862
                            'min' => 0,
1863
                            'max' => 255
1864
                        )
1865
                    )
1866
                )
1867
            )));
1868
1869
            $inputFilter->add($factory->createInput(array(
1870
                'name' => 'fbShareImage',
1871
                'required' => false,
1872
                'filters' => array(
1873
                    array(
1874
                        'name' => 'StripTags'
1875
                    ),
1876
                    array(
1877
                        'name' => 'StringTrim'
1878
                    )
1879
                ),
1880
                'validators' => array(
1881
                    array(
1882
                        'name' => 'StringLength',
1883
                        'options' => array(
1884
                            'encoding' => 'UTF-8',
1885
                            'min' => 1,
1886
                            'max' => 255
1887
                        )
1888
                    )
1889
                )
1890
            )));
1891
1892
            $inputFilter->add($factory->createInput(array(
1893
                    'name' => 'fbShareMessage',
1894
                    'required' => false,
1895
                    'filters' => array(
1896
                            array(
1897
                                    'name' => 'StripTags'
1898
                            ),
1899
                            array(
1900
                                    'name' => 'StringTrim'
1901
                            )
1902
                    ),
1903
                    'validators' => array(
1904
                        array(
1905
                            'name' => 'StringLength',
1906
                            'options' => array(
1907
                                'encoding' => 'UTF-8',
1908
                                'min' => 1,
1909
                                'max' => 500
1910
                             )
1911
                        )
1912
                    )
1913
            )));
1914
1915
            $inputFilter->add($factory->createInput(array(
1916
                'name' => 'fbRequestMessage',
1917
                'required' => false,
1918
                'filters' => array(
1919
                    array(
1920
                        'name' => 'StripTags'
1921
                    ),
1922
                    array(
1923
                        'name' => 'StringTrim'
1924
                    )
1925
                ),
1926
                'validators' => array(
1927
                    array(
1928
                        'name' => 'StringLength',
1929
                        'options' => array(
1930
                            'encoding' => 'UTF-8',
1931
                            'min' => 1,
1932
                            'max' => 500
1933
                        )
1934
                    )
1935
                )
1936
            )));
1937
1938
            $inputFilter->add($factory->createInput(array(
1939
                'name' => 'twShareMessage',
1940
                'required' => false,
1941
                'filters' => array(
1942
                    array(
1943
                        'name' => 'StripTags'
1944
                    ),
1945
                    array(
1946
                        'name' => 'StringTrim'
1947
                    )
1948
                ),
1949
                'validators' => array(
1950
                    array(
1951
                        'name' => 'StringLength',
1952
                        'options' => array(
1953
                            'encoding' => 'UTF-8',
1954
                            'min' => 1,
1955
                            'max' => 255
1956
                        )
1957
                    )
1958
                )
1959
            )));
1960
            
1961
            $inputFilter->add($factory->createInput(array(
1962
                'name' => 'anonymousIdentifier',
1963
                'required' => false,
1964
                'filters' => array(
1965
                    array(
1966
                        'name' => 'StripTags'
1967
                    ),
1968
                    array(
1969
                        'name' => 'StringTrim'
1970
                    )
1971
                ),
1972
                'validators' => array(
1973
                    array(
1974
                        'name' => 'StringLength',
1975
                        'options' => array(
1976
                            'encoding' => 'UTF-8',
1977
                            'min' => 0,
1978
                            'max' => 255
1979
                        )
1980
                    )
1981
                )
1982
            )));
1983
1984
            $this->inputFilter = $inputFilter;
1985
        }
1986
1987
        return $this->inputFilter;
1988
    }
1989
1990
    public function setTranslatableLocale($locale)
1991
    {
1992
        $this->locale = $locale;
1993
    }
1994
}
1995