1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @file |
4
|
|
|
* Contains \TheSportsDb\Entity\Player. |
5
|
|
|
*/ |
6
|
|
|
|
7
|
|
|
namespace TheSportsDb\Entity; |
8
|
|
|
|
9
|
|
|
use TheSportsDb\Entity\EntityManagerInterface; |
10
|
|
|
use TheSportsDb\PropertyMapper\PropertyDefinition; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* A fully loaded player object. |
14
|
|
|
* |
15
|
|
|
* @author Jelle Sebreghts |
16
|
|
|
*/ |
17
|
|
|
class Player extends Entity implements PlayerInterface { |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* {@inheritdoc} |
21
|
|
|
*/ |
22
|
|
|
protected static $propertyMapDefinition; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* The primary identifier. |
26
|
|
|
* |
27
|
|
|
* @var mixed |
28
|
|
|
*/ |
29
|
|
|
protected $id; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* The team. |
33
|
|
|
* |
34
|
|
|
* @var \TheSportsDb\Entity\TeamInterface |
35
|
|
|
*/ |
36
|
|
|
protected $team; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* The nationality. |
40
|
|
|
* |
41
|
|
|
* @var string |
42
|
|
|
*/ |
43
|
|
|
protected $nationality; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* The name. |
47
|
|
|
* |
48
|
|
|
* @var string |
49
|
|
|
*/ |
50
|
|
|
protected $name; |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* The sport. |
54
|
|
|
* |
55
|
|
|
* @var \TheSportsDb\Entity\SportInterface |
56
|
|
|
*/ |
57
|
|
|
protected $sport; |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* The birthday. |
61
|
|
|
* |
62
|
|
|
* @var string |
63
|
|
|
*/ |
64
|
|
|
protected $birthDay; |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* The date this player signed. |
68
|
|
|
* |
69
|
|
|
* @var string |
70
|
|
|
*/ |
71
|
|
|
protected $dateSigned; |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* The amount this player signed for. |
75
|
|
|
* |
76
|
|
|
* @var string |
77
|
|
|
*/ |
78
|
|
|
protected $signing; |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* The wage. |
82
|
|
|
* |
83
|
|
|
* @var string |
84
|
|
|
*/ |
85
|
|
|
protected $wage; |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* The birth location. |
89
|
|
|
* |
90
|
|
|
* @var string |
91
|
|
|
*/ |
92
|
|
|
protected $birthLocation; |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* The description. |
96
|
|
|
* |
97
|
|
|
* @var string |
98
|
|
|
*/ |
99
|
|
|
protected $description; |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* The gender. |
103
|
|
|
* |
104
|
|
|
* @var string |
105
|
|
|
*/ |
106
|
|
|
protected $gender; |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* The position. |
110
|
|
|
* |
111
|
|
|
* @var string |
112
|
|
|
*/ |
113
|
|
|
protected $position; |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* The facebook URL. |
117
|
|
|
* |
118
|
|
|
* @var string |
119
|
|
|
*/ |
120
|
|
|
protected $facebook; |
121
|
|
|
|
122
|
|
|
/** |
123
|
|
|
* The website URL. |
124
|
|
|
* |
125
|
|
|
* @var string |
126
|
|
|
*/ |
127
|
|
|
protected $website; |
128
|
|
|
|
129
|
|
|
/** |
130
|
|
|
* The twitter profile URL. |
131
|
|
|
* |
132
|
|
|
* @var string |
133
|
|
|
*/ |
134
|
|
|
protected $twitter; |
135
|
|
|
|
136
|
|
|
/** |
137
|
|
|
* The instagram URL. |
138
|
|
|
* |
139
|
|
|
* @var string |
140
|
|
|
*/ |
141
|
|
|
protected $instagram; |
142
|
|
|
|
143
|
|
|
/** |
144
|
|
|
* The youtube URL. |
145
|
|
|
* |
146
|
|
|
* @var string |
147
|
|
|
*/ |
148
|
|
|
protected $youtube; |
149
|
|
|
|
150
|
|
|
/** |
151
|
|
|
* The height. |
152
|
|
|
* |
153
|
|
|
* @var float |
154
|
|
|
*/ |
155
|
|
|
protected $height; |
156
|
|
|
|
157
|
|
|
/** |
158
|
|
|
* The weight. |
159
|
|
|
* |
160
|
|
|
* @var float |
161
|
|
|
*/ |
162
|
|
|
protected $weight; |
163
|
|
|
|
164
|
|
|
/** |
165
|
|
|
* The thumbnail URL. |
166
|
|
|
* |
167
|
|
|
* @var string |
168
|
|
|
*/ |
169
|
|
|
protected $thumb; |
170
|
|
|
|
171
|
|
|
/** |
172
|
|
|
* The cutout URL. |
173
|
|
|
* |
174
|
|
|
* @var string |
175
|
|
|
*/ |
176
|
|
|
protected $cutout; |
177
|
|
|
|
178
|
|
|
/** |
179
|
|
|
* Whether this player is locked or not. |
180
|
|
|
* |
181
|
|
|
* @var string |
182
|
|
|
*/ |
183
|
|
|
protected $locked; |
184
|
|
|
|
185
|
|
|
/** |
186
|
|
|
* {@inheritdoc} |
187
|
|
|
*/ |
188
|
1 |
|
public function getId() { |
189
|
1 |
|
return $this->id; |
190
|
|
|
} |
191
|
|
|
|
192
|
|
|
/** |
193
|
|
|
* {@inheritdoc} |
194
|
|
|
*/ |
195
|
1 |
|
public function getTeam() { |
196
|
1 |
|
return $this->team; |
197
|
|
|
} |
198
|
|
|
|
199
|
|
|
/** |
200
|
|
|
* {@inheritdoc} |
201
|
|
|
*/ |
202
|
1 |
|
public function getNationality() { |
203
|
1 |
|
return $this->nationality; |
204
|
|
|
} |
205
|
|
|
|
206
|
|
|
/** |
207
|
|
|
* {@inheritdoc} |
208
|
|
|
*/ |
209
|
1 |
|
public function getName() { |
210
|
1 |
|
return $this->name; |
211
|
|
|
} |
212
|
|
|
|
213
|
|
|
/** |
214
|
|
|
* {@inheritdoc} |
215
|
|
|
*/ |
216
|
1 |
|
public function getSport() { |
217
|
1 |
|
return $this->sport; |
218
|
|
|
} |
219
|
|
|
|
220
|
|
|
/** |
221
|
|
|
* {@inheritdoc} |
222
|
|
|
*/ |
223
|
1 |
|
public function getBirthDay() { |
224
|
1 |
|
return $this->birthDay; |
225
|
|
|
} |
226
|
|
|
|
227
|
|
|
/** |
228
|
|
|
* {@inheritdoc} |
229
|
|
|
*/ |
230
|
1 |
|
public function getDateSigned() { |
231
|
1 |
|
return $this->dateSigned; |
232
|
|
|
} |
233
|
|
|
|
234
|
|
|
/** |
235
|
|
|
* {@inheritdoc} |
236
|
|
|
*/ |
237
|
1 |
|
public function getSigning() { |
238
|
1 |
|
return $this->signing; |
239
|
|
|
} |
240
|
|
|
|
241
|
|
|
/** |
242
|
|
|
* {@inheritdoc} |
243
|
|
|
*/ |
244
|
1 |
|
public function getWage() { |
245
|
1 |
|
return $this->wage; |
246
|
|
|
} |
247
|
|
|
|
248
|
|
|
/** |
249
|
|
|
* {@inheritdoc} |
250
|
|
|
*/ |
251
|
1 |
|
public function getBirthLocation() { |
252
|
1 |
|
return $this->birthLocation; |
253
|
|
|
} |
254
|
|
|
|
255
|
|
|
/** |
256
|
|
|
* {@inheritdoc} |
257
|
|
|
*/ |
258
|
1 |
|
public function getDescription() { |
259
|
1 |
|
return $this->description; |
260
|
|
|
} |
261
|
|
|
|
262
|
|
|
/** |
263
|
|
|
* {@inheritdoc} |
264
|
|
|
*/ |
265
|
1 |
|
public function getGender() { |
266
|
1 |
|
return $this->gender; |
267
|
|
|
} |
268
|
|
|
|
269
|
|
|
/** |
270
|
|
|
* {@inheritdoc} |
271
|
|
|
*/ |
272
|
1 |
|
public function getPosition() { |
273
|
1 |
|
return $this->position; |
274
|
|
|
} |
275
|
|
|
|
276
|
|
|
/** |
277
|
|
|
* {@inheritdoc} |
278
|
|
|
*/ |
279
|
1 |
|
public function getFacebook() { |
280
|
1 |
|
return $this->facebook; |
281
|
|
|
} |
282
|
|
|
|
283
|
|
|
/** |
284
|
|
|
* {@inheritdoc} |
285
|
|
|
*/ |
286
|
1 |
|
public function getWebsite() { |
287
|
1 |
|
return $this->website; |
288
|
|
|
} |
289
|
|
|
|
290
|
|
|
/** |
291
|
|
|
* {@inheritdoc} |
292
|
|
|
*/ |
293
|
1 |
|
public function getTwitter() { |
294
|
1 |
|
return $this->twitter; |
295
|
|
|
} |
296
|
|
|
|
297
|
|
|
/** |
298
|
|
|
* {@inheritdoc} |
299
|
|
|
*/ |
300
|
1 |
|
public function getInstagram() { |
301
|
1 |
|
return $this->instagram; |
302
|
|
|
} |
303
|
|
|
|
304
|
|
|
/** |
305
|
|
|
* {@inheritdoc} |
306
|
|
|
*/ |
307
|
1 |
|
public function getYoutube() { |
308
|
1 |
|
return $this->youtube; |
309
|
|
|
} |
310
|
|
|
|
311
|
|
|
/** |
312
|
|
|
* {@inheritdoc} |
313
|
|
|
*/ |
314
|
1 |
|
public function getHeight() { |
315
|
1 |
|
return $this->height; |
316
|
|
|
} |
317
|
|
|
|
318
|
|
|
/** |
319
|
|
|
* {@inheritdoc} |
320
|
|
|
*/ |
321
|
1 |
|
public function getWeight() { |
322
|
1 |
|
return $this->weight; |
323
|
|
|
} |
324
|
|
|
|
325
|
|
|
/** |
326
|
|
|
* {@inheritdoc} |
327
|
|
|
*/ |
328
|
1 |
|
public function getThumb() { |
329
|
1 |
|
return $this->thumb; |
330
|
|
|
} |
331
|
|
|
|
332
|
|
|
/** |
333
|
|
|
* {@inheritdoc} |
334
|
|
|
*/ |
335
|
1 |
|
public function getCutout() { |
336
|
1 |
|
return $this->cutout; |
337
|
|
|
} |
338
|
|
|
|
339
|
|
|
/** |
340
|
|
|
* {@inheritdoc} |
341
|
|
|
*/ |
342
|
1 |
|
public function getLocked() { |
343
|
1 |
|
return $this->locked; |
344
|
|
|
} |
345
|
|
|
|
346
|
|
|
/** |
347
|
|
|
* Transforms the team property to a team entity. |
348
|
|
|
* |
349
|
|
|
* @param mixed $value |
350
|
|
|
* The source value of the team property. |
351
|
|
|
* @param \stdClass $context |
352
|
|
|
* The source object representing this player. |
353
|
|
|
* @param EntityManagerInterface $entityManager |
354
|
|
|
* The entity manager. |
355
|
|
|
* |
356
|
|
|
* @return \TheSportsDb\Entity\TeamInterface |
357
|
|
|
* The team entity. |
358
|
|
|
*/ |
359
|
|
|
public static function transformTeam($value, $context, EntityManagerInterface $entityManager) { |
360
|
|
|
return static::transform($value, $context, $entityManager, 'team', 'idTeam', array('strTeam' => 'strTeam')); |
361
|
|
|
} |
362
|
|
|
|
363
|
|
|
/** |
364
|
|
|
* Transforms the sport property to a sport entity. |
365
|
|
|
* |
366
|
|
|
* @param mixed $value |
367
|
|
|
* The source value of the sport property. |
368
|
|
|
* @param \stdClass $context |
369
|
|
|
* The source object representing this player. |
370
|
|
|
* @param EntityManagerInterface $entityManager |
371
|
|
|
* The entity manager. |
372
|
|
|
* |
373
|
|
|
* @return \TheSportsDb\Entity\SportInterface |
374
|
|
|
* The sport entity. |
375
|
|
|
*/ |
376
|
|
|
public static function transformSport($value, $context, EntityManagerInterface $entityManager) { |
377
|
|
|
return static::transform($value, $context, $entityManager, 'sport', 'strSport'); |
378
|
|
|
} |
379
|
|
|
|
380
|
|
|
/** |
381
|
|
|
* {@inheritdoc} |
382
|
|
|
*/ |
383
|
1 |
View Code Duplication |
protected static function initPropertyMapDefinition() { |
|
|
|
|
384
|
1 |
|
static::$propertyMapDefinition |
385
|
1 |
|
->addPropertyMap( |
386
|
1 |
|
new PropertyDefinition('idPlayer'), |
387
|
1 |
|
new PropertyDefinition('id') |
388
|
|
|
) |
389
|
1 |
|
->addPropertyMap( |
390
|
1 |
|
new PropertyDefinition('idTeam'), |
391
|
1 |
|
new PropertyDefinition('team'), |
392
|
1 |
|
[self::class, 'transformTeam'], |
393
|
1 |
|
[Team::class, 'reverse'] |
394
|
|
|
) |
395
|
1 |
|
->addPropertyMap( |
396
|
1 |
|
new PropertyDefinition('strNationality'), |
397
|
1 |
|
new PropertyDefinition('nationality') |
398
|
|
|
) |
399
|
1 |
|
->addPropertyMap( |
400
|
1 |
|
new PropertyDefinition('strPlayer'), |
401
|
1 |
|
new PropertyDefinition('name') |
402
|
|
|
) |
403
|
1 |
|
->addPropertyMap( |
404
|
1 |
|
new PropertyDefinition('strSport'), |
405
|
1 |
|
new PropertyDefinition('sport', 'sport'), |
406
|
1 |
|
[self::class, 'transformSport'], |
407
|
1 |
|
[Sport::class, 'reverse'] |
408
|
|
|
) |
409
|
1 |
|
->addPropertyMap( |
410
|
1 |
|
new PropertyDefinition('dateBorn'), |
411
|
1 |
|
new PropertyDefinition('birthDay') // transform to date |
412
|
|
|
) |
413
|
1 |
|
->addPropertyMap( |
414
|
1 |
|
new PropertyDefinition('dateSigned'), |
415
|
1 |
|
new PropertyDefinition('dateSigned') // transform to date |
416
|
|
|
) |
417
|
1 |
|
->addPropertyMap( |
418
|
1 |
|
new PropertyDefinition('strSigning'), |
419
|
1 |
|
new PropertyDefinition('signing') |
420
|
|
|
) |
421
|
1 |
|
->addPropertyMap( |
422
|
1 |
|
new PropertyDefinition('strWage'), |
423
|
1 |
|
new PropertyDefinition('wage') |
424
|
|
|
) |
425
|
1 |
|
->addPropertyMap( |
426
|
1 |
|
new PropertyDefinition('strBirthLocation'), |
427
|
1 |
|
new PropertyDefinition('birthLocation') |
428
|
|
|
) |
429
|
1 |
|
->addPropertyMap( |
430
|
1 |
|
new PropertyDefinition('strDescriptionEN'), |
431
|
1 |
|
new PropertyDefinition('description') |
432
|
|
|
) |
433
|
1 |
|
->addPropertyMap( |
434
|
1 |
|
new PropertyDefinition('strGender'), |
435
|
1 |
|
new PropertyDefinition('gender') |
436
|
|
|
) |
437
|
1 |
|
->addPropertyMap( |
438
|
1 |
|
new PropertyDefinition('strPosition'), |
439
|
1 |
|
new PropertyDefinition('position') |
440
|
|
|
) |
441
|
1 |
|
->addPropertyMap( |
442
|
1 |
|
new PropertyDefinition('strFacebook'), |
443
|
1 |
|
new PropertyDefinition('facebook') |
444
|
|
|
) |
445
|
1 |
|
->addPropertyMap( |
446
|
1 |
|
new PropertyDefinition('strWebsite'), |
447
|
1 |
|
new PropertyDefinition('website') |
448
|
|
|
) |
449
|
1 |
|
->addPropertyMap( |
450
|
1 |
|
new PropertyDefinition('strTwitter'), |
451
|
1 |
|
new PropertyDefinition('strTwitter') |
452
|
|
|
) |
453
|
1 |
|
->addPropertyMap( |
454
|
1 |
|
new PropertyDefinition('strInstagram'), |
455
|
1 |
|
new PropertyDefinition('instagram') |
456
|
|
|
) |
457
|
1 |
|
->addPropertyMap( |
458
|
1 |
|
new PropertyDefinition('strYoutube'), |
459
|
1 |
|
new PropertyDefinition('youtube') |
460
|
|
|
) |
461
|
1 |
|
->addPropertyMap( |
462
|
1 |
|
new PropertyDefinition('strHeight'), |
463
|
1 |
|
new PropertyDefinition('height') |
464
|
|
|
) |
465
|
1 |
|
->addPropertyMap( |
466
|
1 |
|
new PropertyDefinition('strWeight'), |
467
|
1 |
|
new PropertyDefinition('weight') |
468
|
|
|
) |
469
|
1 |
|
->addPropertyMap( |
470
|
1 |
|
new PropertyDefinition('strThumb'), |
471
|
1 |
|
new PropertyDefinition('thumb') |
472
|
|
|
) |
473
|
1 |
|
->addPropertyMap( |
474
|
1 |
|
new PropertyDefinition('strCutout'), |
475
|
1 |
|
new PropertyDefinition('strCutout') |
476
|
|
|
) |
477
|
1 |
|
->addPropertyMap( |
478
|
1 |
|
new PropertyDefinition('strLocked'), |
479
|
1 |
|
new PropertyDefinition('locked') |
480
|
|
|
); |
481
|
|
|
// strTeam |
482
|
|
|
// idSoccerXML |
483
|
|
|
// idPlayerManager |
484
|
|
|
// intSoccerXMLTeamID |
485
|
|
|
// strDescriptionDE |
486
|
|
|
// strDescriptionFR |
487
|
|
|
// strDescriptionCN |
488
|
|
|
// strDescriptionIT |
489
|
|
|
// strDescriptionJP |
490
|
|
|
// strDescriptionRU |
491
|
|
|
// strDescriptionES |
492
|
|
|
// strDescriptionPT |
493
|
|
|
// strDescriptionSE |
494
|
|
|
// strDescriptionNL |
495
|
|
|
// strDescriptionHU |
496
|
|
|
// strDescriptionNO |
497
|
|
|
// strDescriptionIL |
498
|
|
|
// strDescriptionPL |
499
|
|
|
// strCollege |
500
|
|
|
// intLoved |
501
|
|
|
// strFanart1 |
502
|
|
|
// strFanart2 |
503
|
|
|
// strFanart3 |
504
|
|
|
// strFanart4 |
505
|
1 |
|
} |
506
|
|
|
|
507
|
|
|
} |
508
|
|
|
|
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.