You are here

public function SmsMessageResult::setCreditsBalance in SMS Framework 2.1.x

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

Sets the credit balance after this transaction.

Parameters

float|null $balance: The credit balance after the message is processed, or NULL if unknown.

Return value

$this Returns this result object for chaining.

Throws

\Drupal\sms\Exception\SmsException Thrown if balance set is an invalid variable type.

Overrides SmsMessageResultInterface::setCreditsBalance

File

src/Message/SmsMessageResult.php, line 128

Class

SmsMessageResult
The result of an SMS messaging transaction.

Namespace

Drupal\sms\Message

Code

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;
}