Completed
Push — master ( 105df6...247973 )
by Derek Stephen
02:24
created

Person::getEntityPath()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
/**
3
 * User: delboy1978uk
4
 * Date: 06/01/16
5
 * Time: 21:07
6
 */
7
8
namespace Del\Config\Container;
9
10
use Del\Common\Container\RegistrationInterface;
11
use Del\Repository\Person as PersonRepository;
12
use Del\Service\Person as PersonService;
13
use Doctrine\ORM\EntityManager;
14
use Pimple\Container;
15
16
class Person implements RegistrationInterface
17
{
18
    /**
19
     * @param Container $c
20
     */
21
    public function addToContainer(Container $c)
22
    {
23
        $this->addPersonRepository($c);
24
        $this->addPersonService($c);
25
    }
26
27 2
    private function addPersonRepository(Container $c)
28
    {
29
        $c['repository.person'] = $c->factory(function ($c) {
30
            /** @var EntityManager $em */
31 2
            $em = $c['doctrine.entity_manager'];
32
            /** @var PersonRepository $repo */
33 2
            $repo = $em->getRepository('Del\Entity\Person');
34 2
            return $repo;
35
        });
36
    }
37
38
    private function addPersonService(Container $c)
39
    {
40
        $c['service.person'] = $c->factory(function ($c) {
41
            $svc = new PersonService($c['doctrine.entity_manager']);
42
            return $svc;
43
        });
44
    }
45
46
    public function getEntityPath()
47
    {
48
        return 'vendor/delboy1978uk/person/src/Entity';
49
    }
50
51
    public function hasEntityPath()
52
    {
53
        return true;
54
    }
55
56
57
}