Passed
Pull Request — develop (#24)
by Kevin
02:49
created

CreateTable::execute()   A

Complexity

Conditions 2
Paths 3

Size

Total Lines 12
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 12
ccs 0
cts 0
cp 0
rs 9.4285
cc 2
eloc 9
nc 3
nop 2
crap 6
1
<?php
2
3
namespace Magium\Configuration\Console\Command;
4
5
use Magium\Configuration\Config\Config;
6
use Magium\Configuration\Config\InvalidContextException;
7
use Magium\Configuration\MagiumConfigurationFactory;
8
use Symfony\Component\Console\Command\Command;
9
use Symfony\Component\Console\Input\InputArgument;
10
use Symfony\Component\Console\Input\InputInterface;
11
use Symfony\Component\Console\Output\OutputInterface;
12
13
class CreateTable extends Command
14
{
15
16
    const COMMAND = 'magium:configuration:create-table';
17
18 1
    protected function configure()
19
    {
20
        $this
21 1
            ->setName(self::COMMAND)
22 1
            ->setDescription('Create configuration table in the database')
23 1
            ->setHelp(
24 1
                'This command will create the table for holding configuration values in the configured database.')
25
        ;
26
27 1
    }
28
29
    protected function execute(InputInterface $input, OutputInterface $output)
30
    {
31
        $output->writeln('Creating configuration table...');
32
        $factory = new MagiumConfigurationFactory();
33
        $persistence = $factory->getBuilderFactory()->getPersistence();
34
        try {
35
            $persistence->create();
36
            $output->writeln('Table created');
37
        } catch (\Exception $e) {
38
            $output->writeln('Unable to create table: ' . $e->getMessage());
39
        }
40
    }
41
42
}
43