Completed
Push — master ( d8d25b...3f99c9 )
by Quentin
59s
created

AbstractDoctrineLoader   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 0%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setEntityRepository() 0 6 1
A getEntityRepository() 0 11 2
1
<?php
2
3
namespace Majora\Framework\Loader\Bridge\Doctrine;
4
5
use Doctrine\ORM\EntityRepository;
6
use Majora\Framework\Loader\LoaderInterface;
7
8
/**
9
 * Abstract class for doctrine loaders.
10
 */
11
abstract class AbstractDoctrineLoader implements LoaderInterface
12
{
13
    /**
14
     * @var EntityRepository
15
     */
16
    private $entityRepository;
17
18
    /**
19
     * Define Doctrine loader related doctrine repository for current entity.
20
     *
21
     * @param EntityRepository $entityRepository
22
     */
23
    public function setEntityRepository(EntityRepository $entityRepository)
24
    {
25
        $this->entityRepository = $entityRepository;
26
27
        return $this;
28
    }
29
30
    /**
31
     * Return entity repository.
32
     *
33
     * @return EntityRepository
34
     */
35
    protected function getEntityRepository()
36
    {
37
        if (!$this->entityRepository) {
38
            throw new \RuntimeException(sprintf(
39
                'Any defined entity repository into "%s" loader, consider calling "setEntityRepository()" right after object creation.',
40
                get_class($this)
41
            ));
42
        }
43
44
        return $this->entityRepository;
45
    }
46
}
47