Completed
Pull Request — master (#4)
by Alessandro
05:13
created

AbstractClientCommand   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 3
dl 0
loc 28
ccs 0
cts 15
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 7 1
A initialize() 0 8 2
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Facile\MongoDbBundle\Commands;
6
7
use Facile\MongoDbBundle\Capsule\Client;
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 AbstractClientCommand.
14
 */
15
class AbstractClientCommand extends AbstractCommand
16
{
17
    /**
18
     * @var Client
19
     */
20
    protected $client;
21
    /**
22
     * {@inheritdoc}
23
     */
24
    protected function configure()
25
    {
26
        parent::configure();
27
        $this
28
            ->addOption('connection', null, InputOption::VALUE_OPTIONAL, 'The connection to use for this command')
29
        ;
30
    }
31
    /**
32
     * {@inheritdoc}
33
     */
34
    protected function initialize(InputInterface $input, OutputInterface $output)
35
    {
36
        parent::initialize($input, $output);
37
        $this->client = $input->getOption('connection')
38
            ? $this->getContainer()->get('mongo.connection.'.$input->getOption('connection'))
39
            : $this->getContainer()->get('mongo.connection')
40
        ;
41
    }
42
}
43