Completed
Push — master ( 3a5307...b28f87 )
by Olivier
03:32
created

DebugDBALCommand   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 53.33%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 36
ccs 8
cts 15
cp 0.5333
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A configure() 0 7 1
A execute() 0 10 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Shapin\Datagen\Bridge\Symfony\Bundle\Command;
6
7
use Shapin\Datagen\DBAL\Loader;
8
use Symfony\Component\Console\Command\Command;
9
use Symfony\Component\Console\Input\InputInterface;
10
use Symfony\Component\Console\Output\OutputInterface;
11
use Symfony\Component\Console\Style\SymfonyStyle;
12
13
class DebugDBALCommand extends Command
14
{
15
    private $connection;
16
17 3
    public function __construct(Loader $loader)
18
    {
19 3
        $this->loader = $loader;
0 ignored issues
show
Bug introduced by
The property loader does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
20
21 3
        parent::__construct();
22 3
    }
23
24
    /**
25
     * {@inheritdoc}
26
     */
27 3
    protected function configure()
28
    {
29
        $this
30 3
            ->setName('shapin:datagen:debug:dbal')
31 3
            ->setDescription('Display information about DBAL schema.')
32
        ;
33 3
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38
    protected function execute(InputInterface $input, OutputInterface $output)
39
    {
40
        $io = new SymfonyStyle($input, $output);
41
        $io->title('Repartition of tables by groups.');
42
43
        foreach ($this->loader->getGroups() as $group => $tables) {
44
            $io->section($group);
45
            $io->listing($tables);
46
        }
47
    }
48
}
49