Skip to content

Commit

Permalink
Refactor switch statement to simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesDPC committed Aug 14, 2024
1 parent 41f7442 commit a32f8bb
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions src/Connector/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,20 +137,13 @@ protected function sendMessage(array $parameters)
// send options
$send_via_job = $this->sendViaJob();
$in = $this->getSendIn();// seconds
switch ($send_via_job) {
case 'yes':
return $this->queueAndSend($domain, $parameters, $in);
case 'when-attachments':
if (!empty($parameters['attachment'])) {
return $this->queueAndSend($domain, $parameters, $in);
}
// fallback to direct
// no break
case 'no':
default:
return $client->messages()->send($domain, $parameters);
if ($send_via_job == 'yes') {
return $this->queueAndSend($domain, $parameters, $in);
} elseif ($send_via_job == 'when-attachments' && !empty($parameters['attachment'])) {
return $this->queueAndSend($domain, $parameters, $in);
} else {
return $client->messages()->send($domain, $parameters);
}
return null;
}

/**
Expand Down

0 comments on commit a32f8bb

Please sign in to comment.