UserPackage::addToContainer()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 2

Importance

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