CmobiAMQPLazyConnection::channel()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 7

Duplication

Lines 12
Ratio 100 %

Importance

Changes 0
Metric Value
dl 12
loc 12
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 7
nc 3
nop 1
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