Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
messagetrait.php
1<?php
2
4
9{
13 private $body = null;
14
18 private array $properties = [];
19
23 private bool $redelivered = false;
24
28 private array $headers = [];
29
30 public function getBody()
31 {
32 return $this->body;
33 }
34
35 public function setBody($body): self
36 {
37 $this->body = $body;
38
39 return $this;
40 }
41
42 public function setProperties(array $properties): self
43 {
44 $this->properties = $properties;
45
46 return $this;
47 }
48
49 public function setProperty(string $name, $value): self
50 {
51 if(null === $value)
52 {
53 unset($this->properties[$name]);
54 }
55 else
56 {
57 $this->properties[$name] = $value;
58 }
59
60 return $this;
61 }
62
63 public function getProperties(): array
64 {
65 return $this->properties;
66 }
67
68 public function getProperty(string $name, $default = null)
69 {
70 return array_key_exists($name, $this->properties) ? $this->properties[$name] : $default;
71 }
72
73 public function setHeader(string $name, $value): self
74 {
75 if(null === $value)
76 {
77 unset($this->headers[$name]);
78 }
79 else
80 {
81 $this->headers[$name] = $value;
82 }
83
84 return $this;
85 }
86
87 public function setHeaders(array $headers): self
88 {
89 $this->headers = $headers;
90
91 return $this;
92 }
93
94 public function getHeaders(): array
95 {
96 return $this->headers;
97 }
98
99 public function getHeader(string $name, $default = null)
100 {
101 return array_key_exists($name, $this->headers) ? $this->headers[$name] : $default;
102 }
103
104 public function setRedelivered(bool $redelivered): self
105 {
106 $this->redelivered = $redelivered;
107
108 return $this;
109 }
110
111 public function isRedelivered(): bool
112 {
113 return $this->redelivered;
114 }
115
116 public function setCorrelationId(string $correlationId = null): self
117 {
118 $this->setHeader('correlation_id', $correlationId);
119
120 return $this;
121 }
122
123 public function getCorrelationId(): ?string
124 {
125 return $this->getHeader('correlation_id');
126 }
127
128 public function setMessageId(string $messageId = null): self
129 {
130 $this->setHeader('message_id', $messageId);
131
132 return $this;
133 }
134
135 public function getMessageId(): ?string
136 {
137 return $this->getHeader('message_id');
138 }
139
140 public function getTimestamp(): ?int
141 {
142 $value = $this->getHeader('timestamp');
143
144 return null === $value ? null : (int) $value;
145 }
146
147 public function setTimestamp(int $timestamp = null): self
148 {
149 $this->setHeader('timestamp', $timestamp);
150
151 return $this;
152 }
153
154 public function setReplyTo(string $replyTo = null): self
155 {
156 $this->setHeader('reply_to', $replyTo);
157
158 return $this;
159 }
160
161 public function getReplyTo(): ?string
162 {
163 return $this->getHeader('reply_to');
164 }
165}
setHeader(string $name, $value)
setReplyTo(string $replyTo=null)
setProperties(array $properties)
getHeader(string $name, $default=null)
setTimestamp(int $timestamp=null)
getProperty(string $name, $default=null)
setMessageId(string $messageId=null)
setProperty(string $name, $value)
setRedelivered(bool $redelivered)
setCorrelationId(string $correlationId=null)