Completed
Push — master ( 637e73...30874d )
by Pablo
03:20
created

QueryBus   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 1
cbo 2
dl 33
loc 33
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 5 5 1
A handle() 4 4 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 PhpGitHooks\Infrastructure\CommandBus\QueryBus;
4
5
use PhpGitHooks\Infrastructure\CommandBus\BusOptionsResolver;
6
use Symfony\Component\DependencyInjection\ContainerInterface;
7
8 View Code Duplication
class QueryBus
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...
9
{
10
    /**
11
     * @var ContainerInterface
12
     */
13
    private $container;
14
    /**
15
     * @var BusOptionsResolver
16
     */
17
    private $optionsResolver;
18
19
    /**
20
     * QueryBus constructor.
21
     *
22
     * @param ContainerInterface $container
23
     * @param BusOptionsResolver $optionsResolver
24
     */
25
    public function __construct(ContainerInterface $container, BusOptionsResolver $optionsResolver)
26
    {
27
        $this->container = $container;
28
        $this->optionsResolver = $optionsResolver;
29
    }
30
31
    /**
32
     * @param QueryInterface $query
33
     *
34
     * @return mixed
35
     */
36
    public function handle(QueryInterface $query)
37
    {
38
        return $this->container->get($this->optionsResolver->getOption('\\'.get_class($query)))->handle($query);
0 ignored issues
show
Documentation introduced by
$this->optionsResolver->...\' . get_class($query)) is of type array, but the function expects a 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...
39
    }
40
}
41