Skip to content

Commit cfd7213

Browse files
authored
Optimize events using nullsafe operator (#5473)
1 parent a436290 commit cfd7213

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/Driver/Driver.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ protected function checkQueueLength(): void
8989
{
9090
$info = $this->info();
9191
foreach ($info as $key => $value) {
92-
$this->event && $this->event->dispatch(new QueueLength($this, $key, $value));
92+
$this->event?->dispatch(new QueueLength($this, $key, $value));
9393
}
9494
}
9595

@@ -98,19 +98,19 @@ protected function getCallback($data, $message): callable
9898
return function () use ($data, $message) {
9999
try {
100100
if ($message instanceof MessageInterface) {
101-
$this->event && $this->event->dispatch(new BeforeHandle($message));
101+
$this->event?->dispatch(new BeforeHandle($message));
102102
$message->job()->handle();
103-
$this->event && $this->event->dispatch(new AfterHandle($message));
103+
$this->event?->dispatch(new AfterHandle($message));
104104
}
105105

106106
$this->ack($data);
107107
} catch (Throwable $ex) {
108108
if (isset($message, $data)) {
109109
if ($message->attempts() && $this->remove($data)) {
110-
$this->event && $this->event->dispatch(new RetryHandle($message, $ex));
110+
$this->event?->dispatch(new RetryHandle($message, $ex));
111111
$this->retry($message);
112112
} else {
113-
$this->event && $this->event->dispatch(new FailedHandle($message, $ex));
113+
$this->event?->dispatch(new FailedHandle($message, $ex));
114114
$this->fail($data);
115115
}
116116
}

0 commit comments

Comments
 (0)