Completed
Push — master ( 5fca0d...2a987b )
by Quim
02:16
created

Consumer::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 22
Code Lines 18

Duplication

Lines 22
Ratio 100 %

Importance

Changes 0
Metric Value
dl 22
loc 22
rs 9.2
c 0
b 0
f 0
cc 1
eloc 18
nc 1
nop 8

How to fix   Many Parameters   

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

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