Passed
Push — master ( acbcc2...152ef5 )
by Andrea
17:16 queued 11s
created

Fifree2createdatabaseCommand   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 76.47%

Importance

Changes 0
Metric Value
wmc 3
eloc 16
dl 0
loc 28
ccs 13
cts 17
cp 0.7647
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 6 1
A execute() 0 17 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 6
    protected function configure()
14
    {
15
        $this
16 6
                ->setName('fifree2:createdatabase')
17 6
                ->setDescription('Creazione database fifree')
18 6
                ->setHelp('Creazione di un nuovo database di fifree');
19 6
    }
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();
0 ignored issues
show
Deprecated Code introduced by
The function Doctrine\DBAL\Driver::getName() has been deprecated. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

25
        $driver = /** @scrutinizer ignore-deprecated */ $em->getConnection()->getDriver()->getName();
Loading history...
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