/**
  * @param string $dbCode
  * @param string $absolute
  * @param string $basePath
  * @param string $dbPath
  * @dataProvider getDbPathDataProvider
  */
 public function testGetDbPath($dbCode, $absolute, $basePath, $dbPath)
 {
     if ($absolute) {
         $this->configureGetBasePathMethod($basePath);
     }
     $this->assertEquals($dbPath, $this->database->getDbPath($dbCode, $absolute));
 }
 /**
  * @param string $dbCode
  * @param array $locales
  * @return \GeoIp2\Database\Reader
  * @throws LocalizedException
  */
 public function create($dbCode, array $locales = ['en'])
 {
     if (!$this->database->isDbAvailable($dbCode)) {
         throw new LocalizedException(__('GeoIp2 database with "%1" code is not declared.', $dbCode));
     }
     $reader = $this->objectManager->create($this->instanceName, ['filename' => $this->database->getDbPath($dbCode, true), 'locales' => $locales]);
     if (!$reader instanceof \GeoIp2\Database\Reader) {
         throw new \InvalidArgumentException(get_class($reader) . ' must be an instance of \\GeoIp2\\Database\\Reader.');
     }
     return $reader;
 }
Example #3
0
 /**
  * @param string $dbCode
  * @throws LocalizedException
  */
 protected function unpackDb($dbCode)
 {
     $this->archive->unpack($this->directory->getAbsolutePath($this->getDbArchiveFilePath($dbCode)), $this->directory->getAbsolutePath($this->database->getDbPath($dbCode)));
     if (!$this->directory->isExist($this->database->getDbPath($dbCode))) {
         throw new LocalizedException(__('Cannot unpack db file.'));
     }
 }