Completed
Push — master ( ad4118...2bb684 )
by Jelle
10:14 queued 04:02
created

LeagueProxy   A

Complexity

Total Complexity 28

Size/Duplication

Total Lines 192
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 3

Test Coverage

Coverage 73.32%

Importance

Changes 0
Metric Value
wmc 28
lcom 2
cbo 3
dl 0
loc 192
ccs 44
cts 60
cp 0.7332
rs 10
c 0
b 0
f 0

24 Methods

Rating   Name   Duplication   Size   Complexity  
A load() 0 8 2
A loadSeasons() 0 14 4
A getAlternateName() 0 3 1
A getBadge() 0 3 1
A getBanner() 0 3 1
A getCountry() 0 3 1
A getDateFirstEvent() 0 3 1
A getDescription() 0 3 1
A getFacebook() 0 3 1
A getFormedYear() 0 3 1
A getGender() 0 3 1
A getId() 0 3 1
A getLocked() 0 3 1
A getLogo() 0 3 1
A getName() 0 3 1
A getNaming() 0 3 1
A getPoster() 0 3 1
A getRss() 0 3 1
A getTrophy() 0 3 1
A getTwitter() 0 3 1
A getWebsite() 0 3 1
A getYoutube() 0 3 1
A getSeasons() 0 3 1
A getSport() 0 3 1
1
<?php
2
/**
3
 * @file
4
 * Contains \TheSportsDb\Entity\Proxy\LeagueProxy.
5
 */
6
7
namespace TheSportsDb\Entity\Proxy;
8
9
use TheSportsDb\Entity\LeagueInterface;
10
11
/**
12
 * A league object that is not yet fully loaded.
13
 *
14
 * @author Jelle Sebreghts
15
 */
16
class LeagueProxy extends Proxy implements LeagueInterface {
17
18
  /**
19
   * {@inheritdoc}
20
   */
21
  protected function load() {
22
    $leagueData = $this->sportsDbClient->doRequest('lookupleague.php', array('id' => $this->properties->id));
23
    if (isset($leagueData->leagues)) {
24
      $this->update($this->entityManager->mapProperties(reset($leagueData->leagues), $this->getEntityType()));
25
      return;
26
    }
27
    throw new \Exception('Could not fully load league with id ' . $this->properties->id . '.');
28
  }
29
30
  /**
31
   * Lazy loads the seasons for this league.
32
   *
33
   * @throws \Exception
34
   *   When the seasons cannot be loaded.
35
   *
36
   * @return void
37
   */
38
  protected function loadSeasons() {
39
    $leagueData = $this->sportsDbClient->doRequest('lookupleague.php', array('id' => $this->properties->id, 's' => 'all'));
40
    if (isset($leagueData->leagues)) {
41
      $leagues = $leagueData->leagues;
42
      foreach ($leagues as &$league) {
43
        if (!isset($league->idLeague)) {
44
          $league->idLeague = $this->properties->id;
45
        }
46
      }
47
      $this->update($this->entityManager->mapProperties((object) array('seasons' => $leagues), $this->getEntityType()));
48
      return;
49
    }
50
    throw new \Exception('Could not fully load league with id ' . $this->properties->id . '.');
51
  }
52
53
  /**
54
   * {@inheritdoc}
55
   */
56 1
  public function getAlternateName() {
57 1
    return $this->get('alternateName');
58
  }
59
60
  /**
61
   * {@inheritdoc}
62
   */
63 1
  public function getBadge() {
64 1
    return $this->get('badge');
65
  }
66
67
  /**
68
   * {@inheritdoc}
69
   */
70 1
  public function getBanner() {
71 1
    return $this->get('banner');
72
  }
73
74
  /**
75
   * {@inheritdoc}
76
   */
77 1
  public function getCountry() {
78 1
    return $this->get('country');
79
  }
80
81
  /**
82
   * {@inheritdoc}
83
   */
84 1
  public function getDateFirstEvent() {
85 1
    return $this->get('dateFirstEvent');
86
  }
87
88
  /**
89
   * {@inheritdoc}
90
   */
91 1
  public function getDescription() {
92 1
    return $this->get('description');
93
  }
94
95
  /**
96
   * {@inheritdoc}
97
   */
98 1
  public function getFacebook() {
99 1
    return $this->get('facebook');
100
  }
101
102
  /**
103
   * {@inheritdoc}
104
   */
105 1
  public function getFormedYear() {
106 1
    return $this->get('formedYear');
107
  }
108
109
  /**
110
   * {@inheritdoc}
111
   */
112 1
  public function getGender() {
113 1
    return $this->get('gender');
114
  }
115
116
  /**
117
   * {@inheritdoc}
118
   */
119 1
  public function getId() {
120 1
    return $this->get('id');
121
  }
122
123
  /**
124
   * {@inheritdoc}
125
   */
126 1
  public function getLocked() {
127 1
    return $this->get('locked');
128
  }
129
130
  /**
131
   * {@inheritdoc}
132
   */
133 1
  public function getLogo() {
134 1
    return $this->get('logo');
135
  }
136
137
  /**
138
   * {@inheritdoc}
139
   */
140 1
  public function getName() {
141 1
    return $this->get('name');
142
  }
143
144
  /**
145
   * {@inheritdoc}
146
   */
147 1
  public function getNaming() {
148 1
    return $this->get('naming');
149
  }
150
151
  /**
152
   * {@inheritdoc}
153
   */
154 1
  public function getPoster() {
155 1
    return $this->get('poster');
156
  }
157
158
  /**
159
   * {@inheritdoc}
160
   */
161 1
  public function getRss() {
162 1
    return $this->get('rss');
163
  }
164
165
  /**
166
   * {@inheritdoc}
167
   */
168 1
  public function getTrophy() {
169 1
    return $this->get('trophy');
170
  }
171
172
  /**
173
   * {@inheritdoc}
174
   */
175 1
  public function getTwitter() {
176 1
    return $this->get('twitter');
177
  }
178
179
  /**
180
   * {@inheritdoc}
181
   */
182 1
  public function getWebsite() {
183 1
    return $this->get('website');
184
  }
185
186
  /**
187
   * {@inheritdoc}
188
   */
189 1
  public function getYoutube() {
190 1
    return $this->get('youtube');
191
  }
192
193
  /**
194
   * {@inheritdoc}
195
   */
196 1
  public function getSeasons() {
197 1
    return $this->get('seasons');
198
  }
199
200
  /**
201
   * {@inheritdoc}
202
   */
203 1
  public function getSport() {
204 1
    return $this->get('sport');
205
  }
206
207
}
208