Consumer   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 1
dl 0
loc 56
ccs 13
cts 13
cp 1
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A cancel() 0 6 1
A tag() 0 4 1
A isActive() 0 4 1
A __toString() 0 4 1
1
<?php
2
3
namespace ButterAMQP\AMQP091;
4
5
use ButterAMQP\ChannelInterface;
6
use ButterAMQP\ConsumerInterface;
7
8
class Consumer implements ConsumerInterface
9
{
10
    /**
11
     * @var ChannelInterface
12
     */
13
    private $channel;
14
15
    /**
16
     * @var string
17
     */
18
    private $tag;
19
20
    /**
21
     * @param ChannelInterface $channel
22
     * @param string           $tag
23
     */
24 15
    public function __construct(ChannelInterface $channel, $tag)
25
    {
26 15
        $this->channel = $channel;
27 15
        $this->tag = $tag;
28 15
    }
29
30
    /**
31
     * {@inheritdoc}
32
     */
33 1
    public function cancel()
34
    {
35 1
        $this->channel->cancel($this->tag);
36
37 1
        return $this;
38
    }
39
40
    /**
41
     * {@inheritdoc}
42
     */
43 4
    public function tag()
44
    {
45 4
        return $this->tag;
46
    }
47
48
    /**
49
     * {@inheritdoc}
50
     */
51 6
    public function isActive()
52
    {
53 6
        return $this->channel->hasConsumer($this->tag);
54
    }
55
56
    /**
57
     * @return string
58
     */
59 2
    public function __toString()
60
    {
61 2
        return $this->tag;
62
    }
63
}
64