You are here

public function SmsMessageResult::setCreditsUsed in SMS Framework 2.x

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

Sets the credits consumed for this transaction.

Parameters

float|null $credits_used: The credits consumed for this transaction, or NULL if unknown.

Return value

$this Returns this result object for chaining.

Throws

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

Overrides SmsMessageResultInterface::setCreditsUsed

File

src/Entity/SmsMessageResult.php, line 148

Class

SmsMessageResult
Defines the SMS message result entity.

Namespace

Drupal\sms\Entity

Code

public function setCreditsUsed($credits_used) {
  if (is_numeric($credits_used) || is_null($credits_used)) {
    $this
      ->set('credits_used', $credits_used);
  }
  else {
    throw new SmsException(sprintf('Credit used is a %s', gettype($credits_used)));
  }
  return $this;
}