Completed
Push — master ( d916d6...61ec1a )
by Jelle
04:08
created

EntityManagerConsumerTrait   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 1 Features 0
Metric Value
wmc 2
c 3
b 1
f 0
lcom 0
cbo 0
dl 0
loc 25
ccs 5
cts 5
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A setEntityManager() 0 6 2
1
<?php
2
/**
3
 * @file
4
 * Contains TheSportsDb\Entity\EntityManagerConsumerTrait.
5
 */
6
namespace TheSportsDb\Entity;
7
8
use TheSportsDb\Entity\EntityManagerInterface;
9
10
/**
11
 * A trait to use by entity manager consumers.
12
 *
13
 * @author Jelle Sebreghts
14
 */
15
trait EntityManagerConsumerTrait {
16
17
  /**
18
   * The entity manager.
19
   *
20
   * @var \TheSportsDb\Entity\EntityManagerInterface
21
   */
22
  protected $entityManager;
23
24
  /**
25
   * Set the entity manager.
26
   *
27
   * @param \TheSportsDb\Entity\EntityManagerInterface $entityManager
28
   *   The entity manager to set.
29
   *
30
   * @throws \Exception
31
   *   If the entity manager is already set.
32
   */
33 2
  public function setEntityManager(EntityManagerInterface $entityManager) {
34 2
    if ($this->entityManager instanceof EntityManagerInterface) {
35 2
      throw new \Exception('Entity manager already set.');
36
    }
37 1
    $this->entityManager = $entityManager;
38 1
  }
39
}
40