Completed
Push — master ( 72f7d3...fba581 )
by Jelle
05:10
created

League::getTwitter()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
/**
3
 * @file
4
 * Contains \TheSportsDb\Entity\League.
5
 */
6
7
namespace TheSportsDb\Entity;
8
9
use TheSportsDb\Entity\EntityManagerInterface;
10
use TheSportsDb\PropertyMapper\PropertyDefinition;
11
12
/**
13
 * A fully loaded league object.
14
 *
15
 * @author Jelle Sebreghts
16
 */
17
class League extends Entity implements LeagueInterface {
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 name.
33
   *
34
   * @var string
35
   */
36
  protected $name;
37
38
  /**
39
   * The sport
40
   *
41
   * @var \TheSportsDb\Entity\SportInterface
42
   */
43
  protected $sport;
44
45
  /**
46
   * The alternate name.
47
   *
48
   * @var string
49
   */
50
  protected $alternateName;
51
52
  /**
53
   * The year the league was formed.
54
   *
55
   * @var int
56
   */
57
  protected $formedYear;
58
59
  /**
60
   * The date of the first event.
61
   *
62
   * @var string
63
   */
64
  protected $dateFirstEvent;
65
66
  /**
67
   * The gender.
68
   *
69
   * @var string
70
   */
71
  protected $gender;
72
73
  /**
74
   * The country.
75
   *
76
   * @var string
77
   */
78
  protected $country;
79
80
  /**
81
   * The website URL.
82
   *
83
   * @var string
84
   */
85
  protected $website;
86
87
  /**
88
   * The facebook URL.
89
   *
90
   * @var string
91
   */
92
  protected $facebook;
93
94
  /**
95
   * The twitter URL.
96
   *
97
   * @var string
98
   */
99
  protected $twitter;
100
101
  /**
102
   * The youtube URL.
103
   *
104
   * @var string
105
   */
106
  protected $youtube;
107
108
  /**
109
   * The RSS URL.
110
   *
111
   * @var string
112
   */
113
  protected $rss;
114
115
  /**
116
   * The description.
117
   *
118
   * @var string
119
   */
120
  protected $description;
121
122
  /**
123
   * The banner URL.
124
   *
125
   * @var string
126
   */
127
  protected $banner;
128
129
  /**
130
   * The badge URL.
131
   *
132
   * @var string
133
   */
134
  protected $badge;
135
136
  /**
137
   * The logo URL.
138
   *
139
   * @var string
140
   */
141
  protected $logo;
142
143
  /**
144
   * The poster URL.
145
   *
146
   * @var string
147
   */
148
  protected $poster;
149
150
  /**
151
   * The trophy URL.
152
   *
153
   * @var string
154
   */
155
  protected $trophy;
156
157
  /**
158
   * The event naming pattern.
159
   *
160
   * @var string
161
   */
162
  protected $naming;
163
164
  /**
165
   * Whether or not the league is locked.
166
   *
167
   * @var string
168
   */
169
  protected $locked;
170
171
  /**
172
   * The seasons.
173
   *
174
   * @var \TheSportsDb\Entity\SeasonInterface[]
175
   */
176
  protected $seasons = array();
177
178
  /**
179
   * {@inheritdoc}
180
   */
181 1
  public function getId() {
182 1
    return $this->id;
183
  }
184
185
  /**
186
   * {@inheritdoc}
187
   */
188 1
  public function getName() {
189 1
    return $this->name;
190
  }
191
192
  /**
193
   * {@inheritdoc}
194
   */
195 1
  public function getSport() {
196 1
    return $this->sport;
197
  }
198
199
  /**
200
   * {@inheritdoc}
201
   */
202 1
  public function getAlternateName() {
203 1
    return $this->alternateName;
204
  }
205
206
  /**
207
   * {@inheritdoc}
208
   */
209 1
  public function getFormedYear() {
210 1
    return $this->formedYear;
211
  }
212
213
  /**
214
   * {@inheritdoc}
215
   */
216 1
  public function getDateFirstEvent() {
217 1
    return $this->dateFirstEvent;
218
  }
219
220
  /**
221
   * {@inheritdoc}
222
   */
223 1
  public function getGender() {
224 1
    return $this->gender;
225
  }
226
227
  /**
228
   * {@inheritdoc}
229
   */
230 1
  public function getCountry() {
231 1
    return $this->country;
232
  }
233
234
  /**
235
   * {@inheritdoc}
236
   */
237 1
  public function getWebsite() {
238 1
    return $this->website;
239
  }
240
241
  /**
242
   * {@inheritdoc}
243
   */
244 1
  public function getFacebook() {
245 1
    return $this->facebook;
246
  }
247
248
  /**
249
   * {@inheritdoc}
250
   */
251 1
  public function getTwitter() {
252 1
    return $this->twitter;
253
  }
254
255
  /**
256
   * {@inheritdoc}
257
   */
258 1
  public function getYoutube() {
259 1
    return $this->youtube;
260
  }
261
262
  /**
263
   * {@inheritdoc}
264
   */
265 1
  public function getRss() {
266 1
    return $this->rss;
267
  }
268
269
  /**
270
   * {@inheritdoc}
271
   */
272 1
  public function getDescription() {
273 1
    return $this->description;
274
  }
275
276
  /**
277
   * {@inheritdoc}
278
   */
279 1
  public function getBanner() {
280 1
    return $this->banner;
281
  }
282
283
  /**
284
   * {@inheritdoc}
285
   */
286 1
  public function getBadge() {
287 1
    return $this->badge;
288
  }
289
290
  /**
291
   * {@inheritdoc}
292
   */
293 1
  public function getLogo() {
294 1
    return $this->logo;
295
  }
296
297
  /**
298
   * {@inheritdoc}
299
   */
300 1
  public function getPoster() {
301 1
    return $this->poster;
302
  }
303
304
  /**
305
   * {@inheritdoc}
306
   */
307 1
  public function getTrophy() {
308 1
    return $this->trophy;
309
  }
310
311
  /**
312
   * {@inheritdoc}
313
   */
314 1
  public function getNaming() {
315 1
    return $this->naming;
316
  }
317
318
  /**
319
   * {@inheritdoc}
320
   */
321 1
  public function getLocked() {
322 1
    return $this->locked;
323
  }
324
325
  /**
326
   * {@inheritdoc}
327
   */
328 1
  public function getSeasons() {
329 1
    return $this->seasons;
330
  }
331
332
  /**
333
   * Transforms the sport property to a sport entity.
334
   *
335
   * @param mixed $value
336
   *   The source value of the sport property.
337
   * @param \stdClass $context
338
   *   The source object representing this league.
339
   * @param EntityManagerInterface $entityManager
340
   *   The entity manager.
341
   *
342
   * @return \TheSportsDb\Entity\SportInterface
343
   *   The sport entity.
344
   */
345
  public static function transformSport($value, $context, EntityManagerInterface $entityManager) {
346
    return static::transform($value, $context, $entityManager, 'sport', 'strSport');
347
  }
348
349
  /**
350
   * Transforms the seasons property to season entities.
351
   *
352
   * @param array $values
353
   *   The source value of the seasons property.
354
   * @param \stdClass $context
355
   *   The source object representing this league.
356
   * @param EntityManagerInterface $entityManager
357
   *   The entity manager.
358
   *
359
   * @return \TheSportsDb\Entity\SeasonInterface[]
360
   *   The season entities.
361
   */
362
  public static function transformSeasons($values, $context, EntityManagerInterface $entityManager) {
363
    $mappedSeasons = array();
364
    foreach ($values as $season) {
365
      $id = $season->strSeason . '|' . $season->idLeague;
366
      $mappedSeasons[] = $entityManager->repository('season')->byId($id);
367
    }
368
    return $mappedSeasons;
369
  }
370
371
  /**
372
   * {@inheritdoc}
373
   */
374 View Code Duplication
  protected static function initPropertyMapDefinition() {
1 ignored issue
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...
375
    static::$propertyMapDefinition
376
      ->addPropertyMap(
377
        new PropertyDefinition('idLeague'),
378
        new PropertyDefinition('id')
379
      )
380
      ->addPropertyMap(
381
        new PropertyDefinition('strLeague'),
382
        new PropertyDefinition('name')
383
      )
384
      ->addPropertyMap(
385
        new PropertyDefinition('strSport'),
386
        new PropertyDefinition('sport', 'sport'),
387
        [self::class, 'transformSport'],
388
        [Sport::class, 'reverse']
389
      )
390
      ->addPropertyMap(
391
        new PropertyDefinition('strLeagueAlternate'),
392
        new  PropertyDefinition('alternateName')
393
      )
394
      ->addPropertyMap(
395
        new PropertyDefinition('intFormedYear'),
396
        new  PropertyDefinition('formedYear')
397
      )
398
      ->addPropertyMap(
399
        new PropertyDefinition('dateFirstEvent'),
400
        new  PropertyDefinition('dateFirstEvent')) //"2013-03-02",
401
      ->addPropertyMap(
402
        new PropertyDefinition('strGender'),
403
        new  PropertyDefinition('gender')
404
      )
405
      ->addPropertyMap(
406
        new PropertyDefinition('strCountry'),
407
        new  PropertyDefinition('country')
408
      )
409
      ->addPropertyMap(
410
        new PropertyDefinition('strWebsite'),
411
        new  PropertyDefinition('website')
412
      )
413
      ->addPropertyMap(
414
        new PropertyDefinition('strFacebook'),
415
        new  PropertyDefinition('facebook')
416
      )
417
      ->addPropertyMap(
418
        new PropertyDefinition('strTwitter'),
419
        new  PropertyDefinition('twitter')
420
      )
421
      ->addPropertyMap(
422
        new PropertyDefinition('strYoutube'),
423
        new  PropertyDefinition('youtube')
424
      )
425
      ->addPropertyMap(
426
        new PropertyDefinition('strRSS'),
427
        new  PropertyDefinition('rss')
428
      )
429
      ->addPropertyMap(
430
        new PropertyDefinition('strDescriptionEN'),
431
        new  PropertyDefinition('description')
432
      )
433
      ->addPropertyMap(
434
        new PropertyDefinition('strBanner'),
435
        new  PropertyDefinition('banner')
436
      )
437
      ->addPropertyMap(
438
        new PropertyDefinition('strBadge'),
439
        new  PropertyDefinition('badge')
440
      )
441
      ->addPropertyMap(
442
        new PropertyDefinition('strLogo'),
443
        new  PropertyDefinition('logo')
444
      )
445
      ->addPropertyMap(
446
        new PropertyDefinition('strPoster'),
447
        new  PropertyDefinition('poster')
448
      )
449
      ->addPropertyMap(
450
        new PropertyDefinition('strTrophy'),
451
        new  PropertyDefinition('trophy')
452
      )
453
      ->addPropertyMap(
454
        new PropertyDefinition('strNaming'),
455
        new  PropertyDefinition('naming')
456
      )
457
      ->addPropertyMap(
458
        new PropertyDefinition('strLocked'),
459
        new  PropertyDefinition('locked')
460
      )
461
      ->addPropertyMap(
462
        new PropertyDefinition('seasons'),
463
        new  PropertyDefinition('seasons', 'season', TRUE),
464
        [self::class, 'transformSeasons'],
465
        [Season::class, 'reverseArray']
466
      );
467
    // idSoccerXML
468
    // strDescriptionDE
469
    // strDescriptionFR
470
    // strDescriptionIT
471
    // strDescriptionCN
472
    // strDescriptionJP
473
    // strDescriptionRU
474
    // strDescriptionES
475
    // strDescriptionPT
476
    // strDescriptionSE
477
    // strDescriptionNL
478
    // strDescriptionHU
479
    // strDescriptionNO
480
    // strDescriptionPL
481
    // strFanart1
482
    // strFanart2
483
    // strFanart3
484
    // strFanart4
485
  }
486
487
}
488