Completed
Push — master ( 60d200...e262bd )
by Andrea
08:44
created

Fifree2createdatabaseCommand   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 27.78%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 5
dl 0
loc 30
ccs 5
cts 18
cp 0.2778
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 7 1
A execute() 0 18 2
1
<?php
2
3
namespace Fi\CoreBundle\Command;
4
5
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
6
use Symfony\Component\Console\Input\InputInterface;
7
use Symfony\Component\Console\Output\OutputInterface;
8
use Symfony\Component\Console\Input\ArrayInput;
9
10
class Fifree2createdatabaseCommand extends ContainerAwareCommand
11
{
12
13 1
    protected function configure()
14
    {
15
        $this
16 1
                ->setName('fifree2:createdatabase')
17 1
                ->setDescription('Creazione database fifree')
18 1
                ->setHelp('Creazione di un nuovo database di fifree');
19 1
    }
20
21
    protected function execute(InputInterface $input, OutputInterface $output)
22
    {
23
        /* @var $em \Doctrine\ORM\EntityManager */
24
        $em = $this->getContainer()->get('doctrine')->getManager();
25
        $driver = $em->getConnection()->getDriver()->getName();
26
27
28
        if ($driver != "pdo_sqlite") {
29
            $command = $this->getApplication()->find('doctrine:database:create');
30
            $arguments = array('--if-not-exists' => true);
31
            $inputcmd = new ArrayInput($arguments);
32
            $command->run($inputcmd, $output);
33
        }
34
        $command = $this->getApplication()->find('doctrine:schema:create');
35
        $arguments = array('');
36
        $inputcmd = new ArrayInput($arguments);
37
        $command->run($inputcmd, $output);
38
    }
39
}
40