Completed
Push — master ( 58cbfb...3697fd )
by Andrea
47:14 queued 44:56
created

Fifree2createdatabaseCommand   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 75%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 5
dl 0
loc 30
ccs 15
cts 20
cp 0.75
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 3
    protected function configure()
14
    {
15 3
        $this
16 3
                ->setName('fifree2:createdatabase')
17 3
                ->setDescription('Creazione database fifree')
18 3
                ->setHelp('Creazione di un nuovo database di fifree');
19 3
    }
20
21 1
    protected function execute(InputInterface $input, OutputInterface $output)
22
    {
23
        /* @var $em \Doctrine\ORM\EntityManager */
24 1
        $em = $this->getContainer()->get('doctrine')->getManager();
25 1
        $driver = $em->getConnection()->getDriver()->getName();
26
27
28 1
        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 1
        $command = $this->getApplication()->find('doctrine:schema:create');
35 1
        $arguments = array('');
36 1
        $inputcmd = new ArrayInput($arguments);
37 1
        $command->run($inputcmd, $output);
38 1
    }
39
}
40