You are here

class SmsMessageResult in SMS Framework 8

Same name in this branch
  1. 8 src/Message/SmsMessageResult.php \Drupal\sms\Message\SmsMessageResult
  2. 8 src/Entity/SmsMessageResult.php \Drupal\sms\Entity\SmsMessageResult
Same name and namespace in other branches
  1. 2.x src/Message/SmsMessageResult.php \Drupal\sms\Message\SmsMessageResult
  2. 2.1.x src/Message/SmsMessageResult.php \Drupal\sms\Message\SmsMessageResult

The result of an SMS messaging transaction.

Hierarchy

Expanded class hierarchy of SmsMessageResult

8 files declare their use of SmsMessageResult
Incoming.php in tests/modules/sms_test_gateway/src/Plugin/SmsGateway/Incoming.php
LogGateway.php in src/Plugin/SmsGateway/LogGateway.php
Memory.php in tests/modules/sms_test_gateway/src/Plugin/SmsGateway/Memory.php
SmsDevelMessageForm.php in modules/sms_devel/src/Form/SmsDevelMessageForm.php
SmsFrameworkMessageTestTrait.php in tests/src/Functional/SmsFrameworkMessageTestTrait.php

... See full list

File

src/Message/SmsMessageResult.php, line 10

Namespace

Drupal\sms\Message
View source
class SmsMessageResult implements SmsMessageResultInterface {

  /**
   * The error of the message, or NULL if unknown.
   *
   * @var string|null
   */
  protected $error = NULL;

  /**
   * The error message as provided by the gateway API.
   *
   * @var string
   */
  protected $errorMessage = '';

  /**
   * The message delivery reports.
   *
   * @var \Drupal\sms\Message\SmsDeliveryReportInterface[]
   */
  protected $reports = [];

  /**
   * The credit balance after this message is sent, or NULL if unknown.
   *
   * This number is in the SMS gateway's chosen denomination.
   *
   * @var float|null
   */
  protected $creditsBalance = NULL;

  /**
   * The credits consumed to process this message, or NULL if unknown.
   *
   * This number is in the SMS gateway's chosen denomination.
   *
   * @var float|null
   */
  protected $creditsUsed = NULL;

  /**
   * {@inheritdoc}
   */
  public function getError() {
    return $this->error;
  }

  /**
   * {@inheritdoc}
   */
  public function setError($error) {
    $this->error = $error;
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function getErrorMessage() {
    return $this->errorMessage;
  }

  /**
   * {@inheritdoc}
   */
  public function setErrorMessage($message) {
    $this->errorMessage = $message;
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function getReport($recipient) {
    foreach ($this->reports as $report) {
      if ($report
        ->getRecipient() == $recipient) {
        return $report;
      }
    }
    return NULL;
  }

  /**
   * {@inheritdoc}
   */
  public function getReports() {
    return $this->reports;
  }

  /**
   * {@inheritdoc}
   */
  public function setReports(array $reports) {
    $this->reports = $reports;
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function addReport(SmsDeliveryReportInterface $report) {
    $this->reports[] = $report;
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function getCreditsBalance() {
    return $this->creditsBalance;
  }

  /**
   * {@inheritdoc}
   */
  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;
  }

  /**
   * {@inheritdoc}
   */
  public function getCreditsUsed() {
    return $this->creditsUsed;
  }

  /**
   * {@inheritdoc}
   */
  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;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
SmsMessageResult::$creditsBalance protected property The credit balance after this message is sent, or NULL if unknown.
SmsMessageResult::$creditsUsed protected property The credits consumed to process this message, or NULL if unknown.
SmsMessageResult::$error protected property The error of the message, or NULL if unknown.
SmsMessageResult::$errorMessage protected property The error message as provided by the gateway API.
SmsMessageResult::$reports protected property The message delivery reports.
SmsMessageResult::addReport public function Adds a delivery report to the result. Overrides SmsMessageResultInterface::addReport
SmsMessageResult::getCreditsBalance public function Gets the credit balance after this transaction. Overrides SmsMessageResultInterface::getCreditsBalance
SmsMessageResult::getCreditsUsed public function Gets the credits consumed for this transaction. Overrides SmsMessageResultInterface::getCreditsUsed
SmsMessageResult::getError public function Gets the error of the message. Overrides SmsMessageResultInterface::getError
SmsMessageResult::getErrorMessage public function Gets the error message. Overrides SmsMessageResultInterface::getErrorMessage
SmsMessageResult::getReport public function Gets the delivery report for a particular recipient. Overrides SmsMessageResultInterface::getReport
SmsMessageResult::getReports public function Gets the delivery reports for all recipients. Overrides SmsMessageResultInterface::getReports
SmsMessageResult::setCreditsBalance public function Sets the credit balance after this transaction. Overrides SmsMessageResultInterface::setCreditsBalance
SmsMessageResult::setCreditsUsed public function Sets the credits consumed for this transaction. Overrides SmsMessageResultInterface::setCreditsUsed
SmsMessageResult::setError public function Sets the error of the message. Overrides SmsMessageResultInterface::setError
SmsMessageResult::setErrorMessage public function Sets the error message. Overrides SmsMessageResultInterface::setErrorMessage
SmsMessageResult::setReports public function Sets the delivery reports for all recipients. Overrides SmsMessageResultInterface::setReports