Skip to content

Commit

Permalink
removed unnecessary output. added character limit
Browse files Browse the repository at this point in the history
  • Loading branch information
tylercd100 committed Apr 12, 2016
1 parent e87f763 commit e2916f8
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
9 changes: 7 additions & 2 deletions src/Handler/PlivoHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@ class PlivoHandler extends SMSHandler
* @param bool $useSSL Whether to connect via SSL.
* @param string $host The Plivo server hostname.
* @param string $version The Plivo API version (default PlivoHandler::API_V1)
* @param string $limit The character limit
*/
public function __construct($authToken, $authId, $fromNumber, $toNumber, $level = Logger::CRITICAL, $bubble = true, $useSSL = true, $host = 'api.plivo.com', $version = self::API_V1)
public function __construct($authToken, $authId, $fromNumber, $toNumber, $level = Logger::CRITICAL, $bubble = true, $useSSL = true, $host = 'api.plivo.com', $version = self::API_V1, $limit = 160)
{
if($version !== self::API_V1){
throw new Exception('API Version \'{$version}\' is not supported!');
}
parent::__construct($authToken, $authId, $fromNumber, $toNumber, $level, $bubble, $useSSL, $host, $version);
parent::__construct($authToken, $authId, $fromNumber, $toNumber, $level, $bubble, $useSSL, $host, $version, $limit);
}
/**
* {@inheritdoc}
Expand All @@ -42,6 +43,10 @@ public function __construct($authToken, $authId, $fromNumber, $toNumber, $level
*/
protected function buildContent($record)
{
if(strlen($record['formatted']) > $this->limit){
$record['formatted'] = substr($record['formatted'], 0, $this->limit);
}

$dataArray = array(
'src' => $this->fromNumber,
'dst' => $this->toNumber,
Expand Down
4 changes: 3 additions & 1 deletion src/Handler/SMSHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ abstract class SMSHandler extends SocketHandler
* @param bool $useSSL Whether to connect via SSL.
* @param string $host The Plivo server hostname.
* @param string $version The Plivo API version (default PlivoHandler::API_V1)
* @param string $limit The character limit
*/
public function __construct($authToken, $authId, $fromNumber, $toNumber, $level = Logger::CRITICAL, $bubble = true, $useSSL = true, $host = 'api.plivo.com', $version = null)
public function __construct($authToken, $authId, $fromNumber, $toNumber, $level = Logger::CRITICAL, $bubble = true, $useSSL = true, $host = 'api.plivo.com', $version = null, $limit = 160)
{

if(empty($version)){
Expand All @@ -67,6 +68,7 @@ public function __construct($authToken, $authId, $fromNumber, $toNumber, $level
$this->toNumber = $toNumber;
$this->host = $host;
$this->version = $version;
$this->limit = $limit;

}

Expand Down
9 changes: 7 additions & 2 deletions src/Handler/TwilioHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@ class TwilioHandler extends SMSHandler
* @param bool $useSSL Whether to connect via SSL.
* @param string $host The Twilio server hostname.
* @param string $version The Twilio API version (default TwilioHandler::API_V1)
* @param string $limit The character limit
*/
public function __construct($secret, $sid, $fromNumber, $toNumber, $level = Logger::CRITICAL, $bubble = true, $useSSL = true, $host = 'api.twilio.com', $version = self::API_V1)
public function __construct($secret, $sid, $fromNumber, $toNumber, $level = Logger::CRITICAL, $bubble = true, $useSSL = true, $host = 'api.twilio.com', $version = self::API_V1, $limit = 160)
{
if($version !== self::API_V1){
throw new Exception('API Version \'{$version}\' is not supported!');
}
parent::__construct($secret, $sid, $fromNumber, $toNumber, $level, $bubble, $useSSL, $host, $version);
parent::__construct($secret, $sid, $fromNumber, $toNumber, $level, $bubble, $useSSL, $host, $version, $limit);
}

/**
Expand All @@ -43,6 +44,10 @@ public function __construct($secret, $sid, $fromNumber, $toNumber, $level = Logg
*/
protected function buildContent($record)
{
if(strlen($record['formatted']) > $this->limit){
$record['formatted'] = substr($record['formatted'], 0, $this->limit);
}

$dataArray = array(
'From' => $this->fromNumber,
'To' => $this->toNumber,
Expand Down

0 comments on commit e2916f8

Please sign in to comment.