nexmo-bundle/Sender/SmsSender.php

50 lines
1.1 KiB
PHP
Raw Normal View History

2013-12-09 19:29:26 +00:00
<?php
namespace Jhg\NexmoBundle\Sender;
use Nexmo\NexmoMessage;
use Symfony\Component\DependencyInjection\Container;
2014-03-10 23:17:33 +00:00
/**
* Class SmsSender
* @package Jhg\NexmoBundle\Sender
*
* @author Javi Hernández
*/
2013-12-09 19:29:26 +00:00
class SmsSender
{
2014-03-10 23:17:33 +00:00
/**
* @var \Nexmo\NexmoMessage
*/
protected $nexmoMessage;
/**
* @var \Symfony\Component\DependencyInjection\Container
*/
protected $container;
/**
* @param Container $container
* @param NexmoMessage $nexmoMessage
*/
public function __construct(Container $container,NexmoMessage $nexmoMessage) {
2013-12-09 19:29:26 +00:00
$this->container = $container;
2014-03-10 23:17:33 +00:00
$this->nexmoMessage = $nexmoMessage;
2013-12-09 19:29:26 +00:00
}
2014-03-10 23:17:33 +00:00
/**
* @param $number
* @param null $fromName
* @param $message
* @param null $unicode
* @param int $status_report_req
* @return array|bool|\Nexmo\stdClass
*/
public function send($number,$fromName=null,$message,$unicode=null, $status_report_req=0) {
2013-12-09 19:29:26 +00:00
if($fromName===null)
$fromName = $this->container->getParameter('jhg_nexmo.from_name');
return $this->nexmoMessage->sendText($number,$fromName,$message,$unicode,$status_report_req);
}
}