Completed
Push — master ( 714373...31da10 )
by Alessandro
10:21 queued 10:16
created

AbstractConnectionCommand   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
c 1
b 0
f 1
lcom 1
cbo 3
dl 0
loc 32
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 8 1
A initialize() 0 9 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Algatux\InfluxDbBundle\Command;
6
7
use InfluxDB\Database;
8
use Symfony\Component\Console\Input\InputInterface;
9
use Symfony\Component\Console\Input\InputOption;
10
use Symfony\Component\Console\Output\OutputInterface;
11
12
/**
13
 * Class for commands which needs the connection option.
14
 */
15
abstract class AbstractConnectionCommand extends AbstractCommand
16
{
17
    /**
18
     * @var Database
19
     */
20
    protected $connection;
21
22
    /**
23
     * {@inheritdoc}
24
     */
25
    protected function configure()
26
    {
27
        parent::configure();
28
29
        $this
30
            ->addOption('connection', null, InputOption::VALUE_OPTIONAL, 'The connection to use for this command')
31
        ;
32
    }
33
34
    /**
35
     * {@inheritdoc}
36
     */
37
    protected function initialize(InputInterface $input, OutputInterface $output)
38
    {
39
        parent::initialize($input, $output);
40
41
        $this->connection = $input->getOption('connection')
42
            ? $this->getContainer()->get('algatux_influx_db.connection.'.$input->getOption('connection').'.http')
43
            : $this->getContainer()->get('algatux_influx_db.connection.http')
44
        ;
45
    }
46
}
47