Completed
Push — develop ( 5dae5d...f6975e )
by greg
02:34
created

PostVote::setMailModerationValidatedSubject()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
namespace PlaygroundGame\Entity;
3
4
use PlaygroundGame\Entity\Game;
5
use Doctrine\Common\Collections\ArrayCollection;
6
use Gedmo\Mapping\Annotation as Gedmo;
7
use Gedmo\Translatable\Translatable;
8
use Doctrine\ORM\Mapping as ORM;
9
use Doctrine\ORM\Mapping\HasLifecycleCallbacks;
10
use Zend\InputFilter\InputFilter;
11
use Zend\InputFilter\Factory as InputFactory;
12
use Zend\InputFilter\InputFilterAwareInterface;
13
use Zend\InputFilter\InputFilterInterface;
14
15
/**
16
 * @ORM\Entity @HasLifecycleCallbacks
17
 * @ORM\Table(name="game_postvote")
18
 */
19
class PostVote extends Game implements InputFilterAwareInterface
20
{
21
    const CLASSTYPE = 'postvote';
22
23
    /**
24
     * Display mode of Posts :
25
     * 'date' : sort by post date desc
26
     * 'random' : ...
27
     * 'votes' : sort by number of vote desc
28
     *
29
     * @ORM\Column(name="post_display_mode", type="string", nullable=false)
30
     */
31
    protected $postDisplayMode = 'date';
32
33
    /**
34
     * Number of Post displayed :
35
     * 0 : infinite
36
     *
37
     * @ORM\Column(name="post_display_number", type="integer", nullable=false)
38
     */
39
    protected $postDisplayNumber = 0;
40
41
    /**
42
     * Is it possible to vote ?
43
     * @ORM\Column(name="vote_active", type="boolean", nullable=false)
44
     */
45
    protected $voteActive = 1;
46
47
    /**
48
     * Is it possible to vote anonymously ?
49
     * @ORM\Column(name="vote_anonymous", type="boolean", nullable=false)
50
     */
51
    protected $voteAnonymous;
52
53
    /**
54
     * Type of moderation : moderate posts before their publication, or after their publication (default)
55
     * @ORM\Column(name="moderation_type", type="boolean", nullable=false, options={"default" = 0})
56
     */
57
    protected $moderationType = 0;
58
59
        /**
60
     * @ORM\Column(name="mail_moderation_validated",type="boolean", nullable=true)
61
     */
62
    protected $mailModerationValidated = 0;
63
64
    /**
65
     * @Gedmo\Translatable
66
     * @ORM\Column(name="mail_moderation_validated_subject",type="string", nullable=true)
67
     */
68
    protected $mailModerationValidatedSubject;
69
70
    /**
71
     * @Gedmo\Translatable
72
     * @ORM\Column(name="mail_moderation_validated_block", type="text", nullable=true)
73
     */
74
    protected $mailModerationValidatedBlock;
75
76
    /**
77
     * @ORM\Column(name="mail_moderation_rejected",type="boolean", nullable=true)
78
     */
79
    protected $mailModerationRejected = 0;
80
81
    /**
82
     * @Gedmo\Translatable
83
     * @ORM\Column(name="mail_moderation_rejected_subject", type="string", nullable=true)
84
     */
85
    protected $mailModerationRejectedSubject;
86
87
    /**
88
     * @Gedmo\Translatable
89
     * @ORM\Column(name="mail_moderation_rejected_block", type="text", nullable=true)
90
     */
91
    protected $mailModerationRejectedBlock;
92
93
    /**
94
     * @ORM\OneToOne(targetEntity="PostVoteForm", mappedBy="postvote", cascade={"persist","remove"})
95
     **/
96
    private $form;
97
98
    /**
99
     * @ORM\OneToMany(targetEntity="PostVotePost", mappedBy="postvote")
100
     **/
101
    private $posts;
102
103
    public function __construct()
104
    {
105
        parent::__construct();
106
        $this->setClassType(self::CLASSTYPE);
107
        $this->posts = new ArrayCollection();
108
    }
109
110
    /**
111
     * Add a post to the game
112
     *
113
     * @param PostVotePost $post
114
     *
115
     * @return void
116
     */
117
    public function addPost($post)
118
    {
119
        $this->post[] = $post;
120
    }
121
122
    public function getPosts()
123
    {
124
        return $this->posts;
125
    }
126
127
    public function setPosts($posts)
128
    {
129
        $this->posts = $posts;
130
131
        return $this;
132
    }
133
134
    /**
135
     * @return the unknown_type
136
     */
137
    public function getForm()
138
    {
139
        return $this->form;
140
    }
141
142
    /**
143
     * @param unknown_type $form
144
     */
145
    public function setForm($form)
146
    {
147
        $this->form = $form;
148
149
        return $this;
150
    }
151
152
    /**
153
     * @return string unknown_type
154
     */
155
    public function getPostDisplayMode()
156
    {
157
        return $this->postDisplayMode;
158
    }
159
160
    /**
161
     * @param unknown_type $postDisplayMode
162
     */
163
    public function setPostDisplayMode($postDisplayMode)
164
    {
165
        $this->postDisplayMode = $postDisplayMode;
0 ignored issues
show
Documentation Bug introduced by
It seems like $postDisplayMode of type object<PlaygroundGame\Entity\unknown_type> is incompatible with the declared type string of property $postDisplayMode.

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...
166
167
        return $this;
168
    }
169
170
    /**
171
     * @return int
172
     */
173
    public function getPostDisplayNumber()
174
    {
175
        return $this->postDisplayNumber;
176
    }
177
178
    /**
179
     * @param int $postDisplayNumber
180
     *
181
     * @return PostVote
182
     */
183
    public function setPostDisplayNumber($postDisplayNumber)
184
    {
185
        $this->postDisplayNumber = $postDisplayNumber;
186
187
        return $this;
188
    }
189
190
    /**
191
     * @return the unknown_type
192
     */
193
    public function getVoteActive()
194
    {
195
        return $this->voteActive;
196
    }
197
198
    /**
199
     * @param unknown_type $voteActive
200
     */
201
    public function setVoteActive($voteActive)
202
    {
203
        $this->voteActive = $voteActive;
0 ignored issues
show
Documentation Bug introduced by
It seems like $voteActive of type object<PlaygroundGame\Entity\unknown_type> is incompatible with the declared type integer of property $voteActive.

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...
204
205
        return $this;
206
    }
207
208
    /**
209
     * @return the unknown_type
210
     */
211
    public function getVoteAnonymous()
212
    {
213
        return $this->voteAnonymous;
214
    }
215
216
    /**
217
     * @param unknown_type $voteAnonymous
218
     */
219
    public function setVoteAnonymous($voteAnonymous)
220
    {
221
        $this->voteAnonymous = $voteAnonymous;
222
223
        return $this;
224
    }
225
226
    /**
227
     * @return bool
228
     */
229
    public function getModerationType()
230
    {
231
        return $this->moderationType;
232
    }
233
234
    /**
235
     * @param bool $moderationType
236
     */
237
    public function setModerationType($moderationType)
238
    {
239
        $this->moderationType = $moderationType;
0 ignored issues
show
Documentation Bug introduced by
The property $moderationType was declared of type integer, but $moderationType is of type boolean. 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...
240
241
        return $this;
242
    }
243
244
    /**
245
     * @return bool
246
     */
247
    public function getMailModerationValidated()
248
    {
249
        return $this->mailModerationValidated;
250
    }
251
252
    /**
253
     * @param bool $mailModerationValidated
254
     */
255
    public function setMailModerationValidated($mailModerationValidated)
256
    {
257
        $this->mailModerationValidated = $mailModerationValidated;
0 ignored issues
show
Documentation Bug introduced by
The property $mailModerationValidated was declared of type integer, but $mailModerationValidated is of type boolean. 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...
258
259
        return $this;
260
    }
261
262
    /**
263
     * @return bool
264
     */
265
    public function getMailModerationValidatedSubject()
266
    {
267
        return $this->mailModerationValidatedSubject;
268
    }
269
270
    /**
271
     * @param bool $mailModerationValidatedSubject
272
     */
273
    public function setMailModerationValidatedSubject($mailModerationValidatedSubject)
274
    {
275
        $this->mailModerationValidatedSubject = $mailModerationValidatedSubject;
276
277
        return $this;
278
    }
279
280
    /**
281
     * @return bool
282
     */
283
    public function getMailModerationValidatedBlock()
284
    {
285
        return $this->mailModerationValidatedBlock;
286
    }
287
288
    /**
289
     * @param bool $mailModerationValidatedBlock
290
     */
291
    public function setMailModerationValidatedBlock($mailModerationValidatedBlock)
292
    {
293
        $this->mailModerationValidatedBlock = $mailModerationValidatedBlock;
294
295
        return $this;
296
    }
297
298
    /**
299
     * @return bool
300
     */
301
    public function getMailModerationRejected()
302
    {
303
        return $this->mailModerationRejected;
304
    }
305
306
    /**
307
     * @param bool $mailModerationRejected
308
     */
309
    public function setMailModerationRejected($mailModerationRejected)
310
    {
311
        $this->mailModerationRejected = $mailModerationRejected;
0 ignored issues
show
Documentation Bug introduced by
The property $mailModerationRejected was declared of type integer, but $mailModerationRejected is of type boolean. 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...
312
313
        return $this;
314
    }
315
316
    /**
317
     * @return bool
318
     */
319
    public function getMailModerationRejectedSubject()
320
    {
321
        return $this->mailModerationRejectedSubject;
322
    }
323
324
    /**
325
     * @param bool $mailModerationRejectedSubject
326
     */
327
    public function setMailModerationRejectedSubject($mailModerationRejectedSubject)
328
    {
329
        $this->mailModerationRejectedSubject = $mailModerationRejectedSubject;
330
331
        return $this;
332
    }
333
334
    /**
335
     * @return bool
336
     */
337
    public function getMailModerationRejectedBlock()
338
    {
339
        return $this->mailModerationRejectedBlock;
340
    }
341
342
    /**
343
     * @param bool $mailModerationRejectedBlock
344
     */
345
    public function setMailModerationRejectedBlock($mailModerationRejectedBlock)
346
    {
347
        $this->mailModerationRejectedBlock = $mailModerationRejectedBlock;
348
349
        return $this;
350
    }
351
352
    /**
353
     * Convert the object to an array.
354
     *
355
     * @return array
356
     */
357
    public function getArrayCopy()
358
    {
359
        $obj_vars = parent::getArrayCopy();
360
        array_merge($obj_vars, get_object_vars($this));
361
362
        return $obj_vars;
363
    }
364
365
    /**
366
     * Populate from an array.
367
     *
368
     * @param array $data
369
     */
370 View Code Duplication
    public function populate($data = array())
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...
371
    {
372
        parent::populate($data);
373
374
        if (isset($data['postDisplayMode']) && $data['postDisplayMode'] !== null) {
375
            $this->postDisplayMode = $data['postDisplayMode'];
376
        }
377
378
        if (isset($data['voteAnonymous']) && $data['voteAnonymous'] !== null) {
379
            $this->voteAnonymous = $data['voteAnonymous'];
380
        }
381
    }
382
383
    public function setInputFilter(InputFilterInterface $inputFilter)
384
    {
385
        throw new \Exception("Not used");
386
    }
387
388
    public function getInputFilter()
389
    {
390
        if (!$this->inputFilter) {
391
            $inputFilter = new InputFilter();
0 ignored issues
show
Unused Code introduced by
$inputFilter is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
392
            $factory = new InputFactory();
393
394
            $inputFilter = parent::getInputFilter();
395
396
            $inputFilter->add(
397
                $factory->createInput(
398
                    array(
399
                        'name' => 'postDisplayMode',
400
                        'required' => false,
401
                        'validators' => array(
402
                            array(
403
                                'name' => 'InArray',
404
                                'options' => array(
405
                                    'haystack' => array('date', 'vote', 'random'),
406
                                ),
407
                            ),
408
                        ),
409
                    )
410
                )
411
            );
412
413
            $inputFilter->add(
414
                $factory->createInput(
415
                    array(
416
                        'name' => 'voteActive',
417
                        'required' => true,
418
                        'validators' => array(
419
                            array(
420
                                'name' => 'Between',
421
                                'options' => array('min' => 0, 'max' => 1),
422
                            ),
423
                        ),
424
                    )
425
                )
426
            );
427
428
            $inputFilter->add(
429
                $factory->createInput(
430
                    array(
431
                        'name' => 'voteAnonymous',
432
                        'required' => true,
433
                        'validators' => array(
434
                            array(
435
                                'name' => 'Between',
436
                                'options' => array('min' => 0, 'max' => 1),
437
                            ),
438
                        ),
439
                    )
440
                )
441
            );
442
443
            $inputFilter->add(
444
                $factory->createInput(
445
                    array(
446
                        'name' => 'moderationType',
447
                        'required' => false,
448
                        'validators' => array(
449
                            array(
450
                                'name' => 'Between',
451
                                'options' => array('min' => 0, 'max' => 1),
452
                            ),
453
                        ),
454
                    )
455
                )
456
            );
457
458
            $this->inputFilter = $inputFilter;
459
        }
460
461
        return $this->inputFilter;
462
    }
463
}
464