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

Subscriber::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 23
Code Lines 19

Duplication

Lines 23
Ratio 100 %

Importance

Changes 0
Metric Value
dl 23
loc 23
rs 9.0856
c 0
b 0
f 0
cc 1
eloc 19
nc 1
nop 9

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:59
7
 */
8
9
namespace Cmp\Queues\Infrastructure\AmqpLib\v26\RabbitMQ\DomainEvent;
10
11
use Cmp\Queues\Domain\Event\JSONDomainEventFactory;
12
use Cmp\Queues\Domain\Event\Subscriber as DomainSubscriber;
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 Subscriber extends DomainSubscriber
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
     * Subscriber 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 BindConfig $bindConfig
34
     * @param LoggerInterface $logger
35
     */
36
    public function __construct(
37
        $host,
38
        $port,
39
        $user,
40
        $password,
41
        $vHost,
42
        $exchangeName,
43
        $queueName,
44
        BindConfig $bindConfig,
45
        LoggerInterface $logger
46
    )
47
    {
48
        $queueReader = new QueueReader(
49
            new AMQPLazyConnection($host, $port, $user, $password, $vHost),
50
            new QueueConfig($queueName, false, true, false, false),
51
            new ExchangeConfig($exchangeName, 'topic', false, true, false),
52
            $bindConfig,
53
            new ConsumeConfig(false, false, false, false),
54
            new MessageHandler(new JSONDomainEventFactory()),
55
            $logger
56
        );
57
        parent::__construct($queueReader, $logger);
58
    }
59
}