1
|
|
|
<?php |
2
|
|
|
declare(strict_types = 1); |
3
|
|
|
|
4
|
|
|
namespace Innmind\AMQP\Model\Basic; |
5
|
|
|
|
6
|
|
|
use Innmind\Immutable\{ |
7
|
|
|
MapInterface, |
8
|
|
|
Map |
9
|
|
|
}; |
10
|
|
|
|
11
|
|
|
final class Consume |
12
|
|
|
{ |
13
|
|
|
private $queue; |
14
|
|
|
private $consumerTag; |
15
|
|
|
private $local = true; |
16
|
|
|
private $ack = true; |
17
|
|
|
private $exclusive = false; |
18
|
|
|
private $wait = true; |
19
|
|
|
private $arguments; |
20
|
|
|
|
21
|
7 |
|
public function __construct(string $queue) |
22
|
|
|
{ |
23
|
7 |
|
$this->queue = $queue; |
24
|
7 |
|
$this->arguments = new Map('string', 'mixed'); |
25
|
7 |
|
} |
26
|
|
|
|
27
|
2 |
|
public function withConsumerTag(string $tag): self |
28
|
|
|
{ |
29
|
2 |
|
$self = clone $this; |
30
|
2 |
|
$self->consumerTag = $tag; |
31
|
|
|
|
32
|
2 |
|
return $self; |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Let the server define the consumer tag |
37
|
|
|
*/ |
38
|
1 |
|
public function withAutoGeneratedConsumerTag(): self |
39
|
|
|
{ |
40
|
1 |
|
$self = clone $this; |
41
|
1 |
|
$self->consumerTag = null; |
42
|
|
|
|
43
|
1 |
|
return $self; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* Means the server will not deliver messages to the consumer |
48
|
|
|
*/ |
49
|
2 |
|
public function noLocal(): self |
50
|
|
|
{ |
51
|
2 |
|
$self = clone $this; |
52
|
2 |
|
$self->local = false; |
53
|
|
|
|
54
|
2 |
|
return $self; |
55
|
|
|
} |
56
|
|
|
|
57
|
1 |
|
public function local(): self |
58
|
|
|
{ |
59
|
1 |
|
$self = clone $this; |
60
|
1 |
|
$self->local = true; |
61
|
|
|
|
62
|
1 |
|
return $self; |
63
|
|
|
} |
64
|
|
|
|
65
|
1 |
|
public function manualAcknowledge(): self |
66
|
|
|
{ |
67
|
1 |
|
$self = clone $this; |
68
|
1 |
|
$self->ack = true; |
69
|
|
|
|
70
|
1 |
|
return $self; |
71
|
|
|
} |
72
|
|
|
|
73
|
2 |
|
public function autoAcknowledge(): self |
74
|
|
|
{ |
75
|
2 |
|
$self = clone $this; |
76
|
2 |
|
$self->ack = false; |
77
|
|
|
|
78
|
2 |
|
return $self; |
79
|
|
|
} |
80
|
|
|
|
81
|
2 |
|
public function exclusive(): self |
82
|
|
|
{ |
83
|
2 |
|
$self = clone $this; |
84
|
2 |
|
$self->exclusive = true; |
85
|
|
|
|
86
|
2 |
|
return $self; |
87
|
|
|
} |
88
|
|
|
|
89
|
1 |
|
public function notExclusive(): self |
90
|
|
|
{ |
91
|
1 |
|
$self = clone $this; |
92
|
1 |
|
$self->exclusive = false; |
93
|
|
|
|
94
|
1 |
|
return $self; |
95
|
|
|
} |
96
|
|
|
|
97
|
2 |
|
public function dontWait(): self |
98
|
|
|
{ |
99
|
2 |
|
$self = clone $this; |
100
|
2 |
|
$self->wait = false; |
101
|
|
|
|
102
|
2 |
|
return $self; |
103
|
|
|
} |
104
|
|
|
|
105
|
1 |
|
public function wait(): self |
106
|
|
|
{ |
107
|
1 |
|
$self = clone $this; |
108
|
1 |
|
$self->wait = true; |
109
|
|
|
|
110
|
1 |
|
return $self; |
111
|
|
|
} |
112
|
|
|
|
113
|
1 |
|
public function withArgument(string $key, $value): self |
114
|
|
|
{ |
115
|
1 |
|
$self = clone $this; |
116
|
1 |
|
$self->arguments = $self->arguments->put($key, $value); |
117
|
|
|
|
118
|
1 |
|
return $self; |
119
|
|
|
} |
120
|
|
|
|
121
|
2 |
|
public function queue(): string |
122
|
|
|
{ |
123
|
2 |
|
return $this->queue; |
124
|
|
|
} |
125
|
|
|
|
126
|
3 |
|
public function shouldAutoGenerateConsumerTag(): bool |
127
|
|
|
{ |
128
|
3 |
|
return !is_string($this->consumerTag); |
129
|
|
|
} |
130
|
|
|
|
131
|
1 |
|
public function consumerTag(): string |
132
|
|
|
{ |
133
|
1 |
|
return $this->consumerTag; |
134
|
|
|
} |
135
|
|
|
|
136
|
3 |
|
public function isLocal(): bool |
137
|
|
|
{ |
138
|
3 |
|
return $this->local; |
139
|
|
|
} |
140
|
|
|
|
141
|
3 |
|
public function shouldAutoAcknowledge(): bool |
142
|
|
|
{ |
143
|
3 |
|
return !$this->ack; |
144
|
|
|
} |
145
|
|
|
|
146
|
3 |
|
public function isExclusive(): bool |
147
|
|
|
{ |
148
|
3 |
|
return $this->exclusive; |
149
|
|
|
} |
150
|
|
|
|
151
|
3 |
|
public function shouldWait(): bool |
152
|
|
|
{ |
153
|
3 |
|
return $this->wait; |
154
|
|
|
} |
155
|
|
|
|
156
|
|
|
/** |
157
|
|
|
* @return MapInterface<string, mixed> |
|
|
|
|
158
|
|
|
*/ |
159
|
2 |
|
public function arguments(): MapInterface |
160
|
|
|
{ |
161
|
2 |
|
return $this->arguments; |
162
|
|
|
} |
163
|
|
|
} |
164
|
|
|
|
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.