8000 * LightSmsTransport.php - quick fix for private constant. · symfony/symfony@5e54dfe · GitHub
[go: up one dir, main page]

Skip to content

Commit 5e54dfe

Browse files
Vasilij DuskoVasilij Dusko | CREATION
Vasilij Dusko
authored and
Vasilij Dusko | CREATION
committed
* LightSmsTransport.php - quick fix for private constant.
1 parent 3cbbc85 commit 5e54dfe

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

src/Symfony/Component/Notifier/Bridge/LightSms/LightSmsTransport.php

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,8 @@ final class LightSmsTransport extends AbstractTransport
3030
private $login;
3131
private $password;
3232
private $phone;
33-
/**
34-
* @var MessageInterface
35-
*/
36-
private $message;
3733

38-
private $errorCodes = [
34+
private const ERROR_CODES = [
3935
'000' => 'Service unavailable',
4036
'1' => 'Signature not specified',
4137
'2' => 'Login not specified',
@@ -103,9 +99,7 @@ protected function doSend(MessageInterface $message): SentMessage
10399
throw new UnsupportedMessageTypeException(__CLASS__, SmsMessage::class, $message);
104100
}
105101

106-
$this->message = $message;
107-
108-
$signature = $this->generateSignature();
102+
$signature = $this->generateSignature($message);
109103

110104
$endpoint = sprintf(
111105
'https://%s/external/get/send.php?login=%s&signature=%s&phone=%s&text=%s&sender=%s&timestamp=%s',
@@ -123,12 +117,12 @@ protected function doSend(MessageInterface $message): SentMessage
123117
$content = $response->toArray(false);
124118

125119
if (isset($content['error'])) {
126-
throw new TransportException('Unable to send the SMS: '.$this->errorCodes[$content['error']], $response);
120+
throw new TransportException('Unable to send the SMS: '.self::ERROR_CODES[$content['error']], $response);
127121
}
128122

129123
$phone = preg_replace("/[^\d]/", '', $message->getPhone());
130124
if (32 == $content[$phone]['error']) {
131-
throw new TransportException('Unable to send the SMS: '.$this->errorCodes[$content['error']], $response);
125+
throw new TransportException('Unable to send the SMS: '.self::ERROR_CODES[$content['error']], $response);
132126
}
133127

134128
if (0 == $content[$phone]['error']) {
@@ -139,14 +133,14 @@ protected function doSend(MessageInterface $message): SentMessage
139133
return $sentMessage;
140134
}
141135

142-
private function generateSignature(): string
136+
private function generateSignature(SmsMessage $message): string
143137
{
144138
$params = [
145139
'timestamp' => time(),
146140
'login' => $this->login,
147-
'phone' => str_replace('+', '', $this->message->getPhone()),
141+
'phone' => str_replace('+', '', $message->getPhone()),
148142
'sender' => $this->phone,
149-
'text' => $this->message->getSubject(),
143+
'text' => $message->getSubject(),
150144
];
151145

152146
ksort($params);

0 commit comments

Comments
 (0)
0