-
Notifications
You must be signed in to change notification settings - Fork 439
/
Copy pathPreSend.php
79 lines (61 loc) · 1.55 KB
/
PreSend.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php
namespace Enqueue\Client;
final class PreSend
{
private $message;
private $originalMessage;
private $commandOrTopic;
private $producer;
private $driver;
public function __construct(
string $commandOrTopic,
Message $message,
ProducerInterface $producer,
DriverInterface $driver,
) {
$this->message = $message;
$this->commandOrTopic = $commandOrTopic;
$this->producer = $producer;
$this->driver = $driver;
$this->originalMessage = clone $message;
}
public function getCommand(): string
{
return $this->commandOrTopic;
}
public function getTopic(): string
{
return $this->commandOrTopic;
}
public function changeCommand(string $newCommand): void
{
$this->commandOrTopic = $newCommand;
}
public function changeTopic(string $newTopic): void
{
$this->commandOrTopic = $newTopic;
}
public function changeBody($body, ?string $contentType = null): void
{
$this->message->setBody($body);
if (null !== $contentType) {
$this->message->setContentType($contentType);
}
}
public function getMessage(): Message
{
return $this->message;
}
public function getOriginalMessage(): Message
{
return $this->originalMessage;
}
public function getProducer(): ProducerInterface
{
return $this->producer;
}
public function getDriver(): DriverInterface
{
return $this->driver;
}
}