Completed
Push — master ( 0d8778...4693cf )
by Derek Stephen
05:55
created

User   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 100%

Importance

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

5 Methods

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