Skip to content

Commit f3f9273

Browse files
committed
Code review fixes.
1 parent 73f182b commit f3f9273

File tree

3 files changed

+13
-18
lines changed

3 files changed

+13
-18
lines changed

pkg/stomp/StompConnectionFactory.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public function createContext(): Context
7676
{
7777
if ($this->config['lazy']) {
7878
return new StompContext(
79-
fn () => $this->establishConnection(),
79+
function () { return $this->establishConnection(); },
8080
$this->config['target']
8181
);
8282
}
@@ -128,7 +128,7 @@ private function parseDsn(string $dsn): array
128128
$schemeExtension = ExtensionType::RABBITMQ;
129129
}
130130

131-
if (false === in_array($schemeExtension, self::SUPPORTED_SCHEMES)) {
131+
if (false === in_array($schemeExtension, self::SUPPORTED_SCHEMES, true)) {
132132
throw new \LogicException(sprintf('The given DSN is not supported. The scheme extension "%s" provided is not supported. It must be one of %s.', $schemeExtension, implode(', ', self::SUPPORTED_SCHEMES)));
133133
}
134134

pkg/stomp/StompConsumer.php

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace Enqueue\Stomp;
66

77
use Interop\Queue\Consumer;
8+
use Interop\Queue\Exception\Exception;
89
use Interop\Queue\Exception\InvalidMessageException;
910
use Interop\Queue\Message;
1011
use Interop\Queue\Queue;
@@ -104,15 +105,13 @@ public function receive(int $timeout = 0): ?Message
104105
return $this->convertMessage($message);
105106
}
106107
}
107-
}
108-
else {
108+
} else {
109109
if ($message = $this->stomp->readMessageFrame($this->subscriptionId, $timeout)) {
110110
return $this->convertMessage($message);
111111
}
112112
}
113-
}
114-
catch (ErrorFrameException $e) {
115-
throw new \Exception($e->getMessage() . "\n" . $e->getFrame()->getBody());
113+
} catch (ErrorFrameException $e) {
114+
throw new Exception($e->getMessage()."\n".$e->getFrame()->getBody(), null, $e);
116115
}
117116

118117
return null;
@@ -150,7 +149,7 @@ public function reject(Message $message, bool $requeue = false): void
150149

151150
$nackFrame = $this->stomp->getProtocol()->getNackFrame($message->getFrame());
152151

153-
if ($this->queue->getExtensionType() === ExtensionType::RABBITMQ) {
152+
if (ExtensionType::RABBITMQ === $this->queue->getExtensionType()) {
154153
$nackFrame->addHeaders([
155154
'requeue' => $requeue ? 'true' : 'false',
156155
]);
@@ -178,19 +177,15 @@ private function subscribe(): void
178177

179178
$headers = $this->queue->getHeaders();
180179

181-
if ($this->queue->getExtensionType() === ExtensionType::RABBITMQ) {
182-
180+
if (ExtensionType::RABBITMQ === $this->queue->getExtensionType()) {
183181
$headers['prefetch-count'] = $this->prefetchCount;
184182
$headers = StompHeadersEncoder::encode($headers);
185183

186184
foreach ($headers as $key => $value) {
187185
$frame[$key] = $value;
188186
}
189-
}
190-
191-
if ($this->queue->getExtensionType() === ExtensionType::ARTEMIS) {
192-
193-
$subscriptionName = "{$this->subscriptionId}-{$this->queue->getStompName()}";
187+
} elseif (ExtensionType::ARTEMIS === $this->queue->getExtensionType()) {
188+
$subscriptionName = $this->subscriptionId.'-'.$this->queue->getStompName();
194189

195190
$artemisHeaders = [];
196191

@@ -214,7 +209,7 @@ private function convertMessage(Frame $frame): StompMessage
214209
throw new \LogicException(sprintf('Frame is not MESSAGE frame but: "%s"', $frame->getCommand()));
215210
}
216211

217-
[$headers, $properties] = StompHeadersEncoder::decode($frame->getHeaders());
212+
list($headers, $properties) = StompHeadersEncoder::decode($frame->getHeaders());
218213

219214
$redelivered = isset($headers['redelivered']) && 'true' === $headers['redelivered'];
220215

pkg/stomp/StompDestination.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class StompDestination implements Topic, Queue
4242
/**
4343
* @var string
4444
*/
45-
private string $extensionType;
45+
private $extensionType;
4646

4747
public function __construct(string $extensionType)
4848
{
@@ -76,7 +76,7 @@ public function getQueueName(): string
7676
throw new \LogicException('Destination name is not set');
7777
}
7878

79-
if ($this->extensionType === ExtensionType::ARTEMIS) {
79+
if (ExtensionType::ARTEMIS === $this->extensionType) {
8080
return $this->getStompName();
8181
}
8282

0 commit comments

Comments
 (0)