Consumer::tag()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 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