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

DebugDBALCommand::configure()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
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