Renamed languages to locales in the code
This commit is contained in:
@@ -38,23 +38,23 @@ use MaxMind\Db\Reader as DbReader;
|
||||
class Reader implements ProviderInterface
|
||||
{
|
||||
private $dbReader;
|
||||
private $languages;
|
||||
private $locales;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $filename The path to the GeoIP2 database file.
|
||||
* @param array $languages List of locale codes to use in name property
|
||||
* @param array $locales List of locale codes to use in name property
|
||||
* from most preferred to least preferred.
|
||||
* @throws \MaxMind\Db\Reader\InvalidDatabaseException if the database
|
||||
* is corrupt or invalid
|
||||
*/
|
||||
public function __construct(
|
||||
$filename,
|
||||
$languages = array('en')
|
||||
$locales = array('en')
|
||||
) {
|
||||
$this->dbReader = new DbReader($filename);
|
||||
$this->languages = $languages;
|
||||
$this->locales = $locales;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -136,7 +136,7 @@ class Reader implements ProviderInterface
|
||||
$record['traits']['ip_address'] = $ipAddress;
|
||||
$class = "GeoIp2\\Model\\" . $class;
|
||||
|
||||
return new $class($record, $this->languages);
|
||||
return new $class($record, $this->locales);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -74,18 +74,18 @@ class City extends Country
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
public function __construct($raw, $languages)
|
||||
public function __construct($raw, $locales)
|
||||
{
|
||||
parent::__construct($raw, $languages);
|
||||
parent::__construct($raw, $locales);
|
||||
|
||||
$this->city = new \GeoIp2\Record\City($this->get('city'), $languages);
|
||||
$this->city = new \GeoIp2\Record\City($this->get('city'), $locales);
|
||||
$this->location = new \GeoIp2\Record\Location($this->get('location'));
|
||||
$this->postal = new \GeoIp2\Record\Postal($this->get('postal'));
|
||||
|
||||
$this->createSubdivisions($raw, $languages);
|
||||
$this->createSubdivisions($raw, $locales);
|
||||
}
|
||||
|
||||
private function createSubdivisions($raw, $languages)
|
||||
private function createSubdivisions($raw, $locales)
|
||||
{
|
||||
if (!isset($raw['subdivisions'])) {
|
||||
return;
|
||||
@@ -94,7 +94,7 @@ class City extends Country
|
||||
foreach ($raw['subdivisions'] as $sub) {
|
||||
array_push(
|
||||
$this->subdivisions,
|
||||
new \GeoIp2\Record\Subdivision($sub, $languages)
|
||||
new \GeoIp2\Record\Subdivision($sub, $locales)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -114,7 +114,7 @@ class City extends Country
|
||||
private function mostSpecificSubdivision()
|
||||
{
|
||||
return empty($this->subdivisions)?
|
||||
new \GeoIp2\Record\Subdivision(array(), $this->languages):
|
||||
new \GeoIp2\Record\Subdivision(array(), $this->locales):
|
||||
end($this->subdivisions);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ class Country
|
||||
{
|
||||
private $continent;
|
||||
private $country;
|
||||
private $languages;
|
||||
private $locales;
|
||||
private $maxmind;
|
||||
private $registeredCountry;
|
||||
private $representedCountry;
|
||||
@@ -47,30 +47,30 @@ class Country
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
public function __construct($raw, $languages)
|
||||
public function __construct($raw, $locales)
|
||||
{
|
||||
$this->raw = $raw;
|
||||
|
||||
$this->continent = new \GeoIp2\Record\Continent(
|
||||
$this->get('continent'),
|
||||
$languages
|
||||
$locales
|
||||
);
|
||||
$this->country = new \GeoIp2\Record\Country(
|
||||
$this->get('country'),
|
||||
$languages
|
||||
$locales
|
||||
);
|
||||
$this->maxmind = new \GeoIp2\Record\MaxMind($this->get('maxmind'));
|
||||
$this->registeredCountry = new \GeoIp2\Record\Country(
|
||||
$this->get('registered_country'),
|
||||
$languages
|
||||
$locales
|
||||
);
|
||||
$this->representedCountry = new \GeoIp2\Record\RepresentedCountry(
|
||||
$this->get('represented_country'),
|
||||
$languages
|
||||
$locales
|
||||
);
|
||||
$this->traits = new \GeoIp2\Record\Traits($this->get('traits'));
|
||||
|
||||
$this->languages = $languages;
|
||||
$this->locales = $locales;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,14 +4,14 @@ namespace GeoIp2\Record;
|
||||
|
||||
abstract class AbstractPlaceRecord extends AbstractRecord
|
||||
{
|
||||
private $languages;
|
||||
private $locales;
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
public function __construct($record, $languages)
|
||||
public function __construct($record, $locales)
|
||||
{
|
||||
$this->languages = $languages;
|
||||
$this->locales = $locales;
|
||||
parent::__construct($record);
|
||||
}
|
||||
|
||||
@@ -29,9 +29,9 @@ abstract class AbstractPlaceRecord extends AbstractRecord
|
||||
|
||||
private function name()
|
||||
{
|
||||
foreach ($this->languages as $language) {
|
||||
if (isset($this->names[$language])) {
|
||||
return $this->names[$language];
|
||||
foreach ($this->locales as $locale) {
|
||||
if (isset($this->names[$locale])) {
|
||||
return $this->names[$locale];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace GeoIp2\Record;
|
||||
* @property int $geonameId The GeoName ID for the city. This attribute
|
||||
* is returned by all end points.
|
||||
*
|
||||
* @property string $name The name of the city based on the languages list
|
||||
* @property string $name The name of the city based on the locales list
|
||||
* passed to the constructor. This attribute is returned by all end points.
|
||||
*
|
||||
* @property array $names A array map where the keys are locale codes
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace GeoIp2\Record;
|
||||
* is returned by all end points.
|
||||
*
|
||||
* @property string $name Returns the name of the continent based on the
|
||||
* languages list passed to the constructor. This attribute is returned by
|
||||
* locales list passed to the constructor. This attribute is returned by
|
||||
* all end points.
|
||||
*
|
||||
* @property array $names An array map where the keys are locale codes
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace GeoIp2\Record;
|
||||
* two-character ISO 3166-1 alpha code} for the country. This attribute is
|
||||
* returned by all end points.
|
||||
*
|
||||
* @property string $name The name of the country based on the languages list
|
||||
* @property string $name The name of the country based on the locales list
|
||||
* passed to the constructor. This attribute is returned by all end points.
|
||||
*
|
||||
* @property array $names An array map where the keys are locale codes and
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace GeoIp2\Record;
|
||||
* two-character ISO 3166-1 alpha code} for the country. This attribute is
|
||||
* returned by all end points.
|
||||
*
|
||||
* @property string $name The name of the country based on the languages list
|
||||
* @property string $name The name of the country based on the locales list
|
||||
* passed to the constructor. This attribute is returned by all end points.
|
||||
*
|
||||
* @property array $names An array map where the keys are locale codes and
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace GeoIp2\Record;
|
||||
* http://en.wikipedia.org/wiki/ISO_3166-2 ISO 3166-2 code}. This attribute
|
||||
* is returned by all end points except Country.
|
||||
*
|
||||
* @property string $name The name of the subdivision based on the languages
|
||||
* @property string $name The name of the subdivision based on the locales
|
||||
* list passed to the constructor. This attribute is returned by all end
|
||||
* points except Country.
|
||||
*
|
||||
|
||||
@@ -49,7 +49,7 @@ class Client implements ProviderInterface
|
||||
{
|
||||
private $userId;
|
||||
private $licenseKey;
|
||||
private $languages;
|
||||
private $locales;
|
||||
private $host;
|
||||
private $guzzleClient;
|
||||
|
||||
@@ -58,7 +58,7 @@ class Client implements ProviderInterface
|
||||
*
|
||||
* @param int $userId Your MaxMind user ID
|
||||
* @param string $licenseKey Your MaxMind license key
|
||||
* @param array $languages List of locale codes to use in name property
|
||||
* @param array $locales List of locale codes to use in name property
|
||||
* from most preferred to least preferred.
|
||||
* @param string $host Optional host parameter
|
||||
* @param object $guzzleClient Optional Guzzle client to use (to facilitate
|
||||
@@ -67,13 +67,13 @@ class Client implements ProviderInterface
|
||||
public function __construct(
|
||||
$userId,
|
||||
$licenseKey,
|
||||
$languages = array('en'),
|
||||
$locales = array('en'),
|
||||
$host = 'geoip.maxmind.com',
|
||||
$guzzleClient = null
|
||||
) {
|
||||
$this->userId = $userId;
|
||||
$this->licenseKey = $licenseKey;
|
||||
$this->languages = $languages;
|
||||
$this->locales = $locales;
|
||||
$this->host = $host;
|
||||
// To enable unit testing
|
||||
$this->guzzleClient = $guzzleClient;
|
||||
@@ -228,7 +228,7 @@ class Client implements ProviderInterface
|
||||
if ($response && $response->isSuccessful()) {
|
||||
$body = $this->handleSuccess($response, $uri);
|
||||
$class = "GeoIp2\\Model\\" . $class;
|
||||
return new $class($body, $this->languages);
|
||||
return new $class($body, $this->locales);
|
||||
} else {
|
||||
$this->handleNon200($response, $uri);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user