Completed
Push — master ( a02710...7ee086 )
by Jelle
09:44
created

Player::initPropertyMapDefinition()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 123
Code Lines 75

Duplication

Lines 123
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 123
loc 123
rs 8.2857
cc 1
eloc 75
nc 1
nop 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

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
  public function getId() {
189
    return $this->id;
190
  }
191
192
  /**
193
   * {@inheritdoc}
194
   */
195
  public function getTeam() {
196
    return $this->team;
197
  }
198
199
  /**
200
   * {@inheritdoc}
201
   */
202
  public function getNationality() {
203
    return $this->nationality;
204
  }
205
206
  /**
207
   * {@inheritdoc}
208
   */
209
  public function getName() {
210
    return $this->name;
211
  }
212
213
  /**
214
   * {@inheritdoc}
215
   */
216
  public function getSport() {
217
    return $this->sport;
218
  }
219
220
  /**
221
   * {@inheritdoc}
222
   */
223
  public function getBirthDay() {
224
    return $this->birthDay;
225
  }
226
227
  /**
228
   * {@inheritdoc}
229
   */
230
  public function getDateSigned() {
231
    return $this->dateSigned;
232
  }
233
234
  /**
235
   * {@inheritdoc}
236
   */
237
  public function getSigning() {
238
    return $this->signing;
239
  }
240
241
  /**
242
   * {@inheritdoc}
243
   */
244
  public function getWage() {
245
    return $this->wage;
246
  }
247
248
  /**
249
   * {@inheritdoc}
250
   */
251
  public function getBirthLocation() {
252
    return $this->birthLocation;
253
  }
254
255
  /**
256
   * {@inheritdoc}
257
   */
258
  public function getDescription() {
259
    return $this->description;
260
  }
261
262
  /**
263
   * {@inheritdoc}
264
   */
265
  public function getGender() {
266
    return $this->gender;
267
  }
268
269
  /**
270
   * {@inheritdoc}
271
   */
272
  public function getPosition() {
273
    return $this->position;
274
  }
275
276
  /**
277
   * {@inheritdoc}
278
   */
279
  public function getFacebook() {
280
    return $this->facebook;
281
  }
282
283
  /**
284
   * {@inheritdoc}
285
   */
286
  public function getWebsite() {
287
    return $this->website;
288
  }
289
290
  /**
291
   * {@inheritdoc}
292
   */
293
  public function getTwitter() {
294
    return $this->twitter;
295
  }
296
297
  /**
298
   * {@inheritdoc}
299
   */
300
  public function getInstagram() {
301
    return $this->instagram;
302
  }
303
304
  /**
305
   * {@inheritdoc}
306
   */
307
  public function getYoutube() {
308
    return $this->youtube;
309
  }
310
311
  /**
312
   * {@inheritdoc}
313
   */
314
  public function getHeight() {
315
    return $this->height;
316
  }
317
318
  /**
319
   * {@inheritdoc}
320
   */
321
  public function getWeight() {
322
    return $this->weight;
323
  }
324
325
  /**
326
   * {@inheritdoc}
327
   */
328
  public function getThumb() {
329
    return $this->thumb;
330
  }
331
332
  /**
333
   * {@inheritdoc}
334
   */
335
  public function getCutout() {
336
    return $this->cutout;
337
  }
338
339
  /**
340
   * {@inheritdoc}
341
   */
342
  public function getLocked() {
343
    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 View Code Duplication
  protected static function initPropertyMapDefinition() {
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...
384
    static::$propertyMapDefinition
385
      ->addPropertyMap(
386
        new PropertyDefinition('idPlayer'),
387
        new PropertyDefinition('id')
388
      )
389
      ->addPropertyMap(
390
        new PropertyDefinition('idTeam'),
391
        new PropertyDefinition('team'),
392
        [self::class, 'transformTeam'],
393
        [Team::class, 'reverse']
394
      )
395
      ->addPropertyMap(
396
        new PropertyDefinition('strNationality'),
397
        new PropertyDefinition('nationality')
398
      )
399
      ->addPropertyMap(
400
        new PropertyDefinition('strPlayer'),
401
        new PropertyDefinition('name')
402
      )
403
      ->addPropertyMap(
404
        new PropertyDefinition('strSport'),
405
        new PropertyDefinition('sport', 'sport'),
406
        [self::class, 'transformSport'],
407
        [Sport::class, 'reverse']
408
      )
409
      ->addPropertyMap(
410
        new PropertyDefinition('dateBorn'),
411
        new PropertyDefinition('birthDay') // transform to date
412
      )
413
      ->addPropertyMap(
414
        new PropertyDefinition('dateSigned'),
415
        new PropertyDefinition('dateSigned') // transform to date
416
      )
417
      ->addPropertyMap(
418
        new PropertyDefinition('strSigning'),
419
        new PropertyDefinition('signing')
420
      )
421
      ->addPropertyMap(
422
        new PropertyDefinition('strWage'),
423
        new PropertyDefinition('wage')
424
      )
425
      ->addPropertyMap(
426
        new PropertyDefinition('strBirthLocation'),
427
        new PropertyDefinition('birthLocation')
428
      )
429
      ->addPropertyMap(
430
        new PropertyDefinition('strDescriptionEN'),
431
        new PropertyDefinition('description')
432
      )
433
      ->addPropertyMap(
434
        new PropertyDefinition('strGender'),
435
        new PropertyDefinition('gender')
436
      )
437
      ->addPropertyMap(
438
        new PropertyDefinition('strPosition'),
439
        new PropertyDefinition('position')
440
      )
441
      ->addPropertyMap(
442
        new PropertyDefinition('strFacebook'),
443
        new PropertyDefinition('facebook')
444
      )
445
      ->addPropertyMap(
446
        new PropertyDefinition('strWebsite'),
447
        new PropertyDefinition('website')
448
      )
449
      ->addPropertyMap(
450
        new PropertyDefinition('strTwitter'),
451
        new PropertyDefinition('strTwitter')
452
      )
453
      ->addPropertyMap(
454
        new PropertyDefinition('strInstagram'),
455
        new PropertyDefinition('instagram')
456
      )
457
      ->addPropertyMap(
458
        new PropertyDefinition('strYoutube'),
459
        new PropertyDefinition('youtube')
460
      )
461
      ->addPropertyMap(
462
        new PropertyDefinition('strHeight'),
463
        new PropertyDefinition('height')
464
      )
465
      ->addPropertyMap(
466
        new PropertyDefinition('strWeight'),
467
        new PropertyDefinition('weight')
468
      )
469
      ->addPropertyMap(
470
        new PropertyDefinition('strThumb'),
471
        new PropertyDefinition('thumb')
472
      )
473
      ->addPropertyMap(
474
        new PropertyDefinition('strCutout'),
475
        new PropertyDefinition('strCutout')
476
      )
477
      ->addPropertyMap(
478
        new PropertyDefinition('strLocked'),
479
        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
  }
506
507
}
508