Completed
Push — master ( 9466a4...206d9f )
by Pablo
04:08
created

Application   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
A setCommand() 0 4 1
A doRun() 0 6 1
1
<?php
2
3
4
namespace Bruli\EventBusBundleTests\Infrastructure;
5
6
use Bruli\EventBusBundle\CommandBus\CommandInterface;
7
use Bruli\EventBusBundleTests\Behaviour\SingleCommand;
8
use Symfony\Component\Console\Input\InputInterface;
9
use Symfony\Component\Console\Output\OutputInterface;
10
11
final class Application extends \Symfony\Component\Console\Application
12
{
13
    /**
14
     * @var AppKernel
15
     */
16
    private $container;
17
    /**
18
     * @var CommandInterface
19
     */
20
    private $command;
21
22
    public function __construct()
23
    {
24
        $appKernel = new AppKernel('dev', true);
25
        $appKernel->boot();
26
        $this->container = $appKernel->getContainer();
0 ignored issues
show
Documentation Bug introduced by
It seems like $appKernel->getContainer() can also be of type object<Symfony\Component...ion\ContainerInterface>. However, the property $container is declared as type object<Bruli\EventBusBun...frastructure\AppKernel>. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
27
28
        parent::__construct('command test');
29
    }
30
31
    /**
32
     * @param CommandInterface $command
33
     */
34
    public function setCommand(CommandInterface $command)
35
    {
36
        $this->command = $command;
37
    }
38
39
    public function doRun(InputInterface $input, OutputInterface $output)
40
    {
41
        $command = $this->container->get('bruli.command.bus');
0 ignored issues
show
Bug introduced by
The method get() does not seem to exist on object<Bruli\EventBusBun...frastructure\AppKernel>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
42
43
        $command->handle($this->command);
44
    }
45
46
}