Completed
Push — master ( c5c5d3...85a7e3 )
by Jelle
06:44
created

SeasonRepository::byLeague()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 7
rs 9.4285
cc 2
eloc 5
nc 2
nop 1
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
  protected $entityType = 'season';
17
18
  /**
19
   * {@inheritdoc}
20
   */
21
  public function byId($id) {
22
    if (!isset($this->repository[$id])) {
23
      list($name, $league) = explode('|', $id);
1 ignored issue
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 3 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
24
      $factory = $this->entityManager->factory($this->getEntityTypeName());
1 ignored issue
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 15 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
25
      $this->repository[$id] = $factory->create(
26
        (object) array('id' => $id, 'name' => $name, 'league' => (object) array('id' => $league)),
27
        $this->getEntityTypeName()
28
      );
29
    }
30
    return $this->repository[$id];
31
  }
32
  /**
33
   * {@inheritdoc}
34
   */
35
  public function all() {
36
    // Loading all seasons without any further context is rediculous.
37
    return array();
38
  }
39
40
  public function byLeague($leagueId) {
41
    $data = $this->sportsDbClient->doRequest('search_all_seasons.php', array('id' => $leagueId))->seasons;
42
    foreach ($data as &$season) {
43
      $season->idLeague = $leagueId;
44
    }
45
    return $this->normalizeArray($data);
46
  }
47
48
}
49