RunDqlDoctrineCommand   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 41
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
c 0
b 0
f 0
lcom 1
cbo 3
dl 41
loc 41
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 25 25 1
A execute() 6 6 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace Doctrine\Bundle\DoctrineBundle\Command\Proxy;
4
5
use Doctrine\ORM\Tools\Console\Command\RunDqlCommand;
6
use Symfony\Component\Console\Input\InputInterface;
7
use Symfony\Component\Console\Input\InputOption;
8
use Symfony\Component\Console\Output\OutputInterface;
9
10
/**
11
 * Execute a Doctrine DQL query and output the results.
12
 */
13 View Code Duplication
class RunDqlDoctrineCommand extends RunDqlCommand
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
14
{
15
    /**
16
     * {@inheritDoc}
17
     */
18
    protected function configure()
19
    {
20
        parent::configure();
21
22
        $this
23
            ->setName('doctrine:query:dql')
24
            ->addOption('em', null, InputOption::VALUE_OPTIONAL, 'The entity manager to use for this command')
25
            ->setHelp(<<<EOT
26
The <info>%command.name%</info> command executes the given DQL query and
27
outputs the results:
28
29
<info>php %command.full_name% "SELECT u FROM UserBundle:User u"</info>
30
31
You can also optional specify some additional options like what type of
32
hydration to use when executing the query:
33
34
<info>php %command.full_name% "SELECT u FROM UserBundle:User u" --hydrate=array</info>
35
36
Additionally you can specify the first result and maximum amount of results to
37
show:
38
39
<info>php %command.full_name% "SELECT u FROM UserBundle:User u" --first-result=0 --max-result=30</info>
40
EOT
41
        );
42
    }
43
44
    /**
45
     * {@inheritDoc}
46
     */
47
    protected function execute(InputInterface $input, OutputInterface $output)
48
    {
49
        DoctrineCommandHelper::setApplicationEntityManager($this->getApplication(), $input->getOption('em'));
0 ignored issues
show
Documentation introduced by
$this->getApplication() is of type null|object<Symfony\Comp...nt\Console\Application>, but the function expects a object<Symfony\Bundle\Fr...le\Console\Application>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
50
51
        return parent::execute($input, $output);
52
    }
53
}
54