-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathClient.php
More file actions
43 lines (38 loc) · 905 Bytes
/
Client.php
File metadata and controls
43 lines (38 loc) · 905 Bytes
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
42
43
<?php
namespace gud3\sms;
use gud3\sms\Services\ServiceInterface;
use yii\base\Component;
use yii\base\InvalidConfigException;
use yii\di\Instance;
/**
* Class Client
* @package gud3\sms
*/
class Client extends Component
{
/**
* @var string|ServiceInterface
*/
public $service;
/**
* @var string Sender name
*/
public $sender;
public function init()
{
if (empty($this->sender)) {
throw new InvalidConfigException('Specify sender name.');
}
$this->service = Instance::ensure($this->service, 'gud3\sms\Services\ServiceInterface');
}
/**
* @param string|array $to
* @param string $message
* @return mixed transaction ID
* @throws \RuntimeException
*/
public function send($to, $message)
{
return $this->service->send(new Sms($this->sender, (array)$to, $message));
}
}