You are here

public function EmailConfirmation::setIp in Email confirmer 8

Sets the IP address associated with this confirmation process.

Parameters

string $ip: The IP address.

Return value

\Drupal\email_confirmer\EmailConfirmationInterface The called email confirmation entity.

Throws

\InvalidArgumentException If the given value is not a valid IP address.

Overrides EmailConfirmationInterface::setIp

File

src/Entity/EmailConfirmation.php, line 357

Class

EmailConfirmation
Defines the email confirmation entity class.

Namespace

Drupal\email_confirmer\Entity

Code

public function setIp($ip) {
  if (ip2long($ip) === FALSE) {
    throw new \InvalidArgumentException($ip . ' is not a valid IP address.');
  }
  $this
    ->get('ip')
    ->setValue($ip);
  return $this;
}