Channel::commitTransaction()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 10

Duplication

Lines 10
Ratio 100 %

Code Coverage

Tests 4
CRAP Score 3.3332

Importance

Changes 0
Metric Value
dl 10
loc 10
ccs 4
cts 6
cp 0.6667
rs 9.9332
c 0
b 0
f 0
cc 3
nc 3
nop 0
crap 3.3332
1
<?php
2
3
namespace TreeHouse\Queue\Amqp\Driver\Amqp;
4
5
use TreeHouse\Queue\Amqp\ChannelInterface;
6
use TreeHouse\Queue\Amqp\ConnectionInterface;
7
use TreeHouse\Queue\Exception\ChannelException;
8
use TreeHouse\Queue\Exception\ConnectionException;
9
10
class Channel implements ChannelInterface
11
{
12
    /**
13
     * @var \AMQPChannel
14
     */
15
    protected $delegate;
16
17
    /**
18
     * @var ConnectionInterface
19
     */
20
    protected $connection;
21
22
    /**
23
     * @param \AMQPChannel        $delegate
24
     * @param ConnectionInterface $connection
25
     */
26 27
    public function __construct(\AMQPChannel $delegate, ConnectionInterface &$connection)
27
    {
28 27
        $this->delegate = $delegate;
29 27
        $this->connection = &$connection;
30 27
    }
31
32
    /**
33
     * @inheritdoc
34
     */
35 3
    public function getConnection()
36
    {
37 3
        return $this->connection;
38
    }
39
40
    /**
41
     * @inheritdoc
42
     */
43 1
    public function getChannelId()
44
    {
45 1
        return $this->delegate->getChannelId();
46
    }
47
48
    /**
49
     * @inheritdoc
50
     */
51 2 View Code Duplication
    public function basicQos($prefetchSize, $prefetchCount)
0 ignored issues
show
Duplication introduced by
This method 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...
52
    {
53
        try {
54 2
            return $this->delegate->qos($prefetchSize, $prefetchCount);
55 1
        } catch (\AMQPChannelException $e) {
56
            throw new ChannelException($e->getMessage(), $e->getCode(), $e);
57 1
        } catch (\AMQPConnectionException $e) {
58 1
            throw new ConnectionException($e->getMessage(), $e->getCode(), $e);
59
        }
60
    }
61
62
    /**
63
     * @inheritdoc
64
     */
65 3 View Code Duplication
    public function startTransaction()
0 ignored issues
show
Duplication introduced by
This method 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...
66
    {
67
        try {
68 3
            return $this->delegate->startTransaction();
69 1
        } catch (\AMQPChannelException $e) {
70 1
            throw new ChannelException($e->getMessage(), $e->getCode(), $e);
71
        } catch (\AMQPConnectionException $e) {
72
            throw new ConnectionException($e->getMessage(), $e->getCode(), $e);
73
        }
74
    }
75
76
    /**
77
     * @inheritdoc
78
     */
79 3 View Code Duplication
    public function commitTransaction()
0 ignored issues
show
Duplication introduced by
This method 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...
80
    {
81
        try {
82 3
            return $this->delegate->commitTransaction();
83 2
        } catch (\AMQPChannelException $e) {
84 2
            throw new ChannelException($e->getMessage(), $e->getCode(), $e);
85
        } catch (\AMQPConnectionException $e) {
86
            throw new ConnectionException($e->getMessage(), $e->getCode(), $e);
87
        }
88
    }
89
90
    /**
91
     * @inheritdoc
92
     */
93 2 View Code Duplication
    public function rollbackTransaction()
0 ignored issues
show
Duplication introduced by
This method 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...
94
    {
95
        try {
96 2
            return $this->delegate->rollbackTransaction();
97 2
        } catch (\AMQPChannelException $e) {
98 2
            throw new ChannelException($e->getMessage(), $e->getCode(), $e);
99
        } catch (\AMQPConnectionException $e) {
100
            throw new ConnectionException($e->getMessage(), $e->getCode(), $e);
101
        }
102
    }
103
104
    /**
105
     * @inheritdoc
106
     *
107
     * @return \AMQPChannel
108
     */
109 14
    public function getDelegate()
110
    {
111 14
        return $this->delegate;
112
    }
113
}
114