ProxyCommand::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 21
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 21
ccs 0
cts 9
cp 0
rs 9.3142
c 0
b 0
f 0
cc 1
eloc 15
nc 1
nop 7
crap 2
1
<?php
2
3
namespace BrainExe\Core\Console;
4
5
use Symfony\Component\Console\Application;
6
use Symfony\Component\Console\Command\Command;
7
use Symfony\Component\Console\Input\InputInterface;
8
use Symfony\Component\Console\Output\OutputInterface;
9
use Symfony\Component\DependencyInjection\Container;
10
11
class ProxyCommand extends Command
12
{
13
14
    /**
15
     * @var Container
16
     */
17
    private $container;
18
19
    /**
20
     * @var string
21
     */
22
    private $serviceId;
23
24
    /**
25
     * @param Container $container
26
     * @param Application $application
27
     * @param string $serviceId
28
     * @param string $name
29
     * @param string $description
30
     * @param string|array $alias
31
     * @param array $definition
32
     */
33
    public function __construct(
34
        Container $container,
35
        Application $application,
0 ignored issues
show
Unused Code introduced by
The parameter $application is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
36
        string $serviceId,
37
        string $name,
38
        $description,
39
        $alias,
40
        array $definition
41
    ) {
42
43
        $this->setName($name);
44
        $this->setDescription($description);
45
        $this->setAliases($alias);
0 ignored issues
show
Documentation introduced by
$alias is of type string|array, but the function expects a array<integer,string>.

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...
46
47
        $this->container = $container;
48
        $this->serviceId = $serviceId;
49
50
        parent::__construct();
51
52
        $this->setDefinition($definition);
53
    }
54
55
    /**
56
     * @param InputInterface $input
57
     * @param OutputInterface $output
58
     * @return int|null
59
     */
60
    protected function execute(InputInterface $input, OutputInterface $output)
61
    {
62
        /** @var Command $child */
63
        $child = $this->container->get($this->serviceId);
64
        $child->setApplication($this->getApplication());
65
        $child->setDefinition($this->getDefinition());
66
67
        return $child->execute($input, $output);
68
    }
69
}
70