-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathQtSmsTransport.php
41 lines (35 loc) · 1.04 KB
/
QtSmsTransport.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
namespace Bankiru\Sms\QtSms;
use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;
use ScayTrase\SmsDeliveryBundle\Exception\DeliveryFailedException;
use ScayTrase\SmsDeliveryBundle\Service\ShortMessageInterface;
use ScayTrase\SmsDeliveryBundle\Transport\TransportInterface;
final class QtSmsTransport implements TransportInterface
{
/** @var QtSms */
private $client;
/** @var string */
private $sender;
/**
* QtSmsTransport constructor.
*
* @param QtSms $client
* @param string $sender
*/
public function __construct(QtSms $client, $sender)
{
$this->client = $client;
$this->sender = $sender;
}
/** {@inheritdoc} */
public function send(ShortMessageInterface $message)
{
try {
$this->client->post_message($message->getBody(), $message->getRecipient(), $this->sender);
} catch (\Exception $e) {
throw new DeliveryFailedException($e->getMessage(), $e->getCode(), $e);
}
return true;
}
}