You are here

public function GeoIpHandlerV2::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

File

src/GeoIpHandlerV2.php, line 166
The GeoIP API handler for version 2.

Class

GeoIpHandlerV2

Namespace

Drupal\geoip

Code

public function regionName($ip = NULL) {
  try {
    $subdivisions = $this
      ->record($ip)->subdivisions;
    if ($subdivision = end($subdivisions)) {
      return $subdivision->name;
    }
  } catch (\Exception $e) {
    return FALSE;
  }
}