Passed
Push — develop ( ee596d...b4560d )
by Kevin
05:19 queued 02:34
created

CreateTable   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Test Coverage

Coverage 40%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
lcom 1
cbo 6
dl 0
loc 32
ccs 6
cts 15
cp 0.4
rs 10
c 1
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 10 1
A execute() 0 12 2
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
    use ConfigurationFactoryTrait;
17
18
    const COMMAND = 'magium:configuration:create-table';
19
20 1
    protected function configure()
21
    {
22
        $this
23 1
            ->setName(self::COMMAND)
24 1
            ->setDescription('Create configuration table in the database')
25 1
            ->setHelp(
26 1
                'This command will create the table for holding configuration values in the configured database.')
27
        ;
28
29 1
    }
30
31
    protected function execute(InputInterface $input, OutputInterface $output)
32
    {
33
        $output->writeln('Creating configuration table...');
34
        $factory = $this->getConfigurationFactory();
35
        $persistence = $factory->getBuilderFactory()->getPersistence();
36
        try {
37
            $persistence->create();
38
            $output->writeln('Table created');
39
        } catch (\Exception $e) {
40
            $output->writeln('Unable to create table: ' . $e->getMessage());
41
        }
42
    }
43
44
}
45