Consumer   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 36
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 9

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 22 22 2

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 Cmp\Queues\Infrastructure\AmqpLib\v26\RabbitMQ\Task;
4
5
use Cmp\Queues\Domain\Queue\JSONMessageFactory;
6
use Cmp\Queues\Domain\Task\Consumer as DomainConsumer;
7
use Cmp\Queues\Domain\Task\JSONTaskFactory;
8
use Cmp\Queues\Infrastructure\AmqpLib\v26\RabbitMQ\Queue\Config\BindConfig;
9
use Cmp\Queues\Infrastructure\AmqpLib\v26\RabbitMQ\Queue\Config\ConsumeConfig;
10
use Cmp\Queues\Infrastructure\AmqpLib\v26\RabbitMQ\Queue\Config\ExchangeConfig;
11
use Cmp\Queues\Infrastructure\AmqpLib\v26\RabbitMQ\Queue\Config\QueueConfig;
12
use Cmp\Queues\Infrastructure\AmqpLib\v26\RabbitMQ\Queue\MessageHandler;
13
use Cmp\Queues\Infrastructure\AmqpLib\v26\RabbitMQ\Queue\QueueReader;
14
use PhpAmqpLib\Connection\AMQPLazyConnection;
15
use Psr\Log\LoggerInterface;
16
17 View Code Duplication
class Consumer extends DomainConsumer
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...
18
{
19
    /**
20
     * @param string             $host
21
     * @param int                $port
22
     * @param string             $user
23
     * @param string             $password
24
     * @param string             $vHost
25
     * @param string             $exchangeName
26
     * @param string             $queueName
27
     * @param LoggerInterface    $logger
28
     * @param JSONMessageFactory $factory
29
     */
30
    public function __construct(
31
        $host,
32
        $port,
33
        $user,
34
        $password,
35
        $vHost,
36
        $exchangeName,
37
        $queueName,
38
        LoggerInterface $logger,
39
        JSONMessageFactory $factory = null
40
    ) {
41
        $queueReader = new QueueReader(
42
            new AMQPLazyConnection($host, $port, $user, $password, $vHost),
43
            new QueueConfig($queueName, false, true, false, false),
44
            new ExchangeConfig($exchangeName, 'fanout', false, true, false),
45
            new BindConfig(),
46
            new ConsumeConfig(false, false, false, false),
47
            new MessageHandler($factory ?: new JSONTaskFactory()),
48
            $logger
49
        );
50
        parent::__construct($queueReader);
51
    }
52
}
53