You are here

public function SmsGateway::getRetentionDuration in SMS Framework 8

Same name and namespace in other branches
  1. 2.x src/Entity/SmsGateway.php \Drupal\sms\Entity\SmsGateway::getRetentionDuration()
  2. 2.1.x src/Entity/SmsGateway.php \Drupal\sms\Entity\SmsGateway::getRetentionDuration()

Get how many seconds to hold messages.

Parameters

int $direction: The direction of the message. See SmsMessageInterface::DIRECTION_* constants.

Return value

int How long messages should persist in seconds. -1 to never expire.

Overrides SmsGatewayInterface::getRetentionDuration

File

src/Entity/SmsGateway.php, line 246

Class

SmsGateway
Defines storage for an SMS Gateway instance.

Namespace

Drupal\sms\Entity

Code

public function getRetentionDuration($direction) {
  switch ($direction) {
    case Direction::INCOMING:
      return (int) $this->retention_duration_incoming;
    case Direction::OUTGOING:
      return (int) $this->retention_duration_outgoing;
    default:
      throw new \InvalidArgumentException(sprintf('%s is not a valid direction.', $direction));
  }
}