@@ -24,6 +24,11 @@ class GpsMessage implements Message, \JsonSerializable
2424 */
2525 private $ headers ;
2626
27+ /**
28+ * @var array
29+ */
30+ private $ attributes ;
31+
2732 /**
2833 * @var bool
2934 */
@@ -34,11 +39,12 @@ class GpsMessage implements Message, \JsonSerializable
3439 */
3540 private $ nativeMessage ;
3641
37- public function __construct (string $ body = '' , array $ properties = [], array $ headers = [])
42+ public function __construct (string $ body = '' , array $ properties = [], array $ headers = [], array $ attributes = [] )
3843 {
3944 $ this ->body = $ body ;
4045 $ this ->properties = $ properties ;
4146 $ this ->headers = $ headers ;
47+ $ this ->attributes = $ attributes ;
4248
4349 $ this ->redelivered = false ;
4450 }
@@ -103,7 +109,7 @@ public function isRedelivered(): bool
103109 return $ this ->redelivered ;
104110 }
105111
106- public function setCorrelationId (string $ correlationId = null ): void
112+ public function setCorrelationId (? string $ correlationId = null ): void
107113 {
108114 $ this ->setHeader ('correlation_id ' , $ correlationId );
109115 }
@@ -113,7 +119,7 @@ public function getCorrelationId(): ?string
113119 return $ this ->getHeader ('correlation_id ' );
114120 }
115121
116- public function setMessageId (string $ messageId = null ): void
122+ public function setMessageId (? string $ messageId = null ): void
117123 {
118124 $ this ->setHeader ('message_id ' , $ messageId );
119125 }
@@ -130,12 +136,12 @@ public function getTimestamp(): ?int
130136 return null === $ value ? null : (int ) $ value ;
131137 }
132138
133- public function setTimestamp (int $ timestamp = null ): void
139+ public function setTimestamp (? int $ timestamp = null ): void
134140 {
135141 $ this ->setHeader ('timestamp ' , $ timestamp );
136142 }
137143
138- public function setReplyTo (string $ replyTo = null ): void
144+ public function setReplyTo (? string $ replyTo = null ): void
139145 {
140146 $ this ->setHeader ('reply_to ' , $ replyTo );
141147 }
@@ -151,6 +157,7 @@ public function jsonSerialize(): array
151157 'body ' => $ this ->getBody (),
152158 'properties ' => $ this ->getProperties (),
153159 'headers ' => $ this ->getHeaders (),
160+ 'attributes ' => $ this ->getAttributes (),
154161 ];
155162 }
156163
@@ -161,16 +168,26 @@ public static function jsonUnserialize(string $json): self
161168 throw new \InvalidArgumentException (sprintf ('The malformed json given. Error %s and message %s ' , json_last_error (), json_last_error_msg ()));
162169 }
163170
164- return new self ($ data ['body ' ] ?? $ json , $ data ['properties ' ] ?? [], $ data ['headers ' ] ?? []);
171+ return new self ($ data ['body ' ] ?? $ json , $ data ['properties ' ] ?? [], $ data ['headers ' ] ?? [], $ data [ ' attributes ' ] ?? [] );
165172 }
166173
167174 public function getNativeMessage (): ?GoogleMessage
168175 {
169176 return $ this ->nativeMessage ;
170177 }
171178
172- public function setNativeMessage (GoogleMessage $ message = null ): void
179+ public function setNativeMessage (? GoogleMessage $ message = null ): void
173180 {
174181 $ this ->nativeMessage = $ message ;
175182 }
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+ }
176193}
0 commit comments