You are here

public function GeoIpHandlerV2::getReader in GeoIP API 7.2

Creates a single reader instance for this file.

Return value

\GeoIp2\Database\Reader The reader to use.

File

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

Class

GeoIpHandlerV2

Namespace

Drupal\geoip

Code

public function getReader() {
  if (!isset($this->reader)) {
    $this->reader = new Reader($this->dbFile);

    // Set the read method to use for this type of db.
    $database_type = $this->reader
      ->metadata()->databaseType;
    $this->readMethod = strtolower(substr($database_type, strrpos($database_type, '-') + 1));
  }
  return $this->reader;
}