Passed
Pull Request — master (#31)
by Catalin
03:34
created

MigrationsExecuteCommand   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 45.45%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
dl 0
loc 22
ccs 5
cts 11
cp 0.4545
rs 10
c 1
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 7 1
A execute() 0 10 1
1
<?php
2
3
/*
4
 * This file is part of the AntiMattr MongoDB Migrations Bundle, a library by Matthew Fitzgerald.
5
 *
6
 * (c) 2014 Matthew Fitzgerald
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace AntiMattr\Bundle\MongoDBMigrationsBundle\Command;
13
14
use AntiMattr\MongoDB\Migrations\Tools\Console\Command\ExecuteCommand;
15
use Symfony\Bundle\FrameworkBundle\Console\Application;
16
use Symfony\Component\Console\Input\InputInterface;
17
use Symfony\Component\Console\Input\InputOption;
18
use Symfony\Component\Console\Output\OutputInterface;
19
20
/**
21
 * @author Matthew Fitzgerald <[email protected]>
22
 */
23
class MigrationsExecuteCommand extends ExecuteCommand
24
{
25 1
    protected function configure()
26
    {
27 1
        parent::configure();
28
29
        $this
30 1
            ->setName('mongodb:migrations:execute')
31 1
            ->addOption('dm', null, InputOption::VALUE_OPTIONAL, 'The document manager to use for this command.', 'default_document_manager')
32
        ;
33 1
    }
34
35
    public function execute(InputInterface $input, OutputInterface $output)
36
    {
37
        /** @var Application $application */
38
        $application = $this->getApplication();
39
        CommandHelper::setApplicationDocumentManager($application, $input->getOption('dm'));
0 ignored issues
show
Bug introduced by
It seems like $input->getOption('dm') can also be of type string[]; however, parameter $dmName of AntiMattr\Bundle\MongoDB...cationDocumentManager() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

39
        CommandHelper::setApplicationDocumentManager($application, /** @scrutinizer ignore-type */ $input->getOption('dm'));
Loading history...
40
41
        $configuration = $this->getMigrationConfiguration($input, $output);
42
        CommandHelper::configureMigrations($application->getKernel()->getContainer(), $configuration);
43
44
        return parent::execute($input, $output);
0 ignored issues
show
Bug introduced by
Are you sure the usage of parent::execute($input, $output) targeting AntiMattr\MongoDB\Migrat...ecuteCommand::execute() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
45
    }
46
}
47