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