Completed
Push — master ( 622106...eab52f )
by Derek Stephen
02:07
created

User::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
namespace Del\Config\Container;
4
5
use Del\Common\Container\RegistrationInterface;
6
use Del\Repository\User as UserRepository;
7
use Del\Service\User as UserService;
8
use Doctrine\ORM\EntityManager;
9
use Pimple\Container;
10
11
class User implements RegistrationInterface
12
{
13
    /**
14
     * @param Container $c
15
     */
16 1
    public function addToContainer(Container $c)
17
    {
18 1
        $this->addUserRepository($c);
19 1
        $this->addUserService($c);
20 1
    }
21
22 1
    private function addUserRepository(Container $c)
23
    {
24
        $c['repository.user'] = $c->factory(function ($c) {
25
            /** @var EntityManager $em */
26 1
            $em = $c['doctrine.entity_manager'];
27
            /** @var UserRepository $repo */
28 1
            $repo = $em->getRepository('Del\Entity\User');
29 1
            return $repo;
30 1
        });
31 1
    }
32
33
    private function addUserService(Container $c)
34
    {
35 1
        $c['service.user'] = $c->factory(function ($c) {
36
            $svc = new UserService($c['doctrine.entity_manager'], $c['service.person']);
37
            return $svc;
38 1
        });
39 1
    }
40
41
    public function getEntityPath()
42
    {
43
        return 'vendor/delboy1978uk/user/src/Entity';
44
    }
45
46
    public function hasEntityPath()
47
    {
48
        return true;
49
    }
50
51
}