Module   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 12

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 0
cbo 12
dl 0
loc 42
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getConfig() 0 4 1
B onBootstrap() 0 34 2
1
<?php
2
3
namespace DoctrineMigrationsModule;
4
5
use
0 ignored issues
show
Coding Style introduced by
There must be a single space after the USE keyword
Loading history...
6
    \Doctrine\DBAL\Migrations\Tools\Console\Command\DiffCommand,
7
    \Doctrine\DBAL\Migrations\Tools\Console\Command\ExecuteCommand,
8
    \Doctrine\DBAL\Migrations\Tools\Console\Command\GenerateCommand,
9
    \Doctrine\DBAL\Migrations\Tools\Console\Command\MigrateCommand,
10
    \Doctrine\DBAL\Migrations\Tools\Console\Command\StatusCommand,
11
    \Doctrine\DBAL\Migrations\Tools\Console\Command\VersionCommand,
12
    \Zend\EventManager\EventInterface;
13
use Doctrine\ORM\EntityManager;
14
15
16
class Module
17
{
18
    public function getConfig()
19
    {
20
        return include __DIR__ . '/../../config/module.config.php';
21
    }
22
23
    public function onBootstrap(EventInterface $e)
24
    {
25
        $application = $e->getTarget();
26
        $events = $application->getEventManager()->getSharedManager();
27
        $configuration = $application->getServiceManager()->get('doctrine.migrations.configuration');
0 ignored issues
show
Unused Code introduced by
$configuration is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
28
        // Attach to helper set event and load the entity manager helper.
29
        $events->attach('doctrine', 'loadCli.post', function (EventInterface $e) {
30
            $sm = $e->getParam('ServiceManager');
31
32
            /* @var $cli \Symfony\Component\Console\Application */
33
            $cli = $e->getTarget();
34
            $commands = array(
35
                new DiffCommand(),
36
                new ExecuteCommand(),
37
                new GenerateCommand(),
38
                new MigrateCommand(),
39
                new StatusCommand(),
40
                new VersionCommand(),
41
            );
42
43
            $configuration = $sm->get('doctrine.migrations.configuration');
44
            foreach($commands AS $command) {
45
                $command->setMigrationConfiguration($configuration);
46
            }
47
            $cli->addCommands($commands);
48
49
            /** @var EntityManager $em */
50
            $em = $sm->get('doctrine.entitymanager.orm_default');
51
            $hs = $cli->getHelperSet();
52
            $hs->set(new \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($em), 'em');
53
            $hs->set(new \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($em->getConnection()), 'db');
54
            $hs->set(new \Symfony\Component\Console\Helper\DialogHelper(), 'dialog');
55
        });
56
    }
57
}
58