Completed
Push — master ( fe3da2...17d2a9 )
by Derek Stephen
06:57
created

UserPackage::addToContainer()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1.1715

Importance

Changes 0
Metric Value
dl 0
loc 14
ccs 4
cts 9
cp 0.4444
rs 9.7998
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1.1715
1
<?php
2
3
namespace Del;
4
5
use Barnacle\EntityRegistrationInterface;
6
use Barnacle\RegistrationInterface;
7
use Bone\Console\CommandRegistrationInterface;
8
use Del\Console\UserCommand;
9
use Del\Person\PersonPackage;
10
use Del\Person\Service\PersonService;
11
use Del\Service\UserService;
12
use Barnacle\Container;
13
use Doctrine\ORM\EntityManager;
14
15
class UserPackage implements RegistrationInterface, EntityRegistrationInterface, CommandRegistrationInterface
16
{
17
    /**
18
     * @param Container $c
19
     */
20 26
    public function addToContainer(Container $c): void
21
    {
22
        $personPackage = new PersonPackage();
23
        $personPackage->addToContainer($c);
24
25
        $function = function (Container $c) {
26 26
            $entityManager = $c->get(EntityManager::class);
27 26
            $personService = $c->get(PersonService::class);
28
29 26
            return new UserService($entityManager, $personService);
30
        };
31
32
        $c[UserService::class] = $c->factory($function);
33
    }
34
35
    /**
36
     * @return string
37
     */
38
    public function getEntityPath(): string
39
    {
40
        return 'vendor/delboy1978uk/user/src/Entity';
41
    }
42
43
    /**
44
     * @param Container $container
45
     * @return array
46
     */
47
    public function registerConsoleCommands(Container $container): array
48
    {
49
        $userService = $container->get(UserService::class);
50
        $userCommand = new UserCommand($userService);
51
52
        return [$userCommand];
53
    }
54
}
55