summaryrefslogtreecommitdiffstats
path: root/vendor/geoip2/geoip2/src
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/geoip2/geoip2/src')
-rw-r--r--vendor/geoip2/geoip2/src/Database/Reader.php104
-rw-r--r--vendor/geoip2/geoip2/src/Exception/AddressNotFoundException.php2
-rw-r--r--vendor/geoip2/geoip2/src/Exception/AuthenticationException.php2
-rw-r--r--vendor/geoip2/geoip2/src/Exception/GeoIp2Exception.php2
-rw-r--r--vendor/geoip2/geoip2/src/Exception/HttpException.php10
-rw-r--r--vendor/geoip2/geoip2/src/Exception/InvalidRequestException.php12
-rw-r--r--vendor/geoip2/geoip2/src/Exception/OutOfQueriesException.php2
-rw-r--r--vendor/geoip2/geoip2/src/Model/AbstractModel.php27
-rw-r--r--vendor/geoip2/geoip2/src/Model/AnonymousIp.php41
-rw-r--r--vendor/geoip2/geoip2/src/Model/Asn.php21
-rw-r--r--vendor/geoip2/geoip2/src/Model/City.php45
-rw-r--r--vendor/geoip2/geoip2/src/Model/ConnectionType.php17
-rw-r--r--vendor/geoip2/geoip2/src/Model/Country.php39
-rw-r--r--vendor/geoip2/geoip2/src/Model/Domain.php17
-rw-r--r--vendor/geoip2/geoip2/src/Model/Enterprise.php7
-rw-r--r--vendor/geoip2/geoip2/src/Model/Insights.php9
-rw-r--r--vendor/geoip2/geoip2/src/Model/Isp.php47
-rw-r--r--vendor/geoip2/geoip2/src/ProviderInterface.php6
-rw-r--r--vendor/geoip2/geoip2/src/Record/AbstractPlaceRecord.php25
-rw-r--r--vendor/geoip2/geoip2/src/Record/AbstractRecord.php30
-rw-r--r--vendor/geoip2/geoip2/src/Record/City.php6
-rw-r--r--vendor/geoip2/geoip2/src/Record/Continent.php4
-rw-r--r--vendor/geoip2/geoip2/src/Record/Country.php4
-rw-r--r--vendor/geoip2/geoip2/src/Record/Location.php4
-rw-r--r--vendor/geoip2/geoip2/src/Record/MaxMind.php4
-rw-r--r--vendor/geoip2/geoip2/src/Record/Postal.php4
-rw-r--r--vendor/geoip2/geoip2/src/Record/RepresentedCountry.php7
-rw-r--r--vendor/geoip2/geoip2/src/Record/Subdivision.php4
-rw-r--r--vendor/geoip2/geoip2/src/Record/Traits.php58
-rw-r--r--vendor/geoip2/geoip2/src/Util.php7
-rw-r--r--vendor/geoip2/geoip2/src/WebService/Client.php118
31 files changed, 469 insertions, 216 deletions
diff --git a/vendor/geoip2/geoip2/src/Database/Reader.php b/vendor/geoip2/geoip2/src/Database/Reader.php
index 9c33e3d..40d32bc 100644
--- a/vendor/geoip2/geoip2/src/Database/Reader.php
+++ b/vendor/geoip2/geoip2/src/Database/Reader.php
@@ -1,8 +1,19 @@
<?php
+declare(strict_types=1);
+
namespace GeoIp2\Database;
use GeoIp2\Exception\AddressNotFoundException;
+use GeoIp2\Model\AbstractModel;
+use GeoIp2\Model\AnonymousIp;
+use GeoIp2\Model\Asn;
+use GeoIp2\Model\City;
+use GeoIp2\Model\ConnectionType;
+use GeoIp2\Model\Country;
+use GeoIp2\Model\Domain;
+use GeoIp2\Model\Enterprise;
+use GeoIp2\Model\Isp;
use GeoIp2\ProviderInterface;
use MaxMind\Db\Reader as DbReader;
use MaxMind\Db\Reader\InvalidDatabaseException;
@@ -33,8 +44,19 @@ use MaxMind\Db\Reader\InvalidDatabaseException;
*/
class Reader implements ProviderInterface
{
+ /**
+ * @var DbReader
+ */
private $dbReader;
+
+ /**
+ * @var string
+ */
private $dbType;
+
+ /**
+ * @var array<string>
+ */
private $locales;
/**
@@ -48,8 +70,8 @@ class Reader implements ProviderInterface
* is corrupt or invalid
*/
public function __construct(
- $filename,
- $locales = ['en']
+ string $filename,
+ array $locales = ['en']
) {
$this->dbReader = new DbReader($filename);
$this->dbType = $this->dbReader->metadata()->databaseType;
@@ -65,12 +87,11 @@ class Reader implements ProviderInterface
* not in the database
* @throws \MaxMind\Db\Reader\InvalidDatabaseException if the database
* is corrupt or invalid
- *
- * @return \GeoIp2\Model\City
*/
- public function city($ipAddress)
+ public function city(string $ipAddress): City
{
- return $this->modelFor('City', 'City', $ipAddress);
+ // @phpstan-ignore-next-line
+ return $this->modelFor(City::class, 'City', $ipAddress);
}
/**
@@ -82,12 +103,11 @@ class Reader implements ProviderInterface
* not in the database
* @throws \MaxMind\Db\Reader\InvalidDatabaseException if the database
* is corrupt or invalid
- *
- * @return \GeoIp2\Model\Country
*/
- public function country($ipAddress)
+ public function country(string $ipAddress): Country
{
- return $this->modelFor('Country', 'Country', $ipAddress);
+ // @phpstan-ignore-next-line
+ return $this->modelFor(Country::class, 'Country', $ipAddress);
}
/**
@@ -99,13 +119,12 @@ class Reader implements ProviderInterface
* not in the database
* @throws \MaxMind\Db\Reader\InvalidDatabaseException if the database
* is corrupt or invalid
- *
- * @return \GeoIp2\Model\AnonymousIp
*/
- public function anonymousIp($ipAddress)
+ public function anonymousIp(string $ipAddress): AnonymousIp
{
+ // @phpstan-ignore-next-line
return $this->flatModelFor(
- 'AnonymousIp',
+ AnonymousIp::class,
'GeoIP2-Anonymous-IP',
$ipAddress
);
@@ -120,13 +139,12 @@ class Reader implements ProviderInterface
* not in the database
* @throws \MaxMind\Db\Reader\InvalidDatabaseException if the database
* is corrupt or invalid
- *
- * @return \GeoIp2\Model\Asn
*/
- public function asn($ipAddress)
+ public function asn(string $ipAddress): Asn
{
+ // @phpstan-ignore-next-line
return $this->flatModelFor(
- 'Asn',
+ Asn::class,
'GeoLite2-ASN',
$ipAddress
);
@@ -141,13 +159,12 @@ class Reader implements ProviderInterface
* not in the database
* @throws \MaxMind\Db\Reader\InvalidDatabaseException if the database
* is corrupt or invalid
- *
- * @return \GeoIp2\Model\ConnectionType
*/
- public function connectionType($ipAddress)
+ public function connectionType(string $ipAddress): ConnectionType
{
+ // @phpstan-ignore-next-line
return $this->flatModelFor(
- 'ConnectionType',
+ ConnectionType::class,
'GeoIP2-Connection-Type',
$ipAddress
);
@@ -162,13 +179,12 @@ class Reader implements ProviderInterface
* not in the database
* @throws \MaxMind\Db\Reader\InvalidDatabaseException if the database
* is corrupt or invalid
- *
- * @return \GeoIp2\Model\Domain
*/
- public function domain($ipAddress)
+ public function domain(string $ipAddress): Domain
{
+ // @phpstan-ignore-next-line
return $this->flatModelFor(
- 'Domain',
+ Domain::class,
'GeoIP2-Domain',
$ipAddress
);
@@ -183,12 +199,11 @@ class Reader implements ProviderInterface
* not in the database
* @throws \MaxMind\Db\Reader\InvalidDatabaseException if the database
* is corrupt or invalid
- *
- * @return \GeoIp2\Model\Enterprise
*/
- public function enterprise($ipAddress)
+ public function enterprise(string $ipAddress): Enterprise
{
- return $this->modelFor('Enterprise', 'Enterprise', $ipAddress);
+ // @phpstan-ignore-next-line
+ return $this->modelFor(Enterprise::class, 'Enterprise', $ipAddress);
}
/**
@@ -200,50 +215,47 @@ class Reader implements ProviderInterface
* not in the database
* @throws \MaxMind\Db\Reader\InvalidDatabaseException if the database
* is corrupt or invalid
- *
- * @return \GeoIp2\Model\Isp
*/
- public function isp($ipAddress)
+ public function isp(string $ipAddress): Isp
{
+ // @phpstan-ignore-next-line
return $this->flatModelFor(
- 'Isp',
+ Isp::class,
'GeoIP2-ISP',
$ipAddress
);
}
- private function modelFor($class, $type, $ipAddress)
+ private function modelFor(string $class, string $type, string $ipAddress): AbstractModel
{
- list($record, $prefixLen) = $this->getRecord($class, $type, $ipAddress);
+ [$record, $prefixLen] = $this->getRecord($class, $type, $ipAddress);
$record['traits']['ip_address'] = $ipAddress;
$record['traits']['prefix_len'] = $prefixLen;
- $class = 'GeoIp2\\Model\\' . $class;
-
return new $class($record, $this->locales);
}
- private function flatModelFor($class, $type, $ipAddress)
+ private function flatModelFor(string $class, string $type, string $ipAddress): AbstractModel
{
- list($record, $prefixLen) = $this->getRecord($class, $type, $ipAddress);
+ [$record, $prefixLen] = $this->getRecord($class, $type, $ipAddress);
$record['ip_address'] = $ipAddress;
$record['prefix_len'] = $prefixLen;
- $class = 'GeoIp2\\Model\\' . $class;
return new $class($record);
}
- private function getRecord($class, $type, $ipAddress)
+ private function getRecord(string $class, string $type, string $ipAddress): array
{
if (strpos($this->dbType, $type) === false) {
- $method = lcfirst($class);
+ $method = lcfirst((new \ReflectionClass($class))->getShortName());
+
throw new \BadMethodCallException(
"The $method method cannot be used to open a {$this->dbType} database"
);
}
- list($record, $prefixLen) = $this->dbReader->getWithPrefixLen($ipAddress);
+ [$record, $prefixLen] = $this->dbReader->getWithPrefixLen($ipAddress);
if ($record === null) {
throw new AddressNotFoundException(
"The address $ipAddress is not in the database."
@@ -272,7 +284,7 @@ class Reader implements ProviderInterface
*
* @return \MaxMind\Db\Reader\Metadata object for the database
*/
- public function metadata()
+ public function metadata(): DbReader\Metadata
{
return $this->dbReader->metadata();
}
@@ -280,7 +292,7 @@ class Reader implements ProviderInterface
/**
* Closes the GeoIP2 database and returns the resources to the system.
*/
- public function close()
+ public function close(): void
{
$this->dbReader->close();
}
diff --git a/vendor/geoip2/geoip2/src/Exception/AddressNotFoundException.php b/vendor/geoip2/geoip2/src/Exception/AddressNotFoundException.php
index 4e60c28..e5487b4 100644
--- a/vendor/geoip2/geoip2/src/Exception/AddressNotFoundException.php
+++ b/vendor/geoip2/geoip2/src/Exception/AddressNotFoundException.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
namespace GeoIp2\Exception;
/**
diff --git a/vendor/geoip2/geoip2/src/Exception/AuthenticationException.php b/vendor/geoip2/geoip2/src/Exception/AuthenticationException.php
index 5f5725f..abbc515 100644
--- a/vendor/geoip2/geoip2/src/Exception/AuthenticationException.php
+++ b/vendor/geoip2/geoip2/src/Exception/AuthenticationException.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
namespace GeoIp2\Exception;
/**
diff --git a/vendor/geoip2/geoip2/src/Exception/GeoIp2Exception.php b/vendor/geoip2/geoip2/src/Exception/GeoIp2Exception.php
index b15e5f4..3e75f6b 100644
--- a/vendor/geoip2/geoip2/src/Exception/GeoIp2Exception.php
+++ b/vendor/geoip2/geoip2/src/Exception/GeoIp2Exception.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
namespace GeoIp2\Exception;
/**
diff --git a/vendor/geoip2/geoip2/src/Exception/HttpException.php b/vendor/geoip2/geoip2/src/Exception/HttpException.php
index c9fc8b8..a3a5a93 100644
--- a/vendor/geoip2/geoip2/src/Exception/HttpException.php
+++ b/vendor/geoip2/geoip2/src/Exception/HttpException.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
namespace GeoIp2\Exception;
/**
@@ -9,13 +11,15 @@ class HttpException extends GeoIp2Exception
{
/**
* The URI queried.
+ *
+ * @var string
*/
public $uri;
public function __construct(
- $message,
- $httpStatus,
- $uri,
+ string $message,
+ int $httpStatus,
+ string $uri,
\Exception $previous = null
) {
$this->uri = $uri;
diff --git a/vendor/geoip2/geoip2/src/Exception/InvalidRequestException.php b/vendor/geoip2/geoip2/src/Exception/InvalidRequestException.php
index 63b6e42..4ab5e0c 100644
--- a/vendor/geoip2/geoip2/src/Exception/InvalidRequestException.php
+++ b/vendor/geoip2/geoip2/src/Exception/InvalidRequestException.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
namespace GeoIp2\Exception;
/**
@@ -10,14 +12,16 @@ class InvalidRequestException extends HttpException
{
/**
* The code returned by the MaxMind web service.
+ *
+ * @var string
*/
public $error;
public function __construct(
- $message,
- $error,
- $httpStatus,
- $uri,
+ string $message,
+ string $error,
+ int $httpStatus,
+ string $uri,
\Exception $previous = null
) {
$this->error = $error;
diff --git a/vendor/geoip2/geoip2/src/Exception/OutOfQueriesException.php b/vendor/geoip2/geoip2/src/Exception/OutOfQueriesException.php
index 16dc7b8..0d64d50 100644
--- a/vendor/geoip2/geoip2/src/Exception/OutOfQueriesException.php
+++ b/vendor/geoip2/geoip2/src/Exception/OutOfQueriesException.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
namespace GeoIp2\Exception;
/**
diff --git a/vendor/geoip2/geoip2/src/Model/AbstractModel.php b/vendor/geoip2/geoip2/src/Model/AbstractModel.php
index 50f24b0..ba8dd84 100644
--- a/vendor/geoip2/geoip2/src/Model/AbstractModel.php
+++ b/vendor/geoip2/geoip2/src/Model/AbstractModel.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
namespace GeoIp2\Model;
/**
@@ -7,14 +9,15 @@ namespace GeoIp2\Model;
*/
abstract class AbstractModel implements \JsonSerializable
{
+ /**
+ * @var array<string, mixed>
+ */
protected $raw;
/**
* @ignore
- *
- * @param mixed $raw
*/
- public function __construct($raw)
+ public function __construct(array $raw)
{
$this->raw = $raw;
}
@@ -22,9 +25,9 @@ abstract class AbstractModel implements \JsonSerializable
/**
* @ignore
*
- * @param mixed $field
+ * @return mixed
*/
- protected function get($field)
+ protected function get(string $field)
{
if (isset($this->raw[$field])) {
return $this->raw[$field];
@@ -39,12 +42,12 @@ abstract class AbstractModel implements \JsonSerializable
/**
* @ignore
*
- * @param mixed $attr
+ * @return mixed
*/
- public function __get($attr)
+ public function __get(string $attr)
{
if ($attr !== 'instance' && property_exists($this, $attr)) {
- return $this->$attr;
+ return $this->{$attr};
}
throw new \RuntimeException("Unknown attribute: $attr");
@@ -52,15 +55,13 @@ abstract class AbstractModel implements \JsonSerializable
/**
* @ignore
- *
- * @param mixed $attr
*/
- public function __isset($attr)
+ public function __isset(string $attr): bool
{
- return $attr !== 'instance' && isset($this->$attr);
+ return $attr !== 'instance' && isset($this->{$attr});
}
- public function jsonSerialize()
+ public function jsonSerialize(): array
{
return $this->raw;
}
diff --git a/vendor/geoip2/geoip2/src/Model/AnonymousIp.php b/vendor/geoip2/geoip2/src/Model/AnonymousIp.php
index bf05b88..fb927ab 100644
--- a/vendor/geoip2/geoip2/src/Model/AnonymousIp.php
+++ b/vendor/geoip2/geoip2/src/Model/AnonymousIp.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
namespace GeoIp2\Model;
use GeoIp2\Util;
@@ -17,6 +19,8 @@ use GeoIp2\Util;
* to a hosting or VPN provider (see description of isAnonymousVpn property).
* @property-read bool $isPublicProxy This is true if the IP address belongs to
* a public proxy.
+ * @property-read bool $isResidentialProxy This is true if the IP address is
+ * on a suspected anonymizing network and belongs to a residential ISP.
* @property-read bool $isTorExitNode This is true if the IP address is a Tor
* exit node.
* @property-read string $ipAddress The IP address that the data in the model is
@@ -27,20 +31,50 @@ use GeoIp2\Util;
*/
class AnonymousIp extends AbstractModel
{
+ /**
+ * @var bool
+ */
protected $isAnonymous;
+
+ /**
+ * @var bool
+ */
protected $isAnonymousVpn;
+
+ /**
+ * @var bool
+ */
protected $isHostingProvider;
+
+ /**
+ * @var bool
+ */
protected $isPublicProxy;
+
+ /**
+ * @var bool
+ */
+ protected $isResidentialProxy;
+
+ /**
+ * @var bool
+ */
protected $isTorExitNode;
+
+ /**
+ * @var string
+ */
protected $ipAddress;
+
+ /**
+ * @var string
+ */
protected $network;
/**
* @ignore
- *
- * @param mixed $raw
*/
- public function __construct($raw)
+ public function __construct(array $raw)
{
parent::__construct($raw);
@@ -48,6 +82,7 @@ class AnonymousIp extends AbstractModel
$this->isAnonymousVpn = $this->get('is_anonymous_vpn');
$this->isHostingProvider = $this->get('is_hosting_provider');
$this->isPublicProxy = $this->get('is_public_proxy');
+ $this->isResidentialProxy = $this->get('is_residential_proxy');
$this->isTorExitNode = $this->get('is_tor_exit_node');
$ipAddress = $this->get('ip_address');
$this->ipAddress = $ipAddress;
diff --git a/vendor/geoip2/geoip2/src/Model/Asn.php b/vendor/geoip2/geoip2/src/Model/Asn.php
index 09f746e..c28df26 100644
--- a/vendor/geoip2/geoip2/src/Model/Asn.php
+++ b/vendor/geoip2/geoip2/src/Model/Asn.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
namespace GeoIp2\Model;
use GeoIp2\Util;
@@ -20,17 +22,30 @@ use GeoIp2\Util;
*/
class Asn extends AbstractModel
{
+ /**
+ * @var int|null
+ */
protected $autonomousSystemNumber;
+
+ /**
+ * @var string|null
+ */
protected $autonomousSystemOrganization;
+
+ /**
+ * @var string
+ */
protected $ipAddress;
+
+ /**
+ * @var string
+ */
protected $network;
/**
* @ignore
- *
- * @param mixed $raw
*/
- public function __construct($raw)
+ public function __construct(array $raw)
{
parent::__construct($raw);
$this->autonomousSystemNumber = $this->get('autonomous_system_number');
diff --git a/vendor/geoip2/geoip2/src/Model/City.php b/vendor/geoip2/geoip2/src/Model/City.php
index bf8e352..701e9db 100644
--- a/vendor/geoip2/geoip2/src/Model/City.php
+++ b/vendor/geoip2/geoip2/src/Model/City.php
@@ -1,13 +1,15 @@
<?php
+declare(strict_types=1);
+
namespace GeoIp2\Model;
/**
- * Model class for the data returned by GeoIP2 City web service and database.
+ * Model class for the data returned by City Plus web service and City
+ * database.
*
- * The only difference between the City and Insights model classes is which
- * fields in each record may be populated. See
- * https://dev.maxmind.com/geoip/geoip2/web-services for more details.
+ * See https://dev.maxmind.com/geoip/docs/web-services?lang=en for more
+ * details.
*
* @property-read \GeoIp2\Record\City $city City data for the requested IP
* address.
@@ -31,28 +33,36 @@ class City extends Country
{
/**
* @ignore
+ *
+ * @var \GeoIp2\Record\City
*/
protected $city;
+
/**
* @ignore
+ *
+ * @var \GeoIp2\Record\Location
*/
protected $location;
+
/**
* @ignore
+ *
+ * @var \GeoIp2\Record\Postal
*/
protected $postal;
+
/**
* @ignore
+ *
+ * @var array<\GeoIp2\Record\Subdivision>
*/
protected $subdivisions = [];
/**
* @ignore
- *
- * @param mixed $raw
- * @param mixed $locales
*/
- public function __construct($raw, $locales = ['en'])
+ public function __construct(array $raw, array $locales = ['en'])
{
parent::__construct($raw, $locales);
@@ -63,29 +73,28 @@ class City extends Country
$this->createSubdivisions($raw, $locales);
}
- private function createSubdivisions($raw, $locales)
+ private function createSubdivisions(array $raw, array $locales): void
{
if (!isset($raw['subdivisions'])) {
return;
}
foreach ($raw['subdivisions'] as $sub) {
- array_push(
- $this->subdivisions,
+ $this->subdivisions[] =
new \GeoIp2\Record\Subdivision($sub, $locales)
- );
+ ;
}
}
/**
* @ignore
*
- * @param mixed $attr
+ * @return mixed
*/
- public function __get($attr)
+ public function __get(string $attr)
{
if ($attr === 'mostSpecificSubdivision') {
- return $this->$attr();
+ return $this->{$attr}();
}
return parent::__get($attr);
@@ -93,10 +102,8 @@ class City extends Country
/**
* @ignore
- *
- * @param mixed $attr
*/
- public function __isset($attr)
+ public function __isset(string $attr): bool
{
if ($attr === 'mostSpecificSubdivision') {
// We always return a mostSpecificSubdivision, even if it is the
@@ -107,7 +114,7 @@ class City extends Country
return parent::__isset($attr);
}
- private function mostSpecificSubdivision()
+ private function mostSpecificSubdivision(): \GeoIp2\Record\Subdivision
{
return empty($this->subdivisions) ?
new \GeoIp2\Record\Subdivision([], $this->locales) :
diff --git a/vendor/geoip2/geoip2/src/Model/ConnectionType.php b/vendor/geoip2/geoip2/src/Model/ConnectionType.php
index 013e6c3..e55fda1 100644
--- a/vendor/geoip2/geoip2/src/Model/ConnectionType.php
+++ b/vendor/geoip2/geoip2/src/Model/ConnectionType.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
namespace GeoIp2\Model;
use GeoIp2\Util;
@@ -18,16 +20,25 @@ use GeoIp2\Util;
*/
class ConnectionType extends AbstractModel
{
+ /**
+ * @var string|null
+ */
protected $connectionType;
+
+ /**
+ * @var string
+ */
protected $ipAddress;
+
+ /**
+ * @var string
+ */
protected $network;
/**
* @ignore
- *
- * @param mixed $raw
*/
- public function __construct($raw)
+ public function __construct(array $raw)
{
parent::__construct($raw);
diff --git a/vendor/geoip2/geoip2/src/Model/Country.php b/vendor/geoip2/geoip2/src/Model/Country.php
index 64d2650..67946b5 100644
--- a/vendor/geoip2/geoip2/src/Model/Country.php
+++ b/vendor/geoip2/geoip2/src/Model/Country.php
@@ -1,13 +1,13 @@
<?php
+declare(strict_types=1);
+
namespace GeoIp2\Model;
/**
* Model class for the data returned by GeoIP2 Country web service and database.
*
- * The only difference between the City and Insights model classes is which
- * fields in each record may be populated. See
- * https://dev.maxmind.com/geoip/geoip2/web-services for more details.
+ * See https://dev.maxmind.com/geoip/docs/web-services?lang=en for more details.
*
* @property-read \GeoIp2\Record\Continent $continent Continent data for the
* requested IP address.
@@ -26,24 +26,49 @@ namespace GeoIp2\Model;
* the represented country differs from the country.
* @property-read \GeoIp2\Record\Traits $traits Data for the traits of the
* requested IP address.
+ * @property-read array $raw The raw data from the web service.
*/
class Country extends AbstractModel
{
+ /**
+ * @var \GeoIp2\Record\Continent
+ */
protected $continent;
+
+ /**
+ * @var \GeoIp2\Record\Country
+ */
protected $country;
+
+ /**
+ * @var array<string>
+ */
protected $locales;
+
+ /**
+ * @var \GeoIp2\Record\MaxMind
+ */
protected $maxmind;
+
+ /**
+ * @var \GeoIp2\Record\Country
+ */
protected $registeredCountry;
+
+ /**
+ * @var \GeoIp2\Record\RepresentedCountry
+ */
protected $representedCountry;
+
+ /**
+ * @var \GeoIp2\Record\Traits
+ */
protected $traits;
/**
* @ignore
- *
- * @param mixed $raw
- * @param mixed $locales
*/
- public function __construct($raw, $locales = ['en'])
+ public function __construct(array $raw, array $locales = ['en'])
{
parent::__construct($raw);
diff --git a/vendor/geoip2/geoip2/src/Model/Domain.php b/vendor/geoip2/geoip2/src/Model/Domain.php
index 57982f7..df5e5cc 100644
--- a/vendor/geoip2/geoip2/src/Model/Domain.php
+++ b/vendor/geoip2/geoip2/src/Model/Domain.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
namespace GeoIp2\Model;
use GeoIp2\Util;
@@ -18,16 +20,25 @@ use GeoIp2\Util;
*/
class Domain extends AbstractModel
{
+ /**
+ * @var string|null
+ */
protected $domain;
+
+ /**
+ * @var string
+ */
protected $ipAddress;
+
+ /**
+ * @var string
+ */
protected $network;
/**
* @ignore
- *
- * @param mixed $raw
*/
- public function __construct($raw)
+ public function __construct(array $raw)
{
parent::__construct($raw);
diff --git a/vendor/geoip2/geoip2/src/Model/Enterprise.php b/vendor/geoip2/geoip2/src/Model/Enterprise.php
index 7f153fa..48becc6 100644
--- a/vendor/geoip2/geoip2/src/Model/Enterprise.php
+++ b/vendor/geoip2/geoip2/src/Model/Enterprise.php
@@ -1,13 +1,14 @@
<?php
+declare(strict_types=1);
+
namespace GeoIp2\Model;
/**
* Model class for the data returned by GeoIP2 Enterprise database lookups.
*
- * The only difference between the City and Enterprise model classes is which
- * fields in each record may be populated. See
- * https://dev.maxmind.com/geoip/geoip2/web-services for more details.
+ * See https://dev.maxmind.com/geoip/docs/web-services?lang=en for more
+ * details.
*/
class Enterprise extends City
{
diff --git a/vendor/geoip2/geoip2/src/Model/Insights.php b/vendor/geoip2/geoip2/src/Model/Insights.php
index df3a54c..320ef85 100644
--- a/vendor/geoip2/geoip2/src/Model/Insights.php
+++ b/vendor/geoip2/geoip2/src/Model/Insights.php
@@ -1,13 +1,14 @@
<?php
+declare(strict_types=1);
+
namespace GeoIp2\Model;
/**
- * Model class for the data returned by GeoIP2 Precision: Insights web service.
+ * Model class for the data returned by GeoIP2 Insights web service.
*
- * The only difference between the City and Insights model classes is which
- * fields in each record may be populated. See
- * https://dev.maxmind.com/geoip/geoip2/web-services for more details.
+ * See https://dev.maxmind.com/geoip/docs/web-services?lang=en for
+ * more details.
*/
class Insights extends City
{
diff --git a/vendor/geoip2/geoip2/src/Model/Isp.php b/vendor/geoip2/geoip2/src/Model/Isp.php
index aa30f74..0f7a376 100644
--- a/vendor/geoip2/geoip2/src/Model/Isp.php
+++ b/vendor/geoip2/geoip2/src/Model/Isp.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
namespace GeoIp2\Model;
use GeoIp2\Util;
@@ -14,6 +16,12 @@ use GeoIp2\Util;
* address.
* @property-read string|null $isp The name of the ISP associated with the IP
* address.
+ * @property-read string|null $mobileCountryCode The [mobile country code
+ * (MCC)](https://en.wikipedia.org/wiki/Mobile_country_code) associated with
+ * the IP address and ISP.
+ * @property-read string|null $mobileNetworkCode The [mobile network code
+ * (MNC)](https://en.wikipedia.org/wiki/Mobile_country_code) associated with
+ * the IP address and ISP.
* @property-read string|null $organization The name of the organization associated
* with the IP address.
* @property-read string $ipAddress The IP address that the data in the model is
@@ -24,25 +32,58 @@ use GeoIp2\Util;
*/
class Isp extends AbstractModel
{
+ /**
+ * @var int|null
+ */
protected $autonomousSystemNumber;
+
+ /**
+ * @var string|null
+ */
protected $autonomousSystemOrganization;
+
+ /**
+ * @var string|null
+ */
protected $isp;
+
+ /**
+ * @var string|null
+ */
+ protected $mobileCountryCode;
+
+ /**
+ * @var string|null
+ */
+ protected $mobileNetworkCode;
+
+ /**
+ * @var string|null
+ */
protected $organization;
+
+ /**
+ * @var string
+ */
protected $ipAddress;
+
+ /**
+ * @var string
+ */
protected $network;
/**
* @ignore
- *
- * @param mixed $raw
*/
- public function __construct($raw)
+ public function __construct(array $raw)
{
parent::__construct($raw);
$this->autonomousSystemNumber = $this->get('autonomous_system_number');
$this->autonomousSystemOrganization =
$this->get('autonomous_system_organization');
$this->isp = $this->get('isp');
+ $this->mobileCountryCode = $this->get('mobile_country_code');
+ $this->mobileNetworkCode = $this->get('mobile_network_code');
$this->organization = $this->get('organization');
$ipAddress = $this->get('ip_address');
diff --git a/vendor/geoip2/geoip2/src/ProviderInterface.php b/vendor/geoip2/geoip2/src/ProviderInterface.php
index 9162069..5d5209a 100644
--- a/vendor/geoip2/geoip2/src/ProviderInterface.php
+++ b/vendor/geoip2/geoip2/src/ProviderInterface.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
namespace GeoIp2;
interface ProviderInterface
@@ -9,12 +11,12 @@ interface ProviderInterface
*
* @return \GeoIp2\Model\Country a Country model for the requested IP address
*/
- public function country($ipAddress);
+ public function country(string $ipAddress): Model\Country;
/**
* @param string $ipAddress an IPv4 or IPv6 address to lookup
*
* @return \GeoIp2\Model\City a City model for the requested IP address
*/
- public function city($ipAddress);
+ public function city(string $ipAddress): Model\City;
}
diff --git a/vendor/geoip2/geoip2/src/Record/AbstractPlaceRecord.php b/vendor/geoip2/geoip2/src/Record/AbstractPlaceRecord.php
index 64bff36..d9fa371 100644
--- a/vendor/geoip2/geoip2/src/Record/AbstractPlaceRecord.php
+++ b/vendor/geoip2/geoip2/src/Record/AbstractPlaceRecord.php
@@ -1,18 +1,20 @@
<?php
+declare(strict_types=1);
+
namespace GeoIp2\Record;
abstract class AbstractPlaceRecord extends AbstractRecord
{
+ /**
+ * @var array<string>
+ */
private $locales;
/**
* @ignore
- *
- * @param mixed $record
- * @param mixed $locales
*/
- public function __construct($record, $locales = ['en'])
+ public function __construct(?array $record, array $locales = ['en'])
{
$this->locales = $locales;
parent::__construct($record);
@@ -21,9 +23,9 @@ abstract class AbstractPlaceRecord extends AbstractRecord
/**
* @ignore
*
- * @param mixed $attr
+ * @return mixed
*/
- public function __get($attr)
+ public function __get(string $attr)
{
if ($attr === 'name') {
return $this->name();
@@ -34,26 +36,25 @@ abstract class AbstractPlaceRecord extends AbstractRecord
/**
* @ignore
- *
- * @param mixed $attr
*/
- public function __isset($attr)
+ public function __isset(string $attr): bool
{
if ($attr === 'name') {
- return $this->firstSetNameLocale() === null ? false : true;
+ return $this->firstSetNameLocale() !== null;
}
return parent::__isset($attr);
}
- private function name()
+ private function name(): ?string
{
$locale = $this->firstSetNameLocale();
+ // @phpstan-ignore-next-line
return $locale === null ? null : $this->names[$locale];
}
- private function firstSetNameLocale()
+ private function firstSetNameLocale(): ?string
{
foreach ($this->locales as $locale) {
if (isset($this->names[$locale])) {
diff --git a/vendor/geoip2/geoip2/src/Record/AbstractRecord.php b/vendor/geoip2/geoip2/src/Record/AbstractRecord.php
index b2441ad..6c17ea5 100644
--- a/vendor/geoip2/geoip2/src/Record/AbstractRecord.php
+++ b/vendor/geoip2/geoip2/src/Record/AbstractRecord.php
@@ -1,17 +1,20 @@
<?php
+declare(strict_types=1);
+
namespace GeoIp2\Record;
abstract class AbstractRecord implements \JsonSerializable
{
+ /**
+ * @var array<string, mixed>
+ */
private $record;
/**
* @ignore
- *
- * @param mixed $record
*/
- public function __construct($record)
+ public function __construct(?array $record)
{
$this->record = isset($record) ? $record : [];
}
@@ -19,42 +22,45 @@ abstract class AbstractRecord implements \JsonSerializable
/**
* @ignore
*
- * @param mixed $attr
+ * @return mixed
*/
- public function __get($attr)
+ public function __get(string $attr)
{
// XXX - kind of ugly but greatly reduces boilerplate code
$key = $this->attributeToKey($attr);
if ($this->__isset($attr)) {
return $this->record[$key];
- } elseif ($this->validAttribute($attr)) {
+ }
+ if ($this->validAttribute($attr)) {
if (preg_match('/^is_/', $key)) {
return false;
}
return null;
}
+
throw new \RuntimeException("Unknown attribute: $attr");
}
- public function __isset($attr)
+ public function __isset(string $attr): bool
{
- return $this->validAttribute($attr) &&
- isset($this->record[$this->attributeToKey($attr)]);
+ return $this->validAttribute($attr)
+ && isset($this->record[$this->attributeToKey($attr)]);
}
- private function attributeToKey($attr)
+ private function attributeToKey(string $attr): string
{
return strtolower(preg_replace('/([A-Z])/', '_\1', $attr));
}
- private function validAttribute($attr)
+ private function validAttribute(string $attr): bool
{
+ // @phpstan-ignore-next-line
return \in_array($attr, $this->validAttributes, true);
}
- public function jsonSerialize()
+ public function jsonSerialize(): ?array
{
return $this->record;
}
diff --git a/vendor/geoip2/geoip2/src/Record/City.php b/vendor/geoip2/geoip2/src/Record/City.php
index f2e1f61..ca0eebb 100644
--- a/vendor/geoip2/geoip2/src/Record/City.php
+++ b/vendor/geoip2/geoip2/src/Record/City.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
namespace GeoIp2\Record;
/**
@@ -16,7 +18,7 @@ namespace GeoIp2\Record;
* @property-read string|null $name The name of the city based on the locales list
* passed to the constructor. This attribute is returned by all location
* services and databases.
- * @property-read array|null $names A array map where the keys are locale codes
+ * @property-read array|null $names An array map where the keys are locale codes
* and the values are names. This attribute is returned by all location
* services and databases.
*/
@@ -24,6 +26,8 @@ class City extends AbstractPlaceRecord
{
/**
* @ignore
+ *
+ * @var array<string>
*/
protected $validAttributes = ['confidence', 'geonameId', 'names'];
}
diff --git a/vendor/geoip2/geoip2/src/Record/Continent.php b/vendor/geoip2/geoip2/src/Record/Continent.php
index 8495713..55b8397 100644
--- a/vendor/geoip2/geoip2/src/Record/Continent.php
+++ b/vendor/geoip2/geoip2/src/Record/Continent.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
namespace GeoIp2\Record;
/**
@@ -23,6 +25,8 @@ class Continent extends AbstractPlaceRecord
{
/**
* @ignore
+ *
+ * @var array<string>
*/
protected $validAttributes = [
'code',
diff --git a/vendor/geoip2/geoip2/src/Record/Country.php b/vendor/geoip2/geoip2/src/Record/Country.php
index 5ff810d..155d189 100644
--- a/vendor/geoip2/geoip2/src/Record/Country.php
+++ b/vendor/geoip2/geoip2/src/Record/Country.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
namespace GeoIp2\Record;
/**
@@ -29,6 +31,8 @@ class Country extends AbstractPlaceRecord
{
/**
* @ignore
+ *
+ * @var array<string>
*/
protected $validAttributes = [
'confidence',
diff --git a/vendor/geoip2/geoip2/src/Record/Location.php b/vendor/geoip2/geoip2/src/Record/Location.php
index 8de109f..54e43b9 100644
--- a/vendor/geoip2/geoip2/src/Record/Location.php
+++ b/vendor/geoip2/geoip2/src/Record/Location.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
namespace GeoIp2\Record;
/**
@@ -37,6 +39,8 @@ class Location extends AbstractRecord
{
/**
* @ignore
+ *
+ * @var array<string>
*/
protected $validAttributes = [
'averageIncome',
diff --git a/vendor/geoip2/geoip2/src/Record/MaxMind.php b/vendor/geoip2/geoip2/src/Record/MaxMind.php
index 0c2cdd3..33f6c7c 100644
--- a/vendor/geoip2/geoip2/src/Record/MaxMind.php
+++ b/vendor/geoip2/geoip2/src/Record/MaxMind.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
namespace GeoIp2\Record;
/**
@@ -14,6 +16,8 @@ class MaxMind extends AbstractRecord
{
/**
* @ignore
+ *
+ * @var array<string>
*/
protected $validAttributes = ['queriesRemaining'];
}
diff --git a/vendor/geoip2/geoip2/src/Record/Postal.php b/vendor/geoip2/geoip2/src/Record/Postal.php
index 5c65923..229c234 100644
--- a/vendor/geoip2/geoip2/src/Record/Postal.php
+++ b/vendor/geoip2/geoip2/src/Record/Postal.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
namespace GeoIp2\Record;
/**
@@ -21,6 +23,8 @@ class Postal extends AbstractRecord
{
/**
* @ignore
+ *
+ * @var array<string>
*/
protected $validAttributes = ['code', 'confidence'];
}
diff --git a/vendor/geoip2/geoip2/src/Record/RepresentedCountry.php b/vendor/geoip2/geoip2/src/Record/RepresentedCountry.php
index 270da93..39bf0c3 100644
--- a/vendor/geoip2/geoip2/src/Record/RepresentedCountry.php
+++ b/vendor/geoip2/geoip2/src/Record/RepresentedCountry.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
namespace GeoIp2\Record;
/**
@@ -15,6 +17,11 @@ namespace GeoIp2\Record;
*/
class RepresentedCountry extends Country
{
+ /**
+ * @ignore
+ *
+ * @var array<string>
+ */
protected $validAttributes = [
'confidence',
'geonameId',
diff --git a/vendor/geoip2/geoip2/src/Record/Subdivision.php b/vendor/geoip2/geoip2/src/Record/Subdivision.php
index 4ad4e7f..0534b94 100644
--- a/vendor/geoip2/geoip2/src/Record/Subdivision.php
+++ b/vendor/geoip2/geoip2/src/Record/Subdivision.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
namespace GeoIp2\Record;
/**
@@ -30,6 +32,8 @@ class Subdivision extends AbstractPlaceRecord
{
/**
* @ignore
+ *
+ * @var array<string>
*/
protected $validAttributes = [
'confidence',
diff --git a/vendor/geoip2/geoip2/src/Record/Traits.php b/vendor/geoip2/geoip2/src/Record/Traits.php
index f02c693..d725d98 100644
--- a/vendor/geoip2/geoip2/src/Record/Traits.php
+++ b/vendor/geoip2/geoip2/src/Record/Traits.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
namespace GeoIp2\Record;
use GeoIp2\Util;
@@ -12,13 +14,13 @@ use GeoIp2\Util;
* @property-read int|null $autonomousSystemNumber The autonomous system number
* associated with the IP address. See
* https://en.wikipedia.org/wiki/Autonomous_system_(Internet%29. This attribute
- * is only available from the City and Insights web service and the GeoIP2
- * Enterprise database.
+ * is only available from the City Plus and Insights web services and the
+ * GeoIP2 Enterprise database.
* @property-read string|null $autonomousSystemOrganization The organization
* associated with the registered autonomous system number for the IP address.
* See https://en.wikipedia.org/wiki/Autonomous_system_(Internet%29. This
- * attribute is only available from the City and Insights web service and the
- * GeoIP2 Enterprise database.
+ * attribute is only available from the City Plus and Insights web services and
+ * the GeoIP2 Enterprise database.
* @property-read string|null $connectionType The connection type may take the
* following values: "Dialup", "Cable/DSL", "Corporate", "Cellular".
* Additional values may be added in the future. This attribute is only
@@ -26,7 +28,7 @@ use GeoIp2\Util;
* @property-read string|null $domain The second level domain associated with the
* IP address. This will be something like "example.com" or "example.co.uk",
* not "foo.example.com". This attribute is only available from the
- * City and Insights web service and the GeoIP2 Enterprise
+ * City Plus and Insights web services and the GeoIP2 Enterprise
* database.
* @property-read string $ipAddress The IP address that the data in the model
* is for. If you performed a "me" lookup against the web service, this
@@ -36,7 +38,7 @@ use GeoIp2\Util;
* points.
* @property-read bool $isAnonymous This is true if the IP address belongs to
* any sort of anonymous network. This property is only available from GeoIP2
- * Precision Insights.
+ * Insights.
* @property-read bool $isAnonymousProxy *Deprecated.* Please see our GeoIP2
* Anonymous IP database
* (https://www.maxmind.com/en/geoip2-anonymous-ip-database) to determine
@@ -45,39 +47,49 @@ use GeoIp2\Util;
* registered to an anonymous VPN provider. If a VPN provider does not register
* subnets under names associated with them, we will likely only flag their IP
* ranges using the isHostingProvider property. This property is only available
- * from GeoIP2 Precision Insights.
+ * from GeoIP2 Insights.
* @property-read bool $isHostingProvider This is true if the IP address belongs
* to a hosting or VPN provider (see description of isAnonymousVpn property).
- * This property is only available from GeoIP2 Precision Insights.
+ * This property is only available from GeoIP2 Insights.
* @property-read bool $isLegitimateProxy This attribute is true if MaxMind
* believes this IP address to be a legitimate proxy, such as an internal
* VPN used by a corporation. This attribute is only available in the GeoIP2
* Enterprise database.
* @property-read bool $isPublicProxy This is true if the IP address belongs to
- * a public proxy. This property is only available from GeoIP2 Precision
- * Insights.
+ * a public proxy. This property is only available from GeoIP2 Insights.
+ * @property-read bool $isResidentialProxy This is true if the IP address is
+ * on a suspected anonymizing network and belongs to a residential ISP. This
+ * property is only available from GeoIP2 Insights.
* @property-read bool $isSatelliteProvider *Deprecated.* Due to the
* increased coverage by mobile carriers, very few satellite providers now
* serve multiple countries. As a result, the output does not provide
* sufficiently relevant data for us to maintain it.
* @property-read bool $isTorExitNode This is true if the IP address is a Tor
- * exit node. This property is only available from GeoIP2 Precision Insights.
+ * exit node. This property is only available from GeoIP2 Insights.
* @property-read string|null $isp The name of the ISP associated with the IP
- * address. This attribute is only available from the City and Insights web
- * services and the GeoIP2 Enterprise database.
+ * address. This attribute is only available from the City Plus and Insights
+ * web services and the GeoIP2 Enterprise database.
* @property-read string $network The network in CIDR notation associated with
* the record. In particular, this is the largest network where all of the
* fields besides $ipAddress have the same value.
- * @property-read string|null $organization The name of the organization associated
- * with the IP address. This attribute is only available from the City and
+ * @property-read string|null $organization The name of the organization
+ * associated with the IP address. This attribute is only available from the
+ * City Plus and Insights web services and the GeoIP2 Enterprise database.
+ * @property-read string|null $mobileCountryCode The [mobile country code
+ * (MCC)](https://en.wikipedia.org/wiki/Mobile_country_code) associated with
+ * the IP address and ISP. This property is available from the City Plus and
* Insights web services and the GeoIP2 Enterprise database.
- * @property-read float|null $staticIPScore An indicator of how static or
+ * @property-read string|null $mobileNetworkCode The [mobile network code
+ * (MNC)](https://en.wikipedia.org/wiki/Mobile_country_code) associated with
+ * the IP address and ISP. This property is available from the City Plus and
+ * Insights web services and the GeoIP2 Enterprise database.
+ * @property-read float|null $staticIpScore An indicator of how static or
* dynamic an IP address is. This property is only available from GeoIP2
- * Precision Insights.
+ * Insights.
* @property-read int|null $userCount The estimated number of users sharing
* the IP/network during the past 24 hours. For IPv4, the count is for the
* individual IP. For IPv6, the count is for the /64 network. This property is
- * only available from GeoIP2 Precision Insights.
+ * only available from GeoIP2 Insights.
* @property-read string|null $userType <p>The user type associated with the IP
* address. This can be one of the following values:</p>
* <ul>
@@ -85,6 +97,7 @@ use GeoIp2\Util;
* <li>cafe
* <li>cellular
* <li>college
+ * <li>consumer_privacy_network
* <li>content_delivery_network
* <li>dialup
* <li>government
@@ -106,6 +119,8 @@ class Traits extends AbstractRecord
{
/**
* @ignore
+ *
+ * @var array<string>
*/
protected $validAttributes = [
'autonomousSystemNumber',
@@ -120,8 +135,11 @@ class Traits extends AbstractRecord
'isLegitimateProxy',
'isp',
'isPublicProxy',
+ 'isResidentialProxy',
'isSatelliteProvider',
'isTorExitNode',
+ 'mobileCountryCode',
+ 'mobileNetworkCode',
'network',
'organization',
'staticIpScore',
@@ -129,9 +147,9 @@ class Traits extends AbstractRecord
'userType',
];
- public function __construct($record)
+ public function __construct(?array $record)
{
- if (!isset($record['network']) && isset($record['ip_address']) && isset($record['prefix_len'])) {
+ if (!isset($record['network']) && isset($record['ip_address'], $record['prefix_len'])) {
$record['network'] = Util::cidr($record['ip_address'], $record['prefix_len']);
}
diff --git a/vendor/geoip2/geoip2/src/Util.php b/vendor/geoip2/geoip2/src/Util.php
index ac6d14c..4f08744 100644
--- a/vendor/geoip2/geoip2/src/Util.php
+++ b/vendor/geoip2/geoip2/src/Util.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
namespace GeoIp2;
class Util
@@ -10,11 +12,8 @@ class Util
*
* @internal
* @ignore
- *
- * @param mixed $ipAddress
- * @param mixed $prefixLen
*/
- public static function cidr($ipAddress, $prefixLen)
+ public static function cidr(string $ipAddress, int $prefixLen): string
{
$ipBytes = inet_pton($ipAddress);
$networkBytes = str_repeat("\0", \strlen($ipBytes));
diff --git a/vendor/geoip2/geoip2/src/WebService/Client.php b/vendor/geoip2/geoip2/src/WebService/Client.php
index bebca56..c84d409 100644
--- a/vendor/geoip2/geoip2/src/WebService/Client.php
+++ b/vendor/geoip2/geoip2/src/WebService/Client.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
namespace GeoIp2\WebService;
use GeoIp2\Exception\AddressNotFoundException;
@@ -8,13 +10,16 @@ use GeoIp2\Exception\GeoIp2Exception;
use GeoIp2\Exception\HttpException;
use GeoIp2\Exception\InvalidRequestException;
use GeoIp2\Exception\OutOfQueriesException;
+use GeoIp2\Model\City;
+use GeoIp2\Model\Country;
+use GeoIp2\Model\Insights;
use GeoIp2\ProviderInterface;
use MaxMind\WebService\Client as WsClient;
/**
- * This class provides a client API for all the GeoIP2 Precision web services.
- * The services are Country, City, and Insights. Each service returns a
- * different set of data about an IP address, with Country returning the
+ * This class provides a client API for all the GeoIP2 web services.
+ * The services are Country, City Plus, and Insights. Each service returns
+ * a different set of data about an IP address, with Country returning the
* least data and Insights the most.
*
* Each web service is represented by a different model class, and these model
@@ -43,11 +48,22 @@ use MaxMind\WebService\Client as WsClient;
*/
class Client implements ProviderInterface
{
+ /**
+ * @var array<string>
+ */
private $locales;
+
+ /**
+ * @var WsClient
+ */
private $client;
+
+ /**
+ * @var string
+ */
private static $basePath = '/geoip/v2.1';
- const VERSION = 'v2.10.0';
+ public const VERSION = 'v2.13.0';
/**
* Constructor.
@@ -57,7 +73,10 @@ class Client implements ProviderInterface
* @param array $locales list of locale codes to use in name property
* from most preferred to least preferred
* @param array $options array of options. Valid options include:
- * * `host` - The host to use when querying the web service.
+ * * `host` - The host to use when querying the web
+ * service. To query the GeoLite2 web service
+ * instead of the GeoIP2 web service, set the
+ * host to `geolite.info`.
* * `timeout` - Timeout in seconds.
* * `connectTimeout` - Initial connection timeout in seconds.
* * `proxy` - The HTTP proxy to use. May include a schema, port,
@@ -65,15 +84,16 @@ class Client implements ProviderInterface
* `http://username:password@127.0.0.1:10`.
*/
public function __construct(
- $accountId,
- $licenseKey,
- $locales = ['en'],
- $options = []
+ int $accountId,
+ string $licenseKey,
+ array $locales = ['en'],
+ array $options = []
) {
$this->locales = $locales;
// This is for backwards compatibility. Do not remove except for a
// major version bump.
+ // @phpstan-ignore-next-line
if (\is_string($options)) {
$options = ['host' => $options];
}
@@ -87,13 +107,13 @@ class Client implements ProviderInterface
$this->client = new WsClient($accountId, $licenseKey, $options);
}
- private function userAgent()
+ private function userAgent(): string
{
return 'GeoIP2-API/' . self::VERSION;
}
/**
- * This method calls the GeoIP2 Precision: City service.
+ * This method calls the City Plus service.
*
* @param string $ipAddress IPv4 or IPv6 address as a string. If no
* address is provided, the address that the web service is called
@@ -108,23 +128,22 @@ class Client implements ProviderInterface
* @throws \GeoIp2\Exception\InvalidRequestException} if your request was received by the web service but is
* invalid for some other reason. This may indicate an issue
* with this API. Please report the error to MaxMind.
- * @throws \GeoIp2\Exception\HttpException if an unexpected HTTP error code or message was returned.
- * This could indicate a problem with the connection between
- * your server and the web service or that the web service
- * returned an invalid document or 500 error code
- * @throws \GeoIp2\Exception\GeoIp2Exception This serves as the parent
- * class to the above exceptions. It will be thrown directly
- * if a 200 status code is returned but the body is invalid.
- *
- * @return \GeoIp2\Model\City
+ * @throws \GeoIp2\Exception\HttpException if an unexpected HTTP error code or message was returned.
+ * This could indicate a problem with the connection between
+ * your server and the web service or that the web service
+ * returned an invalid document or 500 error code
+ * @throws \GeoIp2\Exception\GeoIp2Exception This serves as the parent
+ * class to the above exceptions. It will be thrown directly
+ * if a 200 status code is returned but the body is invalid.
*/
- public function city($ipAddress = 'me')
+ public function city(string $ipAddress = 'me'): City
{
- return $this->responseFor('city', 'City', $ipAddress);
+ // @phpstan-ignore-next-line
+ return $this->responseFor('city', City::class, $ipAddress);
}
/**
- * This method calls the GeoIP2 Precision: Country service.
+ * This method calls the Country service.
*
* @param string $ipAddress IPv4 or IPv6 address as a string. If no
* address is provided, the address that the web service is called
@@ -138,24 +157,23 @@ class Client implements ProviderInterface
* @throws \GeoIp2\Exception\InvalidRequestException} if your request was received by the web service but is
* invalid for some other reason. This may indicate an
* issue with this API. Please report the error to MaxMind.
- * @throws \GeoIp2\Exception\HttpException if an unexpected HTTP error
- * code or message was returned. This could indicate a problem
- * with the connection between your server and the web service
- * or that the web service returned an invalid document or 500
- * error code.
- * @throws \GeoIp2\Exception\GeoIp2Exception This serves as the parent class to the above exceptions. It
- * will be thrown directly if a 200 status code is returned but
- * the body is invalid.
- *
- * @return \GeoIp2\Model\Country
+ * @throws \GeoIp2\Exception\HttpException if an unexpected HTTP error
+ * code or message was returned. This could indicate a problem
+ * with the connection between your server and the web service
+ * or that the web service returned an invalid document or 500
+ * error code.
+ * @throws \GeoIp2\Exception\GeoIp2Exception This serves as the parent class to the above exceptions. It
+ * will be thrown directly if a 200 status code is returned but
+ * the body is invalid.
*/
- public function country($ipAddress = 'me')
+ public function country(string $ipAddress = 'me'): Country
{
- return $this->responseFor('country', 'Country', $ipAddress);
+ return $this->responseFor('country', Country::class, $ipAddress);
}
/**
- * This method calls the GeoIP2 Precision: Insights service.
+ * This method calls the Insights service. Insights is only supported by
+ * the GeoIP2 web service. The GeoLite2 web service does not support it.
*
* @param string $ipAddress IPv4 or IPv6 address as a string. If no
* address is provided, the address that the web service is called
@@ -170,27 +188,27 @@ class Client implements ProviderInterface
* @throws \GeoIp2\Exception\InvalidRequestException} if your request was received by the web service but is
* invalid for some other reason. This may indicate an
* issue with this API. Please report the error to MaxMind.
- * @throws \GeoIp2\Exception\HttpException if an unexpected HTTP error code or message was returned.
- * This could indicate a problem with the connection between
- * your server and the web service or that the web service
- * returned an invalid document or 500 error code
- * @throws \GeoIp2\Exception\GeoIp2Exception This serves as the parent
- * class to the above exceptions. It will be thrown directly
- * if a 200 status code is returned but the body is invalid.
- *
- * @return \GeoIp2\Model\Insights
+ * @throws \GeoIp2\Exception\HttpException if an unexpected HTTP error code or message was returned.
+ * This could indicate a problem with the connection between
+ * your server and the web service or that the web service
+ * returned an invalid document or 500 error code
+ * @throws \GeoIp2\Exception\GeoIp2Exception This serves as the parent
+ * class to the above exceptions. It will be thrown directly
+ * if a 200 status code is returned but the body is invalid.
*/
- public function insights($ipAddress = 'me')
+ public function insights(string $ipAddress = 'me'): Insights
{
- return $this->responseFor('insights', 'Insights', $ipAddress);
+ // @phpstan-ignore-next-line
+ return $this->responseFor('insights', Insights::class, $ipAddress);
}
- private function responseFor($endpoint, $class, $ipAddress)
+ private function responseFor(string $endpoint, string $class, string $ipAddress): Country
{
$path = implode('/', [self::$basePath, $endpoint, $ipAddress]);
try {
- $body = $this->client->get('GeoIP2 ' . $class, $path);
+ $service = (new \ReflectionClass($class))->getShortName();
+ $body = $this->client->get('GeoIP2 ' . $service, $path);
} catch (\MaxMind\Exception\IpAddressNotFoundException $ex) {
throw new AddressNotFoundException(
$ex->getMessage(),
@@ -232,8 +250,6 @@ class Client implements ProviderInterface
);
}
- $class = 'GeoIp2\\Model\\' . $class;
-
return new $class($body, $this->locales);
}
}