Passed
Push — master ( aab8f3...c0357c )
by Derek Stephen
03:21
created

UserPackage::addToContainer()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 1

Importance

Changes 3
Bugs 0 Features 0
Metric Value
cc 1
eloc 7
c 3
b 0
f 0
nc 1
nop 1
dl 0
loc 13
ccs 8
cts 8
cp 1
crap 1
rs 10
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 3
    public function addToContainer(Container $c): void
21
    {
22 3
        $personPackage = new PersonPackage();
23 3
        $personPackage->addToContainer($c);
24
25 3
        $function = function (Container $c) {
26 3
            $entityManager = $c->get(EntityManager::class);
27 3
            $personService = $c->get(PersonService::class);
28
29 3
            return new UserService($entityManager, $personService);
30
        };
31
32 3
        $c[UserService::class] = $c->factory($function);
33 3
    }
34
35
    /**
36
     * @return string
37
     */
38 1
    public function getEntityPath(): string
39
    {
40 1
        return 'vendor/delboy1978uk/user/src/Entity';
41
    }
42
43
    /**
44
     * @param Container $container
45
     * @return array
46
     */
47 1
    public function registerConsoleCommands(Container $container): array
48
    {
49 1
        $userService = $container->get(UserService::class);
50 1
        $userCommand = new UserCommand($userService);
51
52 1
        return [$userCommand];
53
    }
54
}
55