This repository was archived by the owner on Oct 30, 2024. It is now read-only.
forked from Workfront/phpnats
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMessage.php
More file actions
170 lines (151 loc) · 2.62 KB
/
Copy pathMessage.php
File metadata and controls
170 lines (151 loc) · 2.62 KB
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
<?php
namespace Nats;
/**
* Message Class.
*
* @package Nats
*/
class Message
{
/**
* Message Subject.
*
* @var string
*/
private $subject;
/**
* Message Body.
*
* @var string
*/
public $body;
/**
* Message Ssid.
*
* @var string
*/
private $sid;
/**
* Message related connection.
*
* @var Connection
*/
private $conn;
/**
* Message constructor.
*
* @param string $subject Message subject.
* @param string $body Message body.
* @param string $sid Message Sid.
* @param Connection $conn Message Connection.
*/
public function __construct($subject, $body, $sid, Connection $conn)
{
$this->setSubject($subject);
$this->setBody($body);
$this->setSid($sid);
$this->setConn($conn);
}
/**
* Set subject.
*
* @param string $subject Subject.
* @return $this
*/
public function setSubject($subject)
{
$this->subject = $subject;
return $this;
}
/**
* Get subject.
*
* @return string
*/
public function getSubject()
{
return $this->subject;
}
/**
* Set body.
*
* @param string $body Body.
* @return $this
*/
public function setBody($body)
{
$this->body = $body;
return $this;
}
/**
* Get body.
*
* @return string
*/
public function getBody()
{
return $this->body;
}
/**
* Set Ssid.
*
* @param string $sid Ssid.
* @return $this
*/
public function setSid($sid)
{
$this->sid = $sid;
return $this;
}
/**
* Get Ssid.
*
* @return string
*/
public function getSid()
{
return $this->sid;
}
/**
* String representation of a message.
*
* @return string
*/
public function __toString()
{
return $this->getBody();
}
/**
* Set Conn.
*
* @param Connection $conn Connection.
* @return $this
*/
public function setConn(Connection $conn)
{
$this->conn = $conn;
return $this;
}
/**
* Get Conn.
*
* @return Connection
*/
public function getConn()
{
return $this->conn;
}
/**
* Allows you reply the message with a specific body.
*
* @param string $body Body to be set.
* @return void
*/
public function reply($body)
{
$this->conn->publish(
$this->subject,
$body
);
}
}