ConvertMappingDoctrineCommand::getExporter()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 12
rs 9.8666
cc 3
nc 3
nop 2
1
<?php
2
3
namespace Doctrine\Bundle\DoctrineBundle\Command\Proxy;
4
5
use Doctrine\ORM\Tools\Console\Command\ConvertMappingCommand;
6
use Doctrine\ORM\Tools\Export\Driver\AbstractExporter;
7
use Doctrine\ORM\Tools\Export\Driver\XmlExporter;
8
use Doctrine\ORM\Tools\Export\Driver\YamlExporter;
9
use Symfony\Component\Console\Input\InputInterface;
10
use Symfony\Component\Console\Input\InputOption;
11
use Symfony\Component\Console\Output\OutputInterface;
12
13
/**
14
 * Convert Doctrine ORM metadata mapping information between the various supported
15
 * formats.
16
 */
17
class ConvertMappingDoctrineCommand extends ConvertMappingCommand
18
{
19
    /**
20
     * {@inheritDoc}
21
     */
22
    protected function configure()
23
    {
24
        parent::configure();
25
        $this
26
            ->setName('doctrine:mapping:convert')
27
            ->addOption('em', null, InputOption::VALUE_OPTIONAL, 'The entity manager to use for this command');
28
    }
29
30
    /**
31
     * {@inheritDoc}
32
     */
33
    protected function execute(InputInterface $input, OutputInterface $output)
34
    {
35
        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...
36
37
        return parent::execute($input, $output);
38
    }
39
40
    /**
41
     * @param string $toType
42
     * @param string $destPath
43
     *
44
     * @return AbstractExporter
45
     */
46
    protected function getExporter($toType, $destPath)
47
    {
48
        /** @var AbstractExporter $exporter */
49
        $exporter = parent::getExporter($toType, $destPath);
50
        if ($exporter instanceof XmlExporter) {
51
            $exporter->setExtension('.orm.xml');
52
        } elseif ($exporter instanceof YamlExporter) {
53
            $exporter->setExtension('.orm.yml');
54
        }
55
56
        return $exporter;
57
    }
58
}
59