Created
February 20, 2019 20:35
-
-
Save orobogenius/596809b9737a117feb3f0cd42f6b0087 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Components\Sms\Drivers; | |
use Nexmo\Client as NexmoClient; | |
class NexmoDriver extends Driver | |
{ | |
/** | |
* The Nexmo client. | |
* | |
* @var \Nexmo\Client | |
*/ | |
protected $client; | |
/** | |
* The phone number this sms should be sent from. | |
* | |
* @var string | |
*/ | |
protected $from; | |
/** | |
* Create a new Nexmo driver instance. | |
* | |
* @param \Nexmo\Client $nexmo | |
* @param string $from | |
* @return void | |
*/ | |
public function __construct(NexmoClient $nexmo, $from) | |
{ | |
$this->client = $nexmo; | |
$this->from = $from; | |
} | |
/** | |
* {@inheritdoc} | |
*/ | |
public function send() | |
{ | |
return $this->client->message()->send([ | |
'type' => 'text', | |
'from' => $this->from, | |
'to' => $this->recipient, | |
'text' => trim($this->message) | |
]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment