SmsMessageResult.php in SMS Framework 2.x
File
src/Message/SmsMessageResult.php
View source
<?php
declare (strict_types=1);
namespace Drupal\sms\Message;
use Drupal\sms\Exception\SmsException;
class SmsMessageResult implements SmsMessageResultInterface {
protected $error = NULL;
protected $errorMessage = '';
protected $reports = [];
protected $creditsBalance = NULL;
protected $creditsUsed = NULL;
public function getError() {
return $this->error;
}
public function setError($error) {
$this->error = $error;
return $this;
}
public function getErrorMessage() {
return $this->errorMessage;
}
public function setErrorMessage($message) {
$this->errorMessage = $message;
return $this;
}
public function getReport($recipient) {
foreach ($this->reports as $report) {
if ($report
->getRecipient() == $recipient) {
return $report;
}
}
return NULL;
}
public function getReports() {
return $this->reports;
}
public function setReports(array $reports) {
$this->reports = $reports;
return $this;
}
public function addReport(SmsDeliveryReportInterface $report) {
$this->reports[] = $report;
return $this;
}
public function getCreditsBalance() {
return $this->creditsBalance;
}
public function setCreditsBalance($balance) {
if (is_numeric($balance) || is_null($balance)) {
$this->creditsBalance = $balance;
}
else {
throw new SmsException(sprintf('Credit balance set is a %s', gettype($balance)));
}
return $this;
}
public function getCreditsUsed() {
return $this->creditsUsed;
}
public function setCreditsUsed($credits_used) {
if (is_numeric($credits_used) || is_null($credits_used)) {
$this->creditsUsed = $credits_used;
}
else {
throw new SmsException(sprintf('Credit used is a %s', gettype($credits_used)));
}
return $this;
}
}