Exemplo n.º 1
0
 /**
  * @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;
 }
Exemplo n.º 2
0
 /**
  * @param string $dbCode
  * @return \Magento\Framework\Phrase|string
  */
 protected function getDbCreateDate($dbCode)
 {
     return $this->database->isDbAvailable($dbCode) ? $this->_localeDate->formatDate($this->getDbDateTime($dbCode), \IntlDateFormatter::MEDIUM) : __('Never');
 }
Exemplo n.º 3
0
 /**
  * @param string $dbCode
  * @param bool $isFile
  * @param bool $isReadable
  * @param bool $isDbAvailable
  * @dataProvider isDbAvailableDataProvider
  */
 public function testIsDbAvailable($dbCode, $isFile, $isReadable, $isDbAvailable)
 {
     $this->configureDirectoryIsFileIsReadableMethods($dbCode, $isFile, $isReadable);
     $this->assertEquals($isDbAvailable, $this->database->isDbAvailable($dbCode));
 }