Subscriber   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 38
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 8

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 8
dl 38
loc 38
rs 10
c 0
b 0
f 0

1 Method

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