League   A
last analyzed

Complexity

Total Complexity 26

Size/Duplication

Total Lines 461
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 93.7%

Importance

Changes 0
Metric Value
wmc 26
lcom 1
cbo 3
dl 0
loc 461
ccs 119
cts 127
cp 0.937
rs 10
c 0
b 0
f 0

25 Methods

Rating   Name   Duplication   Size   Complexity  
A getId() 0 3 1
A getName() 0 3 1
A getSport() 0 3 1
A getAlternateName() 0 3 1
A getFormedYear() 0 3 1
A getDateFirstEvent() 0 3 1
A getGender() 0 3 1
A getCountry() 0 3 1
A getWebsite() 0 3 1
A getFacebook() 0 3 1
A getTwitter() 0 3 1
A getYoutube() 0 3 1
A getRss() 0 3 1
A getDescription() 0 3 1
A getBanner() 0 3 1
A getBadge() 0 3 1
A getLogo() 0 3 1
A getPoster() 0 3 1
A getTrophy() 0 3 1
A getNaming() 0 3 1
A getLocked() 0 3 1
A getSeasons() 0 3 1
A transformSport() 0 3 1
A transformSeasons() 0 8 2
B initPropertyMapDefinition() 0 102 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 1
  protected static function initPropertyMapDefinition() {
375 1
    static::$propertyMapDefinition
376 1
      ->addPropertyMap(
377 1
        new PropertyDefinition('idLeague'),
378 1
        new PropertyDefinition('id')
379
      )
380 1
      ->addPropertyMap(
381 1
        new PropertyDefinition('strLeague'),
382 1
        new PropertyDefinition('name')
383
      )
384 1
      ->addPropertyMap(
385 1
        new PropertyDefinition('strSport'),
386 1
        new PropertyDefinition('sport', 'sport'),
387 1
        [self::class, 'transformSport'],
388 1
        [Sport::class, 'reverse']
389
      )
390 1
      ->addPropertyMap(
391 1
        new PropertyDefinition('strLeagueAlternate'),
392 1
        new  PropertyDefinition('alternateName')
393
      )
394 1
      ->addPropertyMap(
395 1
        new PropertyDefinition('intFormedYear'),
396 1
        new  PropertyDefinition('formedYear')
397
      )
398 1
      ->addPropertyMap(
399 1
        new PropertyDefinition('dateFirstEvent'),
400 1
        new  PropertyDefinition('dateFirstEvent'),
401 1
        [self::class, 'transformDateDefault'],
402 1
        [self::class, 'reverseDateDefault']
403
      )
404 1
      ->addPropertyMap(
405 1
        new PropertyDefinition('strGender'),
406 1
        new  PropertyDefinition('gender')
407
      )
408 1
      ->addPropertyMap(
409 1
        new PropertyDefinition('strCountry'),
410 1
        new  PropertyDefinition('country')
411
      )
412 1
      ->addPropertyMap(
413 1
        new PropertyDefinition('strWebsite'),
414 1
        new  PropertyDefinition('website')
415
      )
416 1
      ->addPropertyMap(
417 1
        new PropertyDefinition('strFacebook'),
418 1
        new  PropertyDefinition('facebook')
419
      )
420 1
      ->addPropertyMap(
421 1
        new PropertyDefinition('strTwitter'),
422 1
        new  PropertyDefinition('twitter')
423
      )
424 1
      ->addPropertyMap(
425 1
        new PropertyDefinition('strYoutube'),
426 1
        new  PropertyDefinition('youtube')
427
      )
428 1
      ->addPropertyMap(
429 1
        new PropertyDefinition('strRSS'),
430 1
        new  PropertyDefinition('rss')
431
      )
432 1
      ->addPropertyMap(
433 1
        new PropertyDefinition('strDescriptionEN'),
434 1
        new  PropertyDefinition('description')
435
      )
436 1
      ->addPropertyMap(
437 1
        new PropertyDefinition('strBanner'),
438 1
        new  PropertyDefinition('banner')
439
      )
440 1
      ->addPropertyMap(
441 1
        new PropertyDefinition('strBadge'),
442 1
        new  PropertyDefinition('badge')
443
      )
444 1
      ->addPropertyMap(
445 1
        new PropertyDefinition('strLogo'),
446 1
        new  PropertyDefinition('logo')
447
      )
448 1
      ->addPropertyMap(
449 1
        new PropertyDefinition('strPoster'),
450 1
        new  PropertyDefinition('poster')
451
      )
452 1
      ->addPropertyMap(
453 1
        new PropertyDefinition('strTrophy'),
454 1
        new  PropertyDefinition('trophy')
455
      )
456 1
      ->addPropertyMap(
457 1
        new PropertyDefinition('strNaming'),
458 1
        new  PropertyDefinition('naming')
459
      )
460 1
      ->addPropertyMap(
461 1
        new PropertyDefinition('strLocked'),
462 1
        new  PropertyDefinition('locked')
463
      )
464 1
      ->addPropertyMap(
465 1
        new PropertyDefinition('seasons'),
466 1
        new  PropertyDefinition('seasons', 'season', TRUE),
467 1
        [self::class, 'transformSeasons'],
468 1
        [Season::class, 'reverseArray']
469
      );
470
    // idSoccerXML
471
    // strFanart1
472
    // strFanart2
473
    // strFanart3
474
    // strFanart4
475 1
  }
476
477
}
478