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

User::addUserService()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 7
ccs 5
cts 5
cp 1
rs 9.4285
cc 1
eloc 4
nc 1
nop 1
crap 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
}