Code Duplication    Length = 22-22 lines in 2 locations

Connection/CmobiAMQPConnection.php 1 location

@@ 7-28 (lines=22) @@
4
5
use PhpAmqpLib\Connection\AMQPStreamConnection;
6
7
class CmobiAMQPConnection extends AMQPStreamConnection implements CmobiAMQPConnectionInterface
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

Connection/CmobiAMQPLazyConnection.php 1 location

@@ 7-28 (lines=22) @@
4
5
use PhpAmqpLib\Connection\AMQPLazyConnection;
6
7
class CmobiAMQPLazyConnection extends AMQPLazyConnection implements CmobiAMQPConnectionInterface
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