Skip to content

Commit 6c65758

Browse files
Use ??= more
1 parent 7089189 commit 6c65758

File tree

4 files changed

+6
-18
lines changed

4 files changed

+6
-18
lines changed

Channel/ChatChannel.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ public function notify(Notification $notification, RecipientInterface $recipient
2828
$message = $notification->asChatMessage($recipient, $transportName);
2929
}
3030

31-
if (null === $message) {
32-
$message = ChatMessage::fromNotification($notification);
33-
}
31+
$message ??= ChatMessage::fromNotification($notification);
3432

3533
if (null !== $transportName) {
3634
$message->transport($transportName);

Channel/PushChannel.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ public function notify(Notification $notification, RecipientInterface $recipient
2828
$message = $notification->asPushMessage($recipient, $transportName);
2929
}
3030

31-
if (null === $message) {
32-
$message = PushMessage::fromNotification($notification);
33-
}
31+
$message ??= PushMessage::fromNotification($notification);
3432

3533
if (null !== $transportName) {
3634
$message->transport($transportName);

Channel/SmsChannel.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@ public function notify(Notification $notification, RecipientInterface $recipient
2929
$message = $notification->asSmsMessage($recipient, $transportName);
3030
}
3131

32-
if (null === $message) {
33-
$message = SmsMessage::fromNotification($notification, $recipient);
34-
}
32+
$message ??= SmsMessage::fromNotification($notification, $recipient);
3533

3634
if (null !== $transportName) {
3735
$message->transport($transportName);

Test/TransportTestCase.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,7 @@ public function testToString(string $expected, TransportInterface $transport)
5757
*/
5858
public function testSupportedMessages(MessageInterface $message, TransportInterface $transport = null)
5959
{
60-
if (null === $transport) {
61-
$transport = $this->createTransport();
62-
}
60+
$transport ??= $this->createTransport();
6361

6462
$this->assertTrue($transport->supports($message));
6563
}
@@ -69,9 +67,7 @@ public function testSupportedMessages(MessageInterface $message, TransportInterf
6967
*/
7068
public function testUnsupportedMessages(MessageInterface $message, TransportInterface $transport = null)
7169
{
72-
if (null === $transport) {
73-
$transport = $this->createTransport();
74-
}
70+
$transport ??= $this->createTransport();
7571

7672
$this->assertFalse($transport->supports($message));
7773
}
@@ -81,9 +77,7 @@ public function testUnsupportedMessages(MessageInterface $message, TransportInte
8177
*/
8278
public function testUnsupportedMessagesTrowUnsupportedMessageTypeExceptionWhenSend(MessageInterface $message, TransportInterface $transport = null)
8379
{
84-
if (null === $transport) {
85-
$transport = $this->createTransport();
86-
}
80+
$transport ??= $this->createTransport();
8781

8882
$this->expectException(UnsupportedMessageTypeException::class);
8983

0 commit comments

Comments
 (0)