EventProxy   B
last analyzed

Complexity

Total Complexity 46

Size/Duplication

Total Lines 322
Duplicated Lines 2.48 %

Coupling/Cohesion

Components 2
Dependencies 3

Test Coverage

Coverage 91.49%

Importance

Changes 0
Metric Value
wmc 46
lcom 2
cbo 3
dl 8
loc 322
ccs 86
cts 94
cp 0.9149
rs 8.72
c 0
b 0
f 0

45 Methods

Rating   Name   Duplication   Size   Complexity  
A load() 8 8 2
A getAwayFormation() 0 3 1
A getAwayGoalDetails() 0 3 1
A getAwayLineupDefense() 0 3 1
A getAwayLineupForward() 0 3 1
A getAwayLineupGoalkeeper() 0 3 1
A getAwayLineupMidfield() 0 3 1
A getAwayLineupSubstitutes() 0 3 1
A getAwayRedCards() 0 3 1
A getAwayScore() 0 3 1
A getAwayShots() 0 3 1
A getAwayTeam() 0 3 1
A getAwayYellowCards() 0 3 1
A getBanner() 0 3 1
A getCircuit() 0 3 1
A getCity() 0 3 1
A getCountry() 0 3 1
A getDate() 0 3 1
A getDescription() 0 3 1
A getFilename() 0 3 1
A getHomeFormation() 0 3 1
A getHomeGoalDetails() 0 3 1
A getHomeLineupDefense() 0 3 1
A getHomeLineupForward() 0 3 1
A getHomeLineupGoalkeeper() 0 3 1
A getHomeLineupMidfield() 0 3 1
A getHomeLineupSubstitutes() 0 3 1
A getHomeRedCards() 0 3 1
A getHomeScore() 0 3 1
A getHomeShots() 0 3 1
A getHomeTeam() 0 3 1
A getHomeYellowCards() 0 3 1
A getId() 0 3 1
A getLeague() 0 3 1
A getLocked() 0 3 1
A getMap() 0 3 1
A getName() 0 3 1
A getPoster() 0 3 1
A getResult() 0 3 1
A getRound() 0 3 1
A getSeason() 0 3 1
A getSpecators() 0 3 1
A getThumb() 0 3 1
A getTime() 0 3 1
A getTvStation() 0 3 1

How to fix   Duplicated Code    Complexity   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

Complex Class

 Tip:   Before tackling complexity, make sure that you eliminate any duplication first. This often can reduce the size of classes significantly.

Complex classes like EventProxy often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use EventProxy, and based on these observations, apply Extract Interface, too.

1
<?php
2
/**
3
 * @file
4
 * Contains \TheSportsDb\Entity\Proxy\EventProxy.
5
 */
6
7
namespace TheSportsDb\Entity\Proxy;
8
9
use TheSportsDb\Entity\EventInterface;
10
11
/**
12
 * An event object that is not yet fully loaded.
13
 *
14
 * @author Jelle Sebreghts
15
 */
16
class EventProxy extends Proxy implements EventInterface {
17
18
  /**
19
   * {@inheritdoc}
20
   */
21 View Code Duplication
  public function load() {
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...
22
    $eventData = $this->sportsDbClient->doRequest('lookupevent.php', array('id' => $this->properties->id));
23
    if (isset($eventData->events)) {
24
      $this->update($this->entityManager->mapProperties(reset($eventData->events), $this->getEntityType()));
25
      return;
26
    }
27
    throw new \Exception('Could not fully load event with id ' . $this->properties->id . '.');
28
  }
29
30
  /**
31
   * {@inheritdoc}
32
   */
33 1
  public function getAwayFormation() {
34 1
    return $this->get('awayFormation');
35
  }
36
37
  /**
38
   * {@inheritdoc}
39
   */
40 1
  public function getAwayGoalDetails() {
41 1
    return $this->get('awayGoalDetails');
42
  }
43
44
  /**
45
   * {@inheritdoc}
46
   */
47 1
  public function getAwayLineupDefense() {
48 1
    return $this->get('awayLineupDefense');
49
  }
50
51
  /**
52
   * {@inheritdoc}
53
   */
54 1
  public function getAwayLineupForward() {
55 1
    return $this->get('awayLineupForward');
56
  }
57
58
  /**
59
   * {@inheritdoc}
60
   */
61 1
  public function getAwayLineupGoalkeeper() {
62 1
    return $this->get('awayLineupGoalkeeper');
63
  }
64
65
  /**
66
   * {@inheritdoc}
67
   */
68 1
  public function getAwayLineupMidfield() {
69 1
    return $this->get('awayLineupMidfield');
70
  }
71
72
  /**
73
   * {@inheritdoc}
74
   */
75 1
  public function getAwayLineupSubstitutes() {
76 1
    return $this->get('awayLineupSubstitutes');
77
  }
78
79
  /**
80
   * {@inheritdoc}
81
   */
82 1
  public function getAwayRedCards() {
83 1
    return $this->get('awayRedCards');
84
  }
85
86
  /**
87
   * {@inheritdoc}
88
   */
89 1
  public function getAwayScore() {
90 1
    return $this->get('awayScore');
91
  }
92
93
  /**
94
   * {@inheritdoc}
95
   */
96 1
  public function getAwayShots() {
97 1
    return $this->get('awayShots');
98
  }
99
100
  /**
101
   * {@inheritdoc}
102
   */
103 1
  public function getAwayTeam() {
104 1
    return $this->get('awayTeam');
105
  }
106
107
  /**
108
   * {@inheritdoc}
109
   */
110 1
  public function getAwayYellowCards() {
111 1
    return $this->get('awayYellowCards');
112
  }
113
114
  /**
115
   * {@inheritdoc}
116
   */
117 1
  public function getBanner() {
118 1
    return $this->get('banner');
119
  }
120
121
  /**
122
   * {@inheritdoc}
123
   */
124 1
  public function getCircuit() {
125 1
    return $this->get('circuit');
126
  }
127
128
  /**
129
   * {@inheritdoc}
130
   */
131 1
  public function getCity() {
132 1
    return $this->get('city');
133
  }
134
135
  /**
136
   * {@inheritdoc}
137
   */
138 1
  public function getCountry() {
139 1
    return $this->get('country');
140
  }
141
142
  /**
143
   * {@inheritdoc}
144
   */
145 1
  public function getDate() {
146 1
    return $this->get('date');
147
  }
148
149
  /**
150
   * {@inheritdoc}
151
   */
152 1
  public function getDescription() {
153 1
    return $this->get('description');
154
  }
155
156
  /**
157
   * {@inheritdoc}
158
   */
159 1
  public function getFilename() {
160 1
    return $this->get('filename');
161
  }
162
163
  /**
164
   * {@inheritdoc}
165
   */
166 1
  public function getHomeFormation() {
167 1
    return $this->get('homeFormation');
168
  }
169
170
  /**
171
   * {@inheritdoc}
172
   */
173 1
  public function getHomeGoalDetails() {
174 1
    return $this->get('homeGoalDetails');
175
  }
176
177
  /**
178
   * {@inheritdoc}
179
   */
180 1
  public function getHomeLineupDefense() {
181 1
    return $this->get('homeLineupDefense');
182
  }
183
184
  /**
185
   * {@inheritdoc}
186
   */
187 1
  public function getHomeLineupForward() {
188 1
    return $this->get('homeLineupForward');
189
  }
190
191
  /**
192
   * {@inheritdoc}
193
   */
194 1
  public function getHomeLineupGoalkeeper() {
195 1
    return $this->get('homeLineupGoalkeeper');
196
  }
197
198
  /**
199
   * {@inheritdoc}
200
   */
201 1
  public function getHomeLineupMidfield() {
202 1
    return $this->get('homeLineupMidfield');
203
  }
204
205
  /**
206
   * {@inheritdoc}
207
   */
208 1
  public function getHomeLineupSubstitutes() {
209 1
    return $this->get('homeLineupSubstitutes');
210
  }
211
212
  /**
213
   * {@inheritdoc}
214
   */
215 1
  public function getHomeRedCards() {
216 1
    return $this->get('homeRedCards');
217
  }
218
219
  /**
220
   * {@inheritdoc}
221
   */
222 1
  public function getHomeScore() {
223 1
    return $this->get('homeScore');
224
  }
225
226
  /**
227
   * {@inheritdoc}
228
   */
229 1
  public function getHomeShots() {
230 1
    return $this->get('homeShots');
231
  }
232
233
  /**
234
   * {@inheritdoc}
235
   */
236 1
  public function getHomeTeam() {
237 1
    return $this->get('homeTeam');
238
  }
239
240
  /**
241
   * {@inheritdoc}
242
   */
243 1
  public function getHomeYellowCards() {
244 1
    return $this->get('homeYellowCards');
245
  }
246
247
  /**
248
   * {@inheritdoc}
249
   */
250 1
  public function getId() {
251 1
    return $this->get('id');
252
  }
253
254
  /**
255
   * {@inheritdoc}
256
   */
257 1
  public function getLeague() {
258 1
    return $this->get('league');
259
  }
260
261
  /**
262
   * {@inheritdoc}
263
   */
264 1
  public function getLocked() {
265 1
    return $this->get('locked');
266
  }
267
268
  /**
269
   * {@inheritdoc}
270
   */
271 1
  public function getMap() {
272 1
    return $this->get('map');
273
  }
274
275
  /**
276
   * {@inheritdoc}
277
   */
278 1
  public function getName() {
279 1
    return $this->get('name');
280
  }
281
282
  /**
283
   * {@inheritdoc}
284
   */
285 1
  public function getPoster() {
286 1
    return $this->get('poster');
287
  }
288
289
  /**
290
   * {@inheritdoc}
291
   */
292 1
  public function getResult() {
293 1
    return $this->get('result');
294
  }
295
296
  /**
297
   * {@inheritdoc}
298
   */
299 1
  public function getRound() {
300 1
    return $this->get('round');
301
  }
302
303
  /**
304
   * {@inheritdoc}
305
   */
306 1
  public function getSeason() {
307 1
    return $this->get('season');
308
  }
309
310
  /**
311
   * {@inheritdoc}
312
   */
313 1
  public function getSpecators() {
314 1
    return $this->get('specators');
315
  }
316
317
  /**
318
   * {@inheritdoc}
319
   */
320 1
  public function getThumb() {
321 1
    return $this->get('thumb');
322
  }
323
324
  /**
325
   * {@inheritdoc}
326
   */
327
  public function getTime() {
328
    return $this->get('time');
329
  }
330
331
  /**
332
   * {@inheritdoc}
333
   */
334 1
  public function getTvStation() {
335 1
    return $this->get('tvStation');
336
  }
337
}
338