You are here

private function IpAddress::checkSingleDelimiter in IP address fields 2.0.x

Checks that zero or one range delimiter exists in a raw value.

1 call to IpAddress::checkSingleDelimiter()
IpAddress::parse in src/IpAddress.php
Find if the value given is an IP, IP range, or other.

File

src/IpAddress.php, line 128

Class

IpAddress
IpTools class.

Namespace

Drupal\field_ipaddress

Code

private function checkSingleDelimiter($value) {
  $count = 0;
  $delimiters = [
    '/',
    '*',
    '-',
  ];
  foreach ($delimiters as $delimiter) {
    if (strpos($value, $delimiter) !== FALSE) {
      $count++;
    }
  }
  if ($count > 1) {
    throw new \Exception('Cannot combine range delimiters, only one of - / * must be present.');
  }
}