Skip to content

Commit 7df63fa

Browse files
[Notifier] Bring consistency to bridges
1 parent 38ce69f commit 7df63fa

File tree

1 file changed

+7
-25
lines changed

1 file changed

+7
-25
lines changed

SmsapiTransport.php

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -64,28 +64,13 @@ public function setTest(bool $test): static
6464

6565
public function __toString(): string
6666
{
67-
$dsn = sprintf('smsapi://%s', $this->getEndpoint());
68-
$params = [];
69-
70-
if ('' !== $this->from) {
71-
$params['from'] = $this->from;
72-
}
73-
74-
if ($this->fast) {
75-
$params['fast'] = (int) $this->fast;
76-
}
77-
78-
if ($this->test) {
79-
$params['test'] = (int) $this->test;
80-
}
81-
82-
$query = http_build_query($params, '', '&');
83-
84-
if ('' !== $query) {
85-
$dsn .= sprintf('?%s', $query);
86-
}
67+
$query = array_filter([
68+
'from' => $this->from,
69+
'fast' => (int) $this->fast,
70+
'test' => (int) $this->test,
71+
]);
8772

88-
return $dsn;
73+
return sprintf('smsapi://%s%s', $this->getEndpoint(), $query ? '?'.http_build_query($query, '', '&') : '');
8974
}
9075

9176
public function supports(MessageInterface $message): bool
@@ -109,10 +94,7 @@ protected function doSend(MessageInterface $message): SentMessage
10994
'test' => $this->test,
11095
];
11196

112-
$from = $message->getFrom() ?: $this->from;
113-
114-
// if from is not empty add it to request body
115-
if ('' !== $from) {
97+
if ('' !== $from = $message->getFrom() ?: $this->from) {
11698
$body['from'] = $from;
11799
}
118100

0 commit comments

Comments
 (0)