PluginProbe ʕ •ᴥ•ʔ
10Web Booster – Website speed optimization, Cache & Page Speed optimizer / trunk
10Web Booster – Website speed optimization, Cache & Page Speed optimizer vtrunk
2.33.0 2.30.5 2.30.7 2.30.9 2.31.10 2.31.8 2.32.11 2.32.21 2.32.3 2.32.4 2.32.7 2.6.31 2.6.40 2.6.42 2.6.7 2.7.37 2.7.44 2.7.47 2.8.18 2.8.19 2.8.32 2.8.34 2.8.35 2.9.23 2.9.24 2.9.25 2.9.27 v2.27.4 trunk 2.0.10 2.0.11 2.0.12 2.0.13 2.0.14 2.0.15 2.0.17 2.0.18 2.0.21 2.0.22 2.0.25 2.0.26 2.0.27 2.0.3 2.0.7 2.0.9 2.10.46 2.10.65 2.10.66 2.10.68 2.11.41 2.11.42 2.11.43 2.12.15 2.12.21 2.12.22 2.12.23 2.12.26 2.13.37 2.13.40 2.13.41 2.13.42 2.13.44 2.13.45 2.13.47 2.14.49 2.14.50 2.15.18 2.17.21 2.17.23 2.18.17 2.19.44 2.19.45 2.19.46 2.19.49 2.2.12 2.2.15 2.2.16 2.2.18 2.2.8 2.20.31 2.20.32 2.20.33 2.21.11 2.21.12 2.21.16 2.21.25 2.22.32 2.23.13 2.23.15 2.23.16 2.23.18 2.24.12 2.24.14 2.24.18 2.25.14 2.26.6 2.28.10 2.28.13 2.28.14 2.28.7 2.29.1 2.29.2 2.29.3 2.3.0 2.3.1 2.3.2 2.3.3 2.30.18
tenweb-speed-optimizer / vendor / enqueue / fs / FsMessage.php
tenweb-speed-optimizer / vendor / enqueue / fs Last commit date
.github 2 years ago CannotObtainLockException.php 4 years ago FsConnectionFactory.php 4 years ago FsConsumer.php 4 years ago FsContext.php 4 years ago FsDestination.php 4 years ago FsMessage.php 4 years ago FsProducer.php 4 years ago LICENSE 4 years ago LegacyFilesystemLock.php 4 years ago Lock.php 4 years ago README.md 2 years ago composer.json 2 years ago
FsMessage.php
164 lines
1 <?php
2
3 declare(strict_types=1);
4
5 namespace Enqueue\Fs;
6
7 use Interop\Queue\Message;
8
9 class FsMessage implements Message, \JsonSerializable
10 {
11 /**
12 * @var string
13 */
14 private $body;
15
16 /**
17 * @var array
18 */
19 private $properties;
20
21 /**
22 * @var array
23 */
24 private $headers;
25
26 /**
27 * @var bool
28 */
29 private $redelivered;
30
31 public function __construct(string $body = '', array $properties = [], array $headers = [])
32 {
33 $this->body = $body;
34 $this->properties = $properties;
35 $this->headers = $headers;
36 $this->redelivered = false;
37 }
38
39 public function setBody(string $body): void
40 {
41 $this->body = $body;
42 }
43
44 public function getBody(): string
45 {
46 return $this->body;
47 }
48
49 public function setProperties(array $properties): void
50 {
51 $this->properties = $properties;
52 }
53
54 public function getProperties(): array
55 {
56 return $this->properties;
57 }
58
59 public function setProperty(string $name, $value): void
60 {
61 $this->properties[$name] = $value;
62 }
63
64 public function getProperty(string $name, $default = null)
65 {
66 return array_key_exists($name, $this->properties) ? $this->properties[$name] : $default;
67 }
68
69 public function setHeaders(array $headers): void
70 {
71 $this->headers = $headers;
72 }
73
74 public function getHeaders(): array
75 {
76 return $this->headers;
77 }
78
79 public function setHeader(string $name, $value): void
80 {
81 $this->headers[$name] = $value;
82 }
83
84 public function getHeader(string $name, $default = null)
85 {
86 return array_key_exists($name, $this->headers) ? $this->headers[$name] : $default;
87 }
88
89 public function isRedelivered(): bool
90 {
91 return $this->redelivered;
92 }
93
94 public function setRedelivered(bool $redelivered): void
95 {
96 $this->redelivered = $redelivered;
97 }
98
99 public function setCorrelationId(string $correlationId = null): void
100 {
101 $this->setHeader('correlation_id', (string) $correlationId);
102 }
103
104 public function getCorrelationId(): ?string
105 {
106 return $this->getHeader('correlation_id');
107 }
108
109 public function setMessageId(string $messageId = null): void
110 {
111 $this->setHeader('message_id', (string) $messageId);
112 }
113
114 public function getMessageId(): ?string
115 {
116 return $this->getHeader('message_id');
117 }
118
119 public function getTimestamp(): ?int
120 {
121 $value = $this->getHeader('timestamp');
122
123 return null === $value ? null : (int) $value;
124 }
125
126 public function setTimestamp(int $timestamp = null): void
127 {
128 $this->setHeader('timestamp', $timestamp);
129 }
130
131 public function setReplyTo(string $replyTo = null): void
132 {
133 $this->setHeader('reply_to', $replyTo);
134 }
135
136 public function getReplyTo(): ?string
137 {
138 return $this->getHeader('reply_to');
139 }
140
141 public function jsonSerialize(): array
142 {
143 return [
144 'body' => $this->getBody(),
145 'properties' => $this->getProperties(),
146 'headers' => $this->getHeaders(),
147 ];
148 }
149
150 public static function jsonUnserialize(string $json): self
151 {
152 $data = json_decode($json, true);
153 if (JSON_ERROR_NONE !== json_last_error()) {
154 throw new \InvalidArgumentException(sprintf(
155 'The malformed json given. Error %s and message %s',
156 json_last_error(),
157 json_last_error_msg()
158 ));
159 }
160
161 return new self($data['body'], $data['properties'], $data['headers']);
162 }
163 }
164