SyncDBCommand::configure()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 3
Bugs 0 Features 0
Metric Value
c 3
b 0
f 0
dl 0
loc 7
ccs 5
cts 5
cp 1
rs 9.4285
cc 1
eloc 5
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Velikonja\LabbyBundle\Command;
4
5
use Symfony\Component\Console\Input\InputInterface;
6
use Symfony\Component\Console\Output\OutputInterface;
7
use Symfony\Component\Stopwatch\Stopwatch;
8
use Velikonja\LabbyBundle\Service\Syncer;
9
10
class SyncDBCommand extends BaseCommand
11
{
12
    const COMMAND_NAME = 'labby:sync:db';
13
14
    /**
15
     * Configure command.
16
     */
17 10
    protected function configure()
18
    {
19
        $this
20 10
            ->setRoles(array(self::ROLE_LOCAL))
21 10
            ->setName(self::COMMAND_NAME)
22 10
            ->setDescription('Run synchronization of database.');
23 10
    }
24
25
    /**
26
     * @param InputInterface  $input
27
     * @param OutputInterface $output
28
     *
29
     * @throws \Exception
30
     *
31
     * @return int|null|void
32
     */
33 2
    protected function execute(InputInterface $input, OutputInterface $output)
34
    {
35
        /** @var Syncer $syncer */
36 2
        $syncer    = $this->getContainer()->get('velikonja_labby.service.syncer');
37 2
        $stopwatch = new Stopwatch();
38
39 2
        $stopwatch->start('sync_db');
40 2
        $syncer->syncDb($output);
41 2
        $event = $stopwatch->stop('sync_db');
42
43 2
        $output->writeln('');
44 2
        $output->writeln(
45
            sprintf(
46 2
                '<info>Finished in %.2f seconds!</info>',
47 2
                $event->getDuration() / 1000
48
            )
49
        );
50 2
    }
51
}
52