Issues (26)

Security Analysis    no request data  

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

src/TheSportsDb.php (5 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/**
3
 * @file
4
 * The main sportsdb class.
5
 */
6
7
namespace TheSportsDb;
8
9
use TheSportsDb\Entity\EntityManagerConsumerInterface;
10
use TheSportsDb\Entity\EntityManagerConsumerTrait;
11
use TheSportsDb\Entity\EntityManagerInterface;
12
use TheSportsDb\Entity\Proxy\ProxyInterface;
13
14
/**
15
 * Main API class for TheSportsDb.
16
 *
17
 * @author Jelle Sebreghts
18
 */
19
class TheSportsDb implements EntityManagerConsumerInterface {
20
21
  use EntityManagerConsumerTrait;
22
23
  /**
24
   * Creates a new TheSportsDb instance
25
   */
26
  public function __construct(EntityManagerInterface $entityManager = NULL) {
27
    if ($entityManager instanceof EntityManagerInterface) {
28
      $this->entityManager = $entityManager;
29
    }
30
  }
31
32
  /**
33
   * Gets all sports.
34
   *
35
   * @return \TheSportsDb\Entity\SportInterface[]
36
   *   The sports.
37
   */
38 1
  public function getSports() {
39 1
    return $this->entityManager->repository('sport')->all();
40
  }
41
42
  /**
43
   * Get a sport by name.
44
   *
45
   * @param string $name
46
   *   The sport name.
47
   *
48
   * @return \TheSportsDb\Entity\SportInterface
49
   *   The sport.
50
   */
51 1 View Code Duplication
  public function getSport($name) {
0 ignored issues
show
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...
52 1
    $entity = $this->entityManager->repository('sport')->byId($name);
53 1
    if ($entity instanceof ProxyInterface) {
54
      try {
55 1
        $entity->load();
56
      }
57 1
      catch (\Exception $e) {
58 1
        return FALSE;
59
      }
60
    }
61 1
    return $entity;
62
  }
63
64
  /**
65
   * Gets all leagues.
66
   *
67
   * @return \TheSportsDb\Entity\LeagueInterface[]
68
   *   The leagues.
69
   */
70 1
  public function getLeagues() {
71 1
    return $this->entityManager->repository('league')->all();
72
  }
73
74
  /**
75
   * Get a league by id.
76
   *
77
   * @param int $leagueId
78
   *   The league id.
79
   *
80
   * @return \TheSportsDb\Entity\LeagueInterface
81
   *   The league.
82
   */
83 1 View Code Duplication
  public function getLeague($leagueId) {
0 ignored issues
show
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...
84 1
    $entity = $this->entityManager->repository('league')->byId($leagueId);
85 1
    if ($entity instanceof ProxyInterface) {
86
      try {
87 1
        $entity->load();
88
      }
89 1
      catch (\Exception $e) {
90 1
        return FALSE;
91
      }
92
    }
93 1
    return $entity;
94
  }
95
96
  /**
97
   * Gets all leagues by country.
98
   *
99
   * @param string $country
100
   *   The country of which to get the leagues.
101
   *
102
   * @return \TheSportsDb\Entity\LeagueInterface[]
103
   *   The leagues.
104
   */
105 1
  public function getLeaguesByCountry($country) {
106 1
    return $this->entityManager->repository('league')->byCountry($country);
107
  }
108
109
  /**
110
   * Gets all leagues by sport.
111
   *
112
   * @param mixed $sport
113
   *   The sport of which to get the leagues.
114
   *
115
   * @return \TheSportsDb\Entity\LeagueInterface[]
116
   *   The leagues.
117
   */
118 1
  public function getLeaguesBySport($sport) {
119 1
    return $this->entityManager->repository('league')->bySport($sport);
120
  }
121
122
  /**
123
   * Gets all leagues by country and sport.
124
   *
125
   * @param string $country
126
   *   The country of which to get the leagues.
127
   * @param mixed $sport
128
   *   The sport of which to get the leagues.
129
   *
130
   * @return \TheSportsDb\Entity\LeagueInterface[]
131
   *   The leagues.
132
   */
133 1
  public function getLeaguesByCountryAndSport($country, $sport) {
134 1
    return $this->entityManager->repository('league')->byCountryAndSport($country, $sport);
135
  }
136
137
  /**
138
   * Gets a team by id.
139
   *
140
   * @param mixed $teamId
141
   *   The team id.
142
   *
143
   * @return \TheSportsDb\Entity\TeamInterface
144
   *   The team.
145
   */
146 1 View Code Duplication
  public function getTeam($teamId) {
0 ignored issues
show
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...
147 1
    $entity = $this->entityManager->repository('team')->byId($teamId);
148 1
    if ($entity instanceof ProxyInterface) {
149
      try {
150 1
        $entity->load();
151
      }
152 1
      catch (\Exception $e) {
153 1
        return FALSE;
154
      }
155
    }
156 1
    return $entity;
157
  }
158
159
  /**
160
   * Gets a team by name.
161
   *
162
   * @param string $teamName
163
   *   The team name.
164
   *
165
   * @return \TheSportsDb\Entity\TeamInterface[]
166
   *   The team.
167
   */
168 1
  public function getTeamsByName($teamName) {
169 1
    return $this->entityManager->repository('team')->byName($teamName);
170
  }
171
172
  /**
173
   * Gets a teams by league id.
174
   *
175
   * @param mixed $leagueId
176
   *   The league id.
177
   *
178
   * @return \TheSportsDb\Entity\TeamInterface[]
179
   *   The teams.
180
   */
181 1
  public function getTeamsByLeague($leagueId) {
182 1
    return $this->entityManager->repository('team')->byLeague($leagueId);
183
  }
184
185
  /**
186
   * Gets a teams by league name.
187
   *
188
   * @param string $leagueName
189
   *   The league name.
190
   *
191
   * @return \TheSportsDb\Entity\TeamInterface[]
192
   *   The teams.
193
   */
194 1
  public function getTeamsByLeagueName($leagueName) {
195 1
    return $this->entityManager->repository('team')->byLeagueName($leagueName);
196
  }
197
198
  /**
199
   * Gets a teams by sport and country.
200
   *
201
   * @param mixed $sport
202
   *   The sport.
203
   * @param string $country
204
   *   The country.
205
   *
206
   * @return \TheSportsDb\Entity\TeamInterface[]
207
   *   The teams.
208
   */
209 1
  public function getTeamsBySportAndCountry($sport, $country) {
210 1
    return $this->entityManager->repository('team')->bySportAndCountry($sport, $country);
211
  }
212
213
  /**
214
   * Get a player by id.
215
   *
216
   * @param mixed $playerId
217
   *   The player id.
218
   *
219
   * @return \TheSportsDb\Entity\PlayerInterface
220
   *   The player.
221
   */
222 1 View Code Duplication
  public function getPlayer($playerId) {
0 ignored issues
show
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...
223 1
    $entity = $this->entityManager->repository('player')->byId($playerId);
224 1
    if ($entity instanceof ProxyInterface) {
225
      try {
226 1
        $entity->load();
227
      }
228 1
      catch (\Exception $e) {
229 1
        return FALSE;
230
      }
231
    }
232 1
    return $entity;
233
  }
234
235
  /**
236
   * Get a players by team id.
237
   *
238
   * @param mixed $teamId
239
   *   The team id.
240
   *
241
   * @return \TheSportsDb\Entity\PlayerInterface[]
242
   *   The players.
243
   */
244 1
  public function getPlayersByTeam($teamId) {
245 1
    return $this->entityManager->repository('player')->byTeam($teamId);
246
  }
247
248
  /**
249
   * Get a players by team name.
250
   *
251
   * @param mixed $teamName
252
   *   The team name.
253
   *
254
   * @return \TheSportsDb\Entity\PlayerInterface[]
255
   *   The players.
256
   */
257 1
  public function getPlayersByTeamName($teamName) {
258 1
    return $this->entityManager->repository('player')->byTeamName($teamName);
259
  }
260
261
  /**
262
   * Get a players by name.
263
   *
264
   * @param mixed $name
265
   *   The name.
266
   *
267
   * @return \TheSportsDb\Entity\PlayerInterface[]
268
   *   The players.
269
   */
270 1
  public function getPlayersByName($name) {
271 1
    return $this->entityManager->repository('player')->byName($name);
272
  }
273
274
  /**
275
   * Get a players by team and name.
276
   *
277
   * @param string $teamName
278
   *   The team name.
279
   * @param string $name
280
   *   The name.
281
   *
282
   * @return \TheSportsDb\Entity\PlayerInterface[]
283
   *   The players.
284
   */
285 1
  public function getPlayersByTeamNameAndName($teamName, $name) {
286 1
    return $this->entityManager->repository('player')->byTeamNameAndName($teamName, $name);
287
  }
288
289
  /**
290
   * Get an event by id.
291
   *
292
   * @param mixed $eventId
293
   *   The event id.
294
   *
295
   * @return \TheSportsDb\Entity\EventInterface
296
   *   The event.
297
   */
298 1 View Code Duplication
  public function getEvent($eventId) {
0 ignored issues
show
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...
299 1
    $entity = $this->entityManager->repository('event')->byId($eventId);
300 1
    if ($entity instanceof ProxyInterface) {
301
      try {
302 1
        $entity->load();
303
      }
304 1
      catch (\Exception $e) {
305 1
        return FALSE;
306
      }
307
    }
308 1
    return $entity;
309
  }
310
311
  /**
312
   * Get events by name.
313
   *
314
   * @param string $name
315
   *   The event name.
316
   *
317
   * @return \TheSportsDb\Entity\EventInterface[]
318
   *   The events.
319
   */
320 1
  public function getEventsByName($name) {
321 1
    return $this->entityManager->repository('event')->byName($name);
322
  }
323
324
  /**
325
   * Get events by file name.
326
   *
327
   * @param string $name
328
   *   The file name.
329
   *
330
   * @return \TheSportsDb\Entity\EventInterface[]
331
   *   The events.
332
   */
333 1
  public function getEventsByFileName($name) {
334 1
    return $this->entityManager->repository('event')->byFileName($name);
335
  }
336
337
  /**
338
   * Get events by name and season.
339
   *
340
   * @param string $name
341
   *   The event name.
342
   * @param mixed $season
343
   *   The season.
344
   *
345
   * @return \TheSportsDb\Entity\EventInterface[]
346
   *   The events.
347
   */
348 1
  public function getEventsByNameAndSeason($name, $season) {
349 1
    return $this->entityManager->repository('event')->byNameAndSeason($name, $season);
350
  }
351
352
  /**
353
   * Get next five events by team.
354
   *
355
   * @param mixed $teamId
356
   *   The team id.
357
   *
358
   * @return \TheSportsDb\Entity\EventInterface[]
359
   *   The events.
360
   */
361 1
  public function getNextFiveEventsByTeam($teamId) {
362 1
    return $this->entityManager->repository('event')->nextFiveByTeam($teamId);
363
  }
364
365
  /**
366
   * Get next fifteen events by league.
367
   *
368
   * @param mixed $leagueId
369
   *   The league id.
370
   *
371
   * @return \TheSportsDb\Entity\EventInterface[]
372
   *   The events.
373
   */
374 1
  public function getNextFifteenEventsByLeague($leagueId) {
375 1
    return $this->entityManager->repository('event')->nextFifteenByLeague($leagueId);
376
  }
377
378
  /**
379
   * Get next fifteen events by league and round.
380
   *
381
   * @param mixed $leagueId
382
   *   The league id.
383
   * @param int $round
384
   *   The round.
385
   *
386
   * @return \TheSportsDb\Entity\EventInterface[]
387
   *   The events.
388
   */
389 1
  public function getNextFifteenEventsByLeagueAndRound($leagueId, $round) {
390 1
    return $this->entityManager->repository('event')->nextFifteenByLeagueAndRound($leagueId, $round);
391
  }
392
393
  /**
394
   * Get last five events by team.
395
   *
396
   * @param mixed $teamId
397
   *   The team id.
398
   *
399
   * @return \TheSportsDb\Entity\EventInterface[]
400
   *   The events.
401
   */
402 1
  public function getLastFiveEventsByTeam($teamId) {
403 1
    return $this->entityManager->repository('event')->lastFiveByTeam($teamId);
404
  }
405
406
  /**
407
   * Get last fifteen events by league.
408
   *
409
   * @param mixed $leagueId
410
   *   The league id.
411
   *
412
   * @return \TheSportsDb\Entity\EventInterface[]
413
   *   The events.
414
   */
415 1
  public function getLastFifteenEventsByLeague($leagueId) {
416 1
    return $this->entityManager->repository('event')->lastFifteenByLeague($leagueId);
417
  }
418
419
  /**
420
   * Get events by day.
421
   *
422
   * @param \DateTime $date
423
   *   The day.
424
   * @param string|null $sport
425
   *   The sport.
426
   * @param string|null $leagueName
427
   *   The league name.
428
   *
429
   * @return \TheSportsDb\Entity\EventInterface[]
430
   *   The events.
431
   */
432 1
  public function getEventsByDay(\DateTime $date, $sport = NULL, $leagueName = NULL) {
433 1
    return $this->entityManager->repository('event')->byDay($date, $sport, $leagueName);
434
  }
435
436
  /**
437
   * Get events by league, round and season.
438
   *
439
   * @param mixed $leagueId
440
   *   The league id.
441
   * @param int $round
442
   *   The round.
443
   * @param mixed $season
444
   *   The season.
445
   *
446
   * @return \TheSportsDb\Entity\EventInterface[]
447
   *   The events.
448
   */
449 1
  public function getEventsByLeagueRoundAndSeason($leagueId, $round, $season) {
450 1
    return $this->entityManager->repository('event')->byLeagueRoundAndSeason($leagueId, $round, $season);
451
  }
452
453
  /**
454
   * Get events by league and season.
455
   *
456
   * @param mixed $leagueId
457
   *   The league id.
458
   * @param mixed $season
459
   *   The season.
460
   *
461
   * @return \TheSportsDb\Entity\EventInterface[]
462
   *   The events.
463
   */
464 1
  public function getEventsByLeagueAndSeason($leagueId, $season) {
465 1
    return $this->entityManager->repository('event')->byLeagueAndSeason($leagueId, $season);
466
  }
467
468
  /**
469
   * Get seasons by league.
470
   *
471
   * @param mixed $leagueId
472
   *   The league id.
473
   *
474
   * @return \TheSportsDb\Entity\SeasonInterface[]
475
   *   The seasons.
476
   */
477 1
  public function getSeasonsByLeague($leagueId) {
478 1
    return $this->entityManager->repository('season')->byLeague($leagueId);
479
  }
480
}
481