CreateTable::execute()   A
last analyzed

Complexity

Conditions 2
Paths 3

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

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