@@ -24,6 +24,11 @@ class GpsMessage implements Message, \JsonSerializable
24
24
*/
25
25
private $ headers ;
26
26
27
+ /**
28
+ * @var array
29
+ */
30
+ private $ attributes ;
31
+
27
32
/**
28
33
* @var bool
29
34
*/
@@ -34,11 +39,12 @@ class GpsMessage implements Message, \JsonSerializable
34
39
*/
35
40
private $ nativeMessage ;
36
41
37
- public function __construct (string $ body = '' , array $ properties = [], array $ headers = [])
42
+ public function __construct (string $ body = '' , array $ properties = [], array $ headers = [], array $ attributes = [] )
38
43
{
39
44
$ this ->body = $ body ;
40
45
$ this ->properties = $ properties ;
41
46
$ this ->headers = $ headers ;
47
+ $ this ->attributes = $ attributes ;
42
48
43
49
$ this ->redelivered = false ;
44
50
}
@@ -103,7 +109,7 @@ public function isRedelivered(): bool
103
109
return $ this ->redelivered ;
104
110
}
105
111
106
- public function setCorrelationId (string $ correlationId = null ): void
112
+ public function setCorrelationId (? string $ correlationId = null ): void
107
113
{
108
114
$ this ->setHeader ('correlation_id ' , $ correlationId );
109
115
}
@@ -113,7 +119,7 @@ public function getCorrelationId(): ?string
113
119
return $ this ->getHeader ('correlation_id ' );
114
120
}
115
121
116
- public function setMessageId (string $ messageId = null ): void
122
+ public function setMessageId (? string $ messageId = null ): void
117
123
{
118
124
$ this ->setHeader ('message_id ' , $ messageId );
119
125
}
@@ -130,12 +136,12 @@ public function getTimestamp(): ?int
130
136
return null === $ value ? null : (int ) $ value ;
131
137
}
132
138
133
- public function setTimestamp (int $ timestamp = null ): void
139
+ public function setTimestamp (? int $ timestamp = null ): void
134
140
{
135
141
$ this ->setHeader ('timestamp ' , $ timestamp );
136
142
}
137
143
138
- public function setReplyTo (string $ replyTo = null ): void
144
+ public function setReplyTo (? string $ replyTo = null ): void
139
145
{
140
146
$ this ->setHeader ('reply_to ' , $ replyTo );
141
147
}
@@ -151,6 +157,7 @@ public function jsonSerialize(): array
151
157
'body ' => $ this ->getBody (),
152
158
'properties ' => $ this ->getProperties (),
153
159
'headers ' => $ this ->getHeaders (),
160
+ 'attributes ' => $ this ->getAttributes (),
154
161
];
155
162
}
156
163
@@ -161,16 +168,26 @@ public static function jsonUnserialize(string $json): self
161
168
throw new \InvalidArgumentException (sprintf ('The malformed json given. Error %s and message %s ' , json_last_error (), json_last_error_msg ()));
162
169
}
163
170
164
- return new self ($ data ['body ' ] ?? $ json , $ data ['properties ' ] ?? [], $ data ['headers ' ] ?? []);
171
+ return new self ($ data ['body ' ] ?? $ json , $ data ['properties ' ] ?? [], $ data ['headers ' ] ?? [], $ data [ ' attributes ' ] ?? [] );
165
172
}
166
173
167
174
public function getNativeMessage (): ?GoogleMessage
168
175
{
169
176
return $ this ->nativeMessage ;
170
177
}
171
178
172
- public function setNativeMessage (GoogleMessage $ message = null ): void
179
+ public function setNativeMessage (? GoogleMessage $ message = null ): void
173
180
{
174
181
$ this ->nativeMessage = $ message ;
175
182
}
183
+
184
+ public function setAttributes (array $ attributes ): void
185
+ {
186
+ $ this ->attributes = $ attributes ;
187
+ }
188
+
189
+ public function getAttributes (): array
190
+ {
191
+ return $ this ->attributes ;
192
+ }
176
193
}
0 commit comments