Completed
Push — master ( db3a5a...bd914c )
by Jelle
10:58
created

RepositoryContainer::addRepository()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 3
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
/**
3
 * @file
4
 * Contains \TheSportsDb\Entity\Repository\RepositoryContainer.
5
 */
6
7
namespace TheSportsDb\Entity\Repository;
8
9
/**
10
 * The default repository container implementation.
11
 *
12
 * @author Jelle Sebreghts
13
 */
14
class RepositoryContainer implements RepositoryContainerInterface {
15
16
  /**
17
   * Holds the repositories.
18
   *
19
   * @var \TheSportsDb\Entity\Repository\RepositoryInterface[]
20
   */
21
  protected $repositories = array();
22
23
  /**
24
   * {@inheritdoc}
25
   */
26 1
  public function addRepository(RepositoryInterface $repository) {
27 1
    $this->repositories[$repository->getEntityTypeName()] = $repository;
28 1
  }
29
30
  /**
31
   * {@inheritdoc}
32
   */
33 1
  public function getRepository($entityType) {
34 1
    if (!isset($this->repositories[$entityType])) {
35 1
      throw new \Exception('No repository registered for ' . $entityType);
36
    }
37
    return $this->repositories[$entityType];
38
  }
39
}
40