CreateTable   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Test Coverage

Coverage 40%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 6
dl 0
loc 32
ccs 6
cts 15
cp 0.4
rs 10
c 0
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 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