|
1
|
|
|
<?php |
|
2
|
|
|
namespace PlaygroundGame\Entity; |
|
3
|
|
|
|
|
4
|
|
|
use PlaygroundGame\Entity\Game; |
|
5
|
|
|
use Doctrine\ORM\Mapping as ORM; |
|
6
|
|
|
use Doctrine\ORM\Mapping\HasLifecycleCallbacks; |
|
7
|
|
|
use Zend\InputFilter\InputFilter; |
|
8
|
|
|
use Zend\InputFilter\Factory as InputFactory; |
|
9
|
|
|
use Zend\InputFilter\InputFilterAwareInterface; |
|
10
|
|
|
use Zend\InputFilter\InputFilterInterface; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* @ORM\Entity @HasLifecycleCallbacks |
|
14
|
|
|
* @ORM\Table(name="game_lottery") |
|
15
|
|
|
*/ |
|
16
|
|
|
class Lottery extends Game implements InputFilterAwareInterface |
|
17
|
|
|
{ |
|
18
|
|
|
const CLASSTYPE = 'lottery'; |
|
19
|
|
|
/** |
|
20
|
|
|
* Automatic Draw |
|
21
|
|
|
* @ORM\Column(name="draw_auto", type="boolean", nullable=false) |
|
22
|
|
|
*/ |
|
23
|
|
|
protected $drawAuto = 0; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* @ORM\Column(name="draw_date", type="datetime", nullable=true) |
|
27
|
|
|
*/ |
|
28
|
|
|
protected $drawDate; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* @ORM\Column(type="integer", nullable=false) |
|
32
|
|
|
*/ |
|
33
|
|
|
protected $winners; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* @ORM\Column(type="integer", nullable=false) |
|
37
|
|
|
*/ |
|
38
|
|
|
protected $substitutes; |
|
39
|
|
|
|
|
40
|
|
|
public function __construct() |
|
41
|
|
|
{ |
|
42
|
|
|
parent::__construct(); |
|
43
|
|
|
$this->setClassType(self::CLASSTYPE); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* @return integer |
|
48
|
|
|
*/ |
|
49
|
|
|
public function getDrawAuto() |
|
50
|
|
|
{ |
|
51
|
|
|
return $this->drawAuto; |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* @param integer $drawAuto |
|
56
|
|
|
*/ |
|
57
|
|
|
public function setDrawAuto($drawAuto) |
|
58
|
|
|
{ |
|
59
|
|
|
$this->drawAuto = $drawAuto; |
|
60
|
|
|
|
|
61
|
|
|
return $this; |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* @return integer |
|
66
|
|
|
*/ |
|
67
|
|
|
public function getWinners() |
|
68
|
|
|
{ |
|
69
|
|
|
return $this->winners; |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* @param integer $winners |
|
74
|
|
|
*/ |
|
75
|
|
|
public function setWinners($winners) |
|
76
|
|
|
{ |
|
77
|
|
|
$this->winners = $winners; |
|
78
|
|
|
|
|
79
|
|
|
return $this; |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* @return integer |
|
84
|
|
|
*/ |
|
85
|
|
|
public function getSubstitutes() |
|
86
|
|
|
{ |
|
87
|
|
|
return $this->substitutes; |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
/** |
|
91
|
|
|
* @param integer $substitutes |
|
92
|
|
|
*/ |
|
93
|
|
|
public function setSubstitutes($substitutes) |
|
94
|
|
|
{ |
|
95
|
|
|
$this->substitutes = $substitutes; |
|
96
|
|
|
|
|
97
|
|
|
return $this; |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
/** |
|
101
|
|
|
* @return \DateTime |
|
102
|
|
|
*/ |
|
103
|
|
|
public function getDrawDate() |
|
104
|
|
|
{ |
|
105
|
|
|
return $this->drawDate; |
|
106
|
|
|
} |
|
107
|
|
|
|
|
108
|
|
|
/** |
|
109
|
|
|
* @param \DateTime $drawDate |
|
110
|
|
|
*/ |
|
111
|
|
|
public function setDrawDate($drawDate) |
|
112
|
|
|
{ |
|
113
|
|
|
$this->drawDate = $drawDate; |
|
114
|
|
|
|
|
115
|
|
|
return $this; |
|
116
|
|
|
} |
|
117
|
|
|
|
|
118
|
|
|
/** |
|
119
|
|
|
* Convert the object to an array. |
|
120
|
|
|
* |
|
121
|
|
|
* @return array |
|
122
|
|
|
*/ |
|
123
|
|
|
public function getArrayCopy() |
|
124
|
|
|
{ |
|
125
|
|
|
$obj_vars = parent::getArrayCopy(); |
|
126
|
|
|
array_merge($obj_vars, get_object_vars($this)); |
|
127
|
|
|
|
|
128
|
|
View Code Duplication |
if (isset($obj_vars['drawDate']) && $obj_vars['drawDate'] !== null) { |
|
|
|
|
|
|
129
|
|
|
$obj_vars['drawDate'] = $obj_vars['drawDate']->format('d/m/Y'); |
|
130
|
|
|
} |
|
131
|
|
|
|
|
132
|
|
|
return $obj_vars; |
|
133
|
|
|
} |
|
134
|
|
|
|
|
135
|
|
|
/** |
|
136
|
|
|
* Populate from an array. |
|
137
|
|
|
* |
|
138
|
|
|
* @param array $data |
|
139
|
|
|
*/ |
|
140
|
|
View Code Duplication |
public function populate($data = array()) |
|
|
|
|
|
|
141
|
|
|
{ |
|
142
|
|
|
parent::populate($data); |
|
143
|
|
|
|
|
144
|
|
|
if (isset($data['drawAuto']) && $data['drawAuto'] !== null) { |
|
145
|
|
|
$this->drawAuto = $data['drawAuto']; |
|
146
|
|
|
} |
|
147
|
|
|
$this->drawDate = (isset($data['drawDate']) && $data['drawDate'] !== null) ? |
|
148
|
|
|
\DateTime::createFromFormat('d/m/Y', $data['drawDate']) : |
|
149
|
|
|
null; |
|
150
|
|
|
} |
|
151
|
|
|
|
|
152
|
|
|
public function setInputFilter(InputFilterInterface $inputFilter) |
|
153
|
|
|
{ |
|
154
|
|
|
throw new \Exception("Not used"); |
|
155
|
|
|
} |
|
156
|
|
|
|
|
157
|
|
View Code Duplication |
public function getInputFilter() |
|
|
|
|
|
|
158
|
|
|
{ |
|
159
|
|
|
if (!$this->inputFilter) { |
|
160
|
|
|
$inputFilter = new InputFilter(); |
|
|
|
|
|
|
161
|
|
|
$factory = new InputFactory(); |
|
162
|
|
|
|
|
163
|
|
|
$inputFilter = parent::getInputFilter(); |
|
164
|
|
|
|
|
165
|
|
|
$inputFilter->add($factory->createInput(array( |
|
166
|
|
|
'name' => 'drawDate', |
|
167
|
|
|
'required' => false, |
|
168
|
|
|
))); |
|
169
|
|
|
|
|
170
|
|
|
$this->inputFilter = $inputFilter; |
|
171
|
|
|
} |
|
172
|
|
|
|
|
173
|
|
|
return $this->inputFilter; |
|
174
|
|
|
} |
|
175
|
|
|
} |
|
176
|
|
|
|
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.