Completed
Push — master ( 5eaf44...4ca75b )
by Jelle
05:50
created

Event::getHomeLineupSubstitutes()   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 0
Metric Value
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
/**
3
 * @file
4
 * Contains \TheSportsDb\Entity\Event.
5
 */
6
7
namespace TheSportsDb\Entity;
8
9
use TheSportsDb\Entity\EntityManagerInterface;
10
use TheSportsDb\PropertyMapper\PropertyDefinition;
11
12
/**
13
 * A fully loaded event object.
14
 *
15
 * @author Jelle Sebreghts
16
 */
17
class Event extends Entity implements EventInterface {
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 league of this event.
40
   *
41
   * @var \TheSportsDb\Entity\LeagueInterface
42
   */
43
  protected $league;
44
45
  /**
46
   * The filename.
47
   *
48
   * @var string
49
   */
50
  protected $filename;
51
52
  /**
53
   * The season.
54
   *
55
   * @var \TheSportsDb\Entity\SeasonInterface
56
   */
57
  protected $season;
58
59
  /**
60
   * The description.
61
   *
62
   * @var string
63
   */
64
  protected $description;
65
66
  /**
67
   * The home score.
68
   *
69
   * @var int
70
   */
71
  protected $homeScore;
72
73
  /**
74
   * The round.
75
   *
76
   * @var int
77
   */
78
  protected $round;
79
80
  /**
81
   * The away score.
82
   *
83
   * @var int
84
   */
85
  protected $awayScore;
86
87
  /**
88
   * The number of specators.
89
   *
90
   * @var int
91
   */
92
  protected $specators;
93
94
  /**
95
   * The home goal details.
96
   *
97
   * @var string
98
   */
99
  protected $homeGoalDetails;
100
101
  /**
102
   * The home red cards.
103
   *
104
   * @var string
105
   */
106
  protected $homeRedCards;
107
108
  /**
109
   * The home yellow cards.
110
   *
111
   * @var string
112
   */
113
  protected $homeYellowCards;
114
115
  /**
116
   * The home lineup - goalkeeper.
117
   *
118
   * @var string
119
   */
120
  protected $homeLineupGoalkeeper;
121
122
  /**
123
   * The home lineup - defense.
124
   *
125
   * @var string
126
   */
127
  protected $homeLineupDefense;
128
129
  /**
130
   * The home lineup - midfield.
131
   *
132
   * @var string
133
   */
134
  protected $homeLineupMidfield;
135
136
  /**
137
   * The home lineup - forward.
138
   *
139
   * @var string
140
   */
141
  protected $homeLineupForward;
142
143
  /**
144
   * The home lineup - substitutes.
145
   *
146
   * @var string
147
   */
148
  protected $homeLineupSubstitues;
149
150
  /**
151
   * The home formation.
152
   *
153
   * @var string
154
   */
155
  protected $homeFormation;
156
157
  /**
158
   * The away red cards.
159
   *
160
   * @var string
161
   */
162
  protected $awayRedCards;
163
164
  /**
165
   * The away yellow cards.
166
   *
167
   * @var string
168
   */
169
  protected $awayYellowCards;
170
171
  /**
172
   * The away goal details.
173
   *
174
   * @var string
175
   */
176
  protected $awayGoalDetails;
177
178
  /**
179
   * The away lineup - goalkeeper.
180
   *
181
   * @var string
182
   */
183
  protected $awayLineupGoalkeeper;
184
185
  /**
186
   * The away lineup - defense.
187
   *
188
   * @var string
189
   */
190
  protected $awayLineupDefense;
191
192
  /**
193
   * The away lineup - midfield.
194
   *
195
   * @var string
196
   */
197
  protected $awayLineupMidfield;
198
199
  /**
200
   * The away lineup - forward.
201
   *
202
   * @var string
203
   */
204
  protected $awayLineupForward;
205
206
  /**
207
   * The away lineup - substitutes.
208
   *
209
   * @var string
210
   */
211
  protected $awayLineupSubstitutes;
212
213
  /**
214
   * The away formation.
215
   *
216
   * @var string
217
   */
218
  protected $awayFormation;
219
220
  /**
221
   * The home shots.
222
   *
223
   * @var int
224
   */
225
  protected $homeShots;
226
227
  /**
228
   * The away shots.
229
   *
230
   * @var int
231
   */
232
  protected $awayShots;
233
234
  /**
235
   * The date.
236
   *
237
   * @var string
238
   */
239
  protected $date;
240
241
  /**
242
   * The TV station.
243
   *
244
   * @var string
245
   */
246
  protected $tvStation;
247
248
  /**
249
   * The home team.
250
   *
251
   * @var \TheSportsDb\Entity\TeamInterface
252
   */
253
  protected $homeTeam;
254
255
  /**
256
   * The away team.
257
   *
258
   * @var \TheSportsDb\Entity\TeamInterface
259
   */
260
  protected $awayTeam;
261
262
  /**
263
   * The result.
264
   *
265
   * @var string
266
   */
267
  protected $result;
268
269
  /**
270
   * The circuit.
271
   *
272
   * @var string
273
   */
274
  protected $circuit;
275
276
  /**
277
   * The country.
278
   *
279
   * @var string
280
   */
281
  protected $country;
282
283
  /**
284
   * The city.
285
   *
286
   * @var string
287
   */
288
  protected $city;
289
290
  /**
291
   * The poster URL.
292
   *
293
   * @var string
294
   */
295
  protected $poster;
296
297
  /**
298
   * The thumbnail URL.
299
   *
300
   * @var string
301
   */
302
  protected $thumb;
303
304
  /**
305
   * The banner URL.
306
   *
307
   * @var string
308
   */
309
  protected $banner;
310
311
  /**
312
   * The map URL.
313
   *
314
   * @var string
315
   */
316
  protected $map;
317
318
  /**
319
   * Whether this player is locked or not.
320
   *
321
   * @var string
322
   */
323
  protected $locked;
324
325
  /**
326
   * {@inheritdoc}
327
   */
328 1
  public function getId() {
329 1
    return $this->id;
330
  }
331
332
  /**
333
   * {@inheritdoc}
334
   */
335 1
  public function getName() {
336 1
    return $this->name;
337
  }
338
339
  /**
340
   * {@inheritdoc}
341
   */
342 1
  public function getLeague() {
343 1
    return $this->league;
344
  }
345
346
  /**
347
   * {@inheritdoc}
348
   */
349 1
  public function getFilename() {
350 1
    return $this->filename;
351
  }
352
353
  /**
354
   * {@inheritdoc}
355
   */
356 1
  public function getSeason() {
357 1
    return $this->season;
358
  }
359
360
  /**
361
   * {@inheritdoc}
362
   */
363 1
  public function getDescription() {
364 1
    return $this->description;
365
  }
366
367
  /**
368
   * {@inheritdoc}
369
   */
370 1
  public function getHomeScore() {
371 1
    return $this->homeScore;
372
  }
373
374
  /**
375
   * {@inheritdoc}
376
   */
377 1
  public function getRound() {
378 1
    return $this->round;
379
  }
380
381
  /**
382
   * {@inheritdoc}
383
   */
384 1
  public function getAwayScore() {
385 1
    return $this->awayScore;
386
  }
387
388
  /**
389
   * {@inheritdoc}
390
   */
391 1
  public function getSpecators() {
392 1
    return $this->specators;
393
  }
394
395
  /**
396
   * {@inheritdoc}
397
   */
398 1
  public function getHomeGoalDetails() {
399 1
    return $this->homeGoalDetails;
400
  }
401
402
  /**
403
   * {@inheritdoc}
404
   */
405 1
  public function getHomeRedCards() {
406 1
    return $this->homeRedCards;
407
  }
408
409
  /**
410
   * {@inheritdoc}
411
   */
412 1
  public function getHomeYellowCards() {
413 1
    return $this->homeYellowCards;
414
  }
415
416
  /**
417
   * {@inheritdoc}
418
   */
419 1
  public function getHomeLineupGoalkeeper() {
420 1
    return $this->homeLineupGoalkeeper;
421
  }
422
423
  /**
424
   * {@inheritdoc}
425
   */
426 1
  public function getHomeLineupDefense() {
427 1
    return $this->homeLineupDefense;
428
  }
429
430
  /**
431
   * {@inheritdoc}
432
   */
433 1
  public function getHomeLineupMidfield() {
434 1
    return $this->homeLineupMidfield;
435
  }
436
437
  /**
438
   * {@inheritdoc}
439
   */
440 1
  public function getHomeLineupForward() {
441 1
    return $this->homeLineupForward;
442
  }
443
444
  /**
445
   * {@inheritdoc}
446
   */
447 1
  public function getHomeLineupSubstitutes() {
448 1
    return $this->homeLineupSubstitues;
449
  }
450
451
  /**
452
   * {@inheritdoc}
453
   */
454 1
  public function getHomeFormation() {
455 1
    return $this->homeFormation;
456
  }
457
458
  /**
459
   * {@inheritdoc}
460
   */
461 1
  public function getAwayRedCards() {
462 1
    return $this->awayRedCards;
463
  }
464
465
  /**
466
   * {@inheritdoc}
467
   */
468 1
  public function getAwayYellowCards() {
469 1
    return $this->awayYellowCards;
470
  }
471
472
  /**
473
   * {@inheritdoc}
474
   */
475 1
  public function getAwayGoalDetails() {
476 1
    return $this->awayGoalDetails;
477
  }
478
479
  /**
480
   * {@inheritdoc}
481
   */
482 1
  public function getAwayLineupGoalkeeper() {
483 1
    return $this->awayLineupGoalkeeper;
484
  }
485
486
  /**
487
   * {@inheritdoc}
488
   */
489 1
  public function getAwayLineupDefense() {
490 1
    return $this->awayLineupDefense;
491
  }
492
493
  /**
494
   * {@inheritdoc}
495
   */
496 1
  public function getAwayLineupMidfield() {
497 1
    return $this->awayLineupMidfield;
498
  }
499
500
  /**
501
   * {@inheritdoc}
502
   */
503 1
  public function getAwayLineupForward() {
504 1
    return $this->awayLineupForward;
505
  }
506
507
  /**
508
   * {@inheritdoc}
509
   */
510 1
  public function getAwayLineupSubstitutes() {
511 1
    return $this->awayLineupSubstitutes;
512
  }
513
514
  /**
515
   * {@inheritdoc}
516
   */
517 1
  public function getAwayFormation() {
518 1
    return $this->awayFormation;
519
  }
520
521
  /**
522
   * {@inheritdoc}
523
   */
524 1
  public function getHomeShots() {
525 1
    return $this->homeShots;
526
  }
527
528
  /**
529
   * {@inheritdoc}
530
   */
531 1
  public function getAwayShots() {
532 1
    return $this->awayShots;
533
  }
534
535
  /**
536
   * {@inheritdoc}
537
   */
538 1
  public function getDate() {
539 1
    return $this->date;
540
  }
541
542
  /**
543
   * {@inheritdoc}
544
   */
545 1
  public function getTvStation() {
546 1
    return $this->tvStation;
547
  }
548
549
  /**
550
   * {@inheritdoc}
551
   */
552 1
  public function getHomeTeam() {
553 1
    return $this->homeTeam;
554
  }
555
556
  /**
557
   * {@inheritdoc}
558
   */
559 1
  public function getAwayTeam() {
560 1
    return $this->awayTeam;
561
  }
562
563
  /**
564
   * {@inheritdoc}
565
   */
566 1
  public function getResult() {
567 1
    return $this->result;
568
  }
569
570
  /**
571
   * {@inheritdoc}
572
   */
573 1
  public function getCircuit() {
574 1
    return $this->circuit;
575
  }
576
577
  /**
578
   * {@inheritdoc}
579
   */
580 1
  public function getCountry() {
581 1
    return $this->country;
582
  }
583
584
  /**
585
   * {@inheritdoc}
586
   */
587 1
  public function getCity() {
588 1
    return $this->city;
589
  }
590
591
  /**
592
   * {@inheritdoc}
593
   */
594 1
  public function getPoster() {
595 1
    return $this->poster;
596
  }
597
598
  /**
599
   * {@inheritdoc}
600
   */
601 1
  public function getThumb() {
602 1
    return $this->thumb;
603
  }
604
605
  /**
606
   * {@inheritdoc}
607
   */
608 1
  public function getBanner() {
609 1
    return $this->banner;
610
  }
611
612
  /**
613
   * {@inheritdoc}
614
   */
615 1
  public function getMap() {
616 1
    return $this->map;
617
  }
618
619
  /**
620
   * {@inheritdoc}
621
   */
622 1
  public function getLocked() {
623 1
    return $this->locked;
624
  }
625
626
  /**
627
   * Transforms the league property to a league entity.
628
   *
629
   * @param mixed $value
630
   *   The source value of the league property.
631
   * @param \stdClass $context
632
   *   The source object representing this event.
633
   * @param EntityManagerInterface $entityManager
634
   *   The entity manager.
635
   *
636
   * @return \TheSportsDb\Entity\LeagueInterface
637
   *   The league entity.
638
   */
639
  public static function transformLeague($value, $context, EntityManagerInterface $entityManager) {
640
    return static::transform($value, $context, $entityManager, 'league', 'idLeague', array('strLeague' => 'strLeague'));
641
  }
642
643
  /**
644
   * Transforms the season property to a season entity.
645
   *
646
   * @param mixed $value
647
   *   The source value of the season property.
648
   * @param \stdClass $context
649
   *   The source object representing this event.
650
   * @param EntityManagerInterface $entityManager
651
   *   The entity manager.
652
   *
653
   * @return \TheSportsDb\Entity\SeasonInterface
654
   *   The season entity.
655
   */
656
  public static function transformSeason($value, $context, EntityManagerInterface $entityManager) {
657
    $season = is_object($value) ? $value : (object) array('idLeague' => $context->idLeague, 'strSeason' => $value);
658
    $id = $season->strSeason . '|' . $season->idLeague;
659
    $seasonEntity = $entityManager->repository('season')->byId($id);
660
    $seasonEntity->update($season);
661
    return $seasonEntity;
662
  }
663
664
  /**
665
   * Transforms the home team property to a team entity.
666
   *
667
   * @param mixed $value
668
   *   The source value of the home team property.
669
   * @param \stdClass $context
670
   *   The source object representing this event.
671
   * @param EntityManagerInterface $entityManager
672
   *   The entity manager.
673
   *
674
   * @return \TheSportsDb\Entity\TeamInterface
675
   *   The team entity.
676
   */
677
  public static function transformHomeTeam($value, $context, EntityManagerInterface $entityManager) {
678
    return static::transform($value, $context, $entityManager, 'team', 'idTeam', array('strHomeTeam' => 'strTeam'));
679
  }
680
681
  /**
682
   * Transforms the away team property to a team entity.
683
   *
684
   * @param mixed $value
685
   *   The source value of the away team property.
686
   * @param \stdClass $context
687
   *   The source object representing this event.
688
   * @param EntityManagerInterface $entityManager
689
   *   The entity manager.
690
   *
691
   * @return \TheSportsDb\Entity\TeamInterface
692
   *   The team entity.
693
   */
694
  public static function transformAwayTeam($value, $context, EntityManagerInterface $entityManager) {
695
    return static::transform($value, $context, $entityManager, 'team', 'idTeam', array('strAwayTeam' => 'strTeam'));
696
  }
697
698
  /**
699
   * {@inhertidoc}
700
   */
701
  protected static function initPropertyMapDefinition() {
702
    static::$propertyMapDefinition
703
      ->addPropertyMap(
704
        new PropertyDefinition('idEvent'),
705
        new PropertyDefinition('id')
706
      )
707
      ->addPropertyMap(
708
        new PropertyDefinition('strEvent'),
709
        new PropertyDefinition('name')
710
      )
711
      ->addPropertyMap(
712
        new PropertyDefinition('strFilename'),
713
        new PropertyDefinition('filename')
714
      )
715
      ->addPropertyMap(
716
        new PropertyDefinition('idLeague'),
717
        new PropertyDefinition('league', 'league'),
718
        [static::class, 'transformLeague'],
719
        [League::class, 'reverse']
720
      )
721
      ->addPropertyMap(
722
        new PropertyDefinition('strSeason'),
723
        new PropertyDefinition('season', 'season'),
724
        [static::class, 'transformSeason'],
725
        [Season::class, 'reverse']
726
      )
727
      ->addPropertyMap(
728
        new PropertyDefinition('strDescriptionEN'),
729
        new PropertyDefinition('description')
730
      )
731
      ->addPropertyMap(
732
        new PropertyDefinition('intHomeScore'),
733
        new PropertyDefinition('homeScore')
734
      )
735
      ->addPropertyMap(
736
        new PropertyDefinition('intRound'),
737
        new PropertyDefinition('round')
738
      )
739
      ->addPropertyMap(
740
        new PropertyDefinition('intAwayScore'),
741
        new PropertyDefinition('awayScore')
742
      )
743
      ->addPropertyMap(
744
        new PropertyDefinition('intSpectators'),
745
        new PropertyDefinition('spectators')
746
      )
747
      ->addPropertyMap(
748
        new PropertyDefinition('strHomeGoalDetails'),
749
        new PropertyDefinition('homeGoalDetails')
750
      )
751
      ->addPropertyMap(
752
        new PropertyDefinition('strHomeRedCards'),
753
        new PropertyDefinition('homeRedCards')
754
      )
755
      ->addPropertyMap(
756
        new PropertyDefinition('strHomeYellowCards'),
757
        new PropertyDefinition('homeYellowCards')
758
      )
759
      ->addPropertyMap(
760
        new PropertyDefinition('strHomeLineupGoalkeeper'),
761
        new PropertyDefinition('homeLineupGoalkeeper')
762
      )
763
      ->addPropertyMap(
764
        new PropertyDefinition('strHomeLineupDefense'),
765
        new PropertyDefinition('homeLineupDefense')
766
      )
767
      ->addPropertyMap(
768
        new PropertyDefinition('strHomeLineupMidfield'),
769
        new PropertyDefinition('homeLineupMidfield')
770
      )
771
      ->addPropertyMap(
772
        new PropertyDefinition('strHomeLineupForward'),
773
        new PropertyDefinition('homeLineupForward')
774
      )
775
      ->addPropertyMap(
776
        new PropertyDefinition('strHomeLineupSubstitutes'),
777
        new PropertyDefinition('homeLineupSubstitutes')
778
      )
779
      ->addPropertyMap(
780
        new PropertyDefinition('strHomeLineupFormation'),
781
        new PropertyDefinition('homeLineupFormation')
782
      )
783
      ->addPropertyMap(
784
        new PropertyDefinition('intHomeShots'),
785
        new PropertyDefinition('homeShots')
786
      )
787
      ->addPropertyMap(
788
        new PropertyDefinition('strAwayGoalDetails'),
789
        new PropertyDefinition('awayGoalDetails')
790
      )
791
      ->addPropertyMap(
792
        new PropertyDefinition('strAwayRedCards'),
793
        new PropertyDefinition('awayRedCards')
794
      )
795
      ->addPropertyMap(
796
        new PropertyDefinition('strAwayYellowCards'),
797
        new PropertyDefinition('awayYellowCards')
798
      )
799
      ->addPropertyMap(
800
        new PropertyDefinition('strAwayLineupGoalkeeper'),
801
        new PropertyDefinition('awayLineupGoalkeeper')
802
      )
803
      ->addPropertyMap(
804
        new PropertyDefinition('strAwayLineupDefense'),
805
        new PropertyDefinition('awayLineupDefense')
806
      )
807
      ->addPropertyMap(
808
        new PropertyDefinition('strAwayLineupMidfield'),
809
        new PropertyDefinition('awayLineupMidfield')
810
      )
811
      ->addPropertyMap(
812
        new PropertyDefinition('strAwayLineupForward'),
813
        new PropertyDefinition('awayLineupForward')
814
      )
815
      ->addPropertyMap(
816
        new PropertyDefinition('strAwayLineupSubstitutes'),
817
        new PropertyDefinition('awayLineupSubstitutes')
818
      )
819
      ->addPropertyMap(
820
        new PropertyDefinition('strAwayLineupFormation'),
821
        new PropertyDefinition('awayLineupFormation')
822
      )
823
      ->addPropertyMap(
824
        new PropertyDefinition('intAwayShots'),
825
        new PropertyDefinition('awayShots')
826
      )
827
      ->addPropertyMap(
828
        new PropertyDefinition('dateEvent'),
829
        new PropertyDefinition('date')
830
      )/* todo: map dateEvent and strTime to date*/
0 ignored issues
show
Coding Style Best Practice introduced by
Comments for TODO tasks are often forgotten in the code; it might be better to use a dedicated issue tracker.
Loading history...
831
      ->addPropertyMap(
832
        new PropertyDefinition('strTVStation'),
833
        new PropertyDefinition('tvStation')
834
      )
835
      ->addPropertyMap(
836
        new PropertyDefinition('idHomeTeam'),
837
        new PropertyDefinition('homeTeam', 'team'),
838
        [static::class, 'transformHomeTeam'],
839
        [Team::class, 'reverse']
840
      )
841
      ->addPropertyMap(
842
        new PropertyDefinition('idAwayTeam'),
843
        new PropertyDefinition('awayTeam', 'team'),
844
        [self::class, 'transformAwayTeam'],
845
        [Team::class, 'reverse']
846
      )
847
      ->addPropertyMap(
848
        new PropertyDefinition('strResult'),
849
        new PropertyDefinition('result')
850
      )
851
      ->addPropertyMap(
852
        new PropertyDefinition('strCircuit'),
853
        new PropertyDefinition('circuit')
854
      )
855
      ->addPropertyMap(
856
        new PropertyDefinition('strCountry'),
857
        new PropertyDefinition('country')
858
      )
859
      ->addPropertyMap(
860
        new PropertyDefinition('strCity'),
861
        new PropertyDefinition('city')
862
      )
863
      ->addPropertyMap(
864
        new PropertyDefinition('strPoster'),
865
        new PropertyDefinition('poster')
866
      )
867
      ->addPropertyMap(
868
        new PropertyDefinition('strThumb'),
869
        new PropertyDefinition('thumb')
870
      )
871
      ->addPropertyMap(
872
        new PropertyDefinition('strBanner'),
873
        new PropertyDefinition('banner')
874
      )
875
      ->addPropertyMap(
876
        new PropertyDefinition('strMap'),
877
        new PropertyDefinition('map')
878
      )
879
      ->addPropertyMap(
880
        new PropertyDefinition('strLocked'),
881
        new PropertyDefinition('locked')
882
      );
883
      // idSoccerXML
884
      // strLeague
885
      // strHomeTeam
886
      // strAwayTeam
887
      // strFanart
888
      // strTime
889
  }
890
891
}
892