CmobiAMQPLazyConnection   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 95.65 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 22
loc 23
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A channel() 12 12 3

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 Cmobi\RabbitmqBundle\Connection;
4
5
use PhpAmqpLib\Connection\AMQPLazyConnection;
6
7 View Code Duplication
class CmobiAMQPLazyConnection extends AMQPLazyConnection implements CmobiAMQPConnectionInterface
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...
8
{
9
    /**
10
     * Fetches a channel object identified by the numeric channel_id, or
11
     * create that object if it doesn't already exist.
12
     *
13
     * @param string $channel_id
14
     *
15
     * @return CmobiAMQPChannel
16
     */
17
    public function channel($channel_id = null)
18
    {
19
        if (isset($this->channels[$channel_id])) {
20
            return $this->channels[$channel_id];
21
        }
22
23
        $channel_id = $channel_id ? $channel_id : $this->get_free_channel_id();
24
        $ch = new CmobiAMQPChannel($this->connection, $channel_id);
25
        $this->channels[$channel_id] = $ch;
26
27
        return $ch;
28
    }
29
}
30