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

Fifree2createdatabaseCommand::execute()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 18
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 2.1821

Importance

Changes 0
Metric Value
dl 0
loc 18
ccs 9
cts 14
cp 0.6429
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 12
nc 2
nop 2
crap 2.1821
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