Completed
Push — master ( e17409...9d6c1e )
by Sergey
04:06
created

Consumer::__toString()   A

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
    const FLAG_NO_WAIT = 0b0000000001;
11
    const FLAG_EXCLUSIVE = 0b0000001000;
12
    const FLAG_NO_LOCAL = 0b0100000000;
13
    const FLAG_NO_ACK = 0b1000000000;
14
15
    /**
16
     * @var ChannelInterface
17
     */
18
    private $channel;
19
20
    /**
21
     * @var string
22
     */
23
    private $tag;
24
25
    /**
26
     * @param ChannelInterface $channel
27
     * @param string           $tag
28
     */
29 15
    public function __construct(ChannelInterface $channel, $tag)
30
    {
31 15
        $this->channel = $channel;
32 15
        $this->tag = $tag;
33 15
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38 1
    public function cancel()
39
    {
40 1
        $this->channel->cancel($this->tag);
41
42 1
        return $this;
43
    }
44
45
    /**
46
     * {@inheritdoc}
47
     */
48 4
    public function tag()
49
    {
50 4
        return $this->tag;
51
    }
52
53
    /**
54
     * {@inheritdoc}
55
     */
56 6
    public function isActive()
57
    {
58 6
        return $this->channel->hasConsumer($this->tag);
59
    }
60
61
    /**
62
     * @return string
63
     */
64 2
    public function __toString()
65
    {
66 2
        return $this->tag;
67
    }
68
}
69