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

RepositoryContainer   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 85.71%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 26
ccs 6
cts 7
cp 0.8571
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A addRepository() 0 3 1
A getRepository() 0 6 2
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