You are here

public function GeoIpHandlerV1::regionName in GeoIP API 7.2

The region name for a given IP.

This will just return the most accurate subdivision if there are multiple levels.

Parameters

string $ip: The ip to resolve.

Return value

string|FALSE The region name or FALSE on failure.

Overrides GeoIpHandlerInterface::regionName

1 call to GeoIpHandlerV1::regionName()
GeoIpHandlerV1::rawRecord in src/GeoIpHandlerV1.php
Returns an array of all information related the ip.

File

src/GeoIpHandlerV1.php, line 172
The GeoIP API handler for version 1 - legacy.

Class

GeoIpHandlerV1

Namespace

Drupal\geoip

Code

public function regionName($ip = NULL) {
  try {
    $record = $this
      ->record($ip);
    if (!empty($record->country_code) && !empty($record->region)) {
      return self::$vars[$record->country_code][$record->region];
    }
    return FALSE;
  } catch (\Exception $e) {
    return FALSE;
  }
}