SeasonRepository   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 2
cbo 4
dl 0
loc 42
ccs 15
cts 15
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A byId() 0 11 2
A all() 0 4 1
A byLeague() 0 7 3
1
<?php
2
/**
3
 * @file
4
 * Contains \TheSportsDb\Entity\Repository\SeasonRepository.
5
 */
6
7
namespace TheSportsDb\Entity\Repository;
8
9
/**
10
 * The default SeasonRepository implementation.
11
 *
12
 * @author Jelle Sebreghts
13
 */
14
class SeasonRepository extends Repository implements SeasonRepositoryInterface {
15
16
  /**
17
   * {@inheritdoc}
18
   */
19
  protected $entityType = 'season';
20
21
  /**
22
   * {@inheritdoc}
23
   */
24 1
  public function byId($id) {
25 1
    if (!isset($this->repository[$id])) {
26 1
      list($name, $league) = explode('|', $id);
27 1
      $factory = $this->entityManager->factory($this->getEntityTypeName());
28 1
      $this->repository[$id] = $factory->create(
29 1
        (object) array('id' => $id, 'name' => $name, 'league' => (object) array('id' => $league)),
30 1
        $this->getEntityTypeName()
31
      );
32
    }
33 1
    return $this->repository[$id];
34
  }
35
36
  /**
37
   * {@inheritdoc}
38
   */
39 1
  public function all() {
40
    // Loading all seasons without any further context is rediculous.
41 1
    return array();
42
  }
43
44
  /**
45
   * {@inheritdoc}
46
   */
47 1
  public function byLeague($leagueId) {
48 1
    $data = $this->sportsDbClient->doRequest('search_all_seasons.php', array('id' => $leagueId))->seasons ?: array();
49 1
    foreach ($data as &$season) {
50 1
      $season->idLeague = $leagueId;
51
    }
52 1
    return $this->normalizeArray($data);
53
  }
54
55
}
56