Skip to content

Commit d5ba019

Browse files
committed
Make use of the nullsafe operator
1 parent e3c930a commit d5ba019

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

Server/DumpServer.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,25 +56,19 @@ public function listen(callable $callback): void
5656
}
5757

5858
foreach ($this->getMessages() as $clientId => $message) {
59-
if ($this->logger) {
60-
$this->logger->info('Received a payload from client {clientId}', ['clientId' => $clientId]);
61-
}
59+
$this->logger?->info('Received a payload from client {clientId}', ['clientId' => $clientId]);
6260

6361
$payload = @unserialize(base64_decode($message), ['allowed_classes' => [Data::class, Stub::class]]);
6462

6563
// Impossible to decode the message, give up.
6664
if (false === $payload) {
67-
if ($this->logger) {
68-
$this->logger->warning('Unable to decode a message from {clientId} client.', ['clientId' => $clientId]);
69-
}
65+
$this->logger?->warning('Unable to decode a message from {clientId} client.', ['clientId' => $clientId]);
7066

7167
continue;
7268
}
7369

7470
if (!\is_array($payload) || \count($payload) < 2 || !$payload[0] instanceof Data || !\is_array($payload[1])) {
75-
if ($this->logger) {
76-
$this->logger->warning('Invalid payload from {clientId} client. Expected an array of two elements (Data $data, array $context)', ['clientId' => $clientId]);
77-
}
71+
$this->logger?->warning('Invalid payload from {clientId} client. Expected an array of two elements (Data $data, array $context)', ['clientId' => $clientId]);
7872

7973
continue;
8074
}

0 commit comments

Comments
 (0)