Completed
Push — master ( 0513f3...46cdfb )
by Daniel
03:05
created

Handler   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 5
c 1
b 0
f 1
lcom 0
cbo 3
dl 0
loc 38
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A handle() 0 20 3
A getResolver() 0 4 1
1
<?php
2
3
namespace Cmobi\RabbitmqBundle\Rpc;
4
5
use Cmobi\RabbitmqBundle\Rpc\Exception\InvalidBodyAMQPMessageException;
6
use PhpAmqpLib\Message\AMQPMessage;
7
use Symfony\Component\HttpKernel\Controller\ControllerResolver;
8
9
class Handler
10
{
11
    private $resolver;
12
13
    public function __construct()
14
    {
15
        $this->resolver = new ControllerResolver();
16
    }
17
18
    public function handle(AMQPMessage $message)
19
    {
20
21
22
        //$controller = $this->getResolver()->getController($message);
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
23
        //$arguments = $this->getResolver()->getArguments($message, $controller);
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
24
        $controller = '';
25
        $arguments = [];
26
        $response = call_user_func_array($controller, $arguments);
27
28
        if (!is_string($response) || is_null($response)) {
29
            throw new InvalidBodyAMQPMessageException('Invalid Body: Content should be string and not null.');
30
        }
31
        $amqpResponse = new AMQPMessage(
32
            $response,
33
            ['correlation_id' => $message->get('correlation_id')]
34
        );
35
36
        return $amqpResponse;
37
    }
38
39
    /**
40
     * @return ControllerResolverInterface
41
     */
42
    public function getResolver()
43
    {
44
        return $this->resolver;
45
    }
46
}