Completed
Pull Request — master (#254)
by greg
03:06
created

InstantWinOccurrence::getEntry()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace PlaygroundGame\Entity;
4
5
use DateTime;
6
use Doctrine\Common\Collections\ArrayCollection;
7
use Doctrine\ORM\Mapping as ORM;
8
use Doctrine\ORM\Mapping\HasLifecycleCallbacks;
9
use Doctrine\ORM\Mapping\PrePersist;
10
use Doctrine\ORM\Mapping\PreUpdate;
11
use Zend\InputFilter\InputFilter;
12
use Zend\InputFilter\Factory as InputFactory;
13
use Zend\InputFilter\InputFilterAwareInterface;
14
use Zend\InputFilter\InputFilterInterface;
15
16
/**
17
 * @ORM\Entity @HasLifecycleCallbacks
18
 * @ORM\Table(name="game_instantwin_occurrence")
19
 */
20
class InstantWinOccurrence implements InputFilterAwareInterface, \JsonSerializable
21
{
22
    protected $inputFilter;
23
24
    /**
25
     * @ORM\Id
26
     * @ORM\Column(type="integer");
27
     * @ORM\GeneratedValue(strategy="AUTO")
28
     */
29
    protected $id;
30
31
    /**
32
     * @ORM\ManyToOne(targetEntity="InstantWin", inversedBy="occurrences", cascade={"persist","remove"})
33
     * @ORM\JoinColumn(name="instantwin_id", referencedColumnName="id", onDelete="CASCADE")
34
     */
35
    protected $instantwin;
36
37
    /**
38
     * @ORM\Column(type="string")
39
     */
40
    protected $value;
41
42
    /**
43
     * @ORM\Column(type="boolean", nullable=true)
44
     */
45
    protected $active = 1;
46
47
    /**
48
     * @ORM\Column(type="boolean", nullable=true)
49
     */
50
    protected $winning = 1;
51
52
    /**
53
     * @ORM\ManyToOne(targetEntity="PlaygroundUser\Entity\User")
54
     * @ORM\JoinColumn(name="user_id", referencedColumnName="user_id")
55
     **/
56
    protected $user;
57
58
    /**
59
     * @ORM\OneToOne(targetEntity="Entry")
60
     * @ORM\JoinColumn(name="entry_id", referencedColumnName="id", onDelete="CASCADE")
61
     */
62
    protected $entry;
63
64
    /**
65
     * @ORM\ManyToOne(targetEntity="Prize")
66
     * @ORM\JoinColumn(name="prize_id", referencedColumnName="id", onDelete="CASCADE")
67
     **/
68
    protected $prize;
69
70
    /**
71
     * @ORM\Column(type="datetime", name="created_at")
72
     */
73
    protected $createdAt;
74
75
    /**
76
     * @ORM\Column(type="datetime", name="updated_at")
77
     */
78
    protected $updatedAt;
79
80
    public function __construct()
81
    {
82
        $this->answers = new ArrayCollection();
83
    }
84
85
    /**
86
     * @PrePersist
87
     */
88
    public function createChrono()
89
    {
90
        $this->createdAt = new \DateTime("now");
91
        $this->updatedAt = new \DateTime("now");
92
    }
93
94
    /**
95
     * @PreUpdate
96
     */
97
    public function updateChrono()
98
    {
99
        $this->updatedAt = new \DateTime("now");
100
    }
101
102
    /**
103
     * @return the unknown_type
104
     */
105
    public function getId()
106
    {
107
        return $this->id;
108
    }
109
110
    /**
111
     * @param unknown_type $id
112
     */
113
    public function setId($id)
114
    {
115
        $this->id = $id;
116
117
        return $this;
118
    }
119
120
    /**
121
     * @return the unknown_type
122
     */
123
    public function getInstantwin()
124
    {
125
        return $this->instantwin;
126
    }
127
128
    /**
129
     * @param unknown_type $instantwin
130
     */
131
    public function setInstantwin($instantwin)
132
    {
133
        $this->instantwin = $instantwin;
134
135
        return $this;
136
    }
137
138
    /**
139
     * @return the unknown_type
140
     */
141
    public function getPrize()
142
    {
143
        return $this->prize;
144
    }
145
146
    /**
147
     * @param unknown_type $prize
148
     */
149
    public function setPrize($prize)
150
    {
151
        $this->prize = $prize;
152
153
        return $this;
154
    }
155
156
    /**
157
     * @return string unknown_type
158
     */
159
    public function getValue()
160
    {
161
        return $this->value;
162
    }
163
164
    /**
165
     * @param string $value
166
     */
167
    public function setValue($value)
168
    {
169
        $this->value = $value;
170
171
        return $this;
172
    }
173
174
    /**
175
     * @return integer unknown_type
176
     */
177
    public function getActive()
178
    {
179
        return $this->active;
180
    }
181
182
    /**
183
     * @param integer $active
184
     */
185
    public function setActive($active)
186
    {
187
        $this->active = $active;
188
189
        return $this;
190
    }
191
192
    /**
193
     * @return integer unknown_type
194
     */
195
    public function getWinning()
196
    {
197
        return $this->winning;
198
    }
199
200
    /**
201
     * @param boolean $winning
202
     */
203
    public function setWinning($winning)
204
    {
205
        $this->winning = $winning;
0 ignored issues
show
Documentation Bug introduced by
The property $winning was declared of type integer, but $winning 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...
206
207
        return $this;
208
    }
209
210
    /**
211
     * @return the $user
212
     */
213
    public function getUser()
214
    {
215
        return $this->user;
216
    }
217
218
    /**
219
     * @param field_type $user
220
     */
221
    public function setUser($user)
222
    {
223
        $this->user = $user;
224
        
225
        return $this;
226
    }
227
228
    /**
229
     * @return PlaygroundGame\Entity\Entry
230
     */
231
    public function getEntry()
232
    {
233
        return $this->entry;
234
    }
235
236
    /**
237
     * @param PlaygroundGame\Entity\Entry $entry
238
     */
239
    public function setEntry($entry)
240
    {
241
        $this->entry = $entry;
242
243
        return $this;
244
    }
245
246
    /**
247
     * @return the unknown_type
248
     */
249
    public function getCreatedAt()
250
    {
251
        return $this->createdAt;
252
    }
253
254
    /**
255
     * @param unknown_type $createdAt
256
     */
257
    public function setCreatedAt($createdAt)
258
    {
259
        $this->createdAt = $createdAt;
260
261
        return $this;
262
    }
263
264
    /**
265
     * @return the unknown_type
266
     */
267
    public function getUpdatedAt()
268
    {
269
        return $this->updatedAt;
270
    }
271
272
    /**
273
     * @param unknown_type $updatedAt
274
     */
275
    public function setUpdatedAt($updatedAt)
276
    {
277
        $this->updatedAt = $updatedAt;
278
279
        return $this;
280
    }
281
282
    /**
283
     * Convert the object to an array.
284
     *
285
     * @return array
286
     */
287
    public function getArrayCopy()
288
    {
289
        $obj_vars = get_object_vars($this);
290
        return $obj_vars;
291
    }
292
293
    /**
294
    * Convert the object to json.
295
    *
296
    * @return array
297
    */
298
    public function jsonSerialize()
299
    {
300
        return $this->getArrayCopy();
301
    }
302
303
    /**
304
     * Populate from an array.
305
     *
306
     * @param array $data
307
     */
308
    public function populate($data = array())
309
    {
310
        $this->value = (isset($data['value']) && $data['value'] !== null) ? $data['value'] : null;
311
        $this->active = (isset($data['active']) && $data['active'] !== null) ? $data['active'] : null;
312
        $this->winning = (isset($data['winning']) && $data['winning'] !== null) ? $data['winning'] : null;
313
    }
314
315
    public function setInputFilter(InputFilterInterface $inputFilter)
316
    {
317
        throw new \Exception("Not used");
318
    }
319
320
    public function getInputFilter()
321
    {
322
        if (!$this->inputFilter) {
323
            $inputFilter = new InputFilter();
324
            $factory = new InputFactory();
325
326
            $inputFilter->add($factory->createInput(array(
327
                'name'       => 'id',
328
                'required'   => true,
329
                'filters'    => array(
330
                    array('name' => 'Int'),
331
                ),
332
            )));
333
334
            $inputFilter->add($factory->createInput(array(
335
                'name' => 'active',
336
                'required' => true,
337
            )));
338
339
            $inputFilter->add($factory->createInput(array(
340
                'name' => 'winning',
341
                'required' => true,
342
            )));
343
344
            $inputFilter->add($factory->createInput(array(
345
                    'name' => 'prize',
346
                    'required' => false,
347
            )));
348
349
            $this->inputFilter = $inputFilter;
350
        }
351
352
        return $this->inputFilter;
353
    }
354
}
355