minFraud PHP API v1.21.0

Reader
in package
implements ProviderInterface

Instances of this class provide a reader for the GeoIP2 database format.

IP addresses can be looked up using the database specific methods.

Usage

The basic API for this class is the same for every database. First, you create a reader object, specifying a file name. You then call the method corresponding to the specific database, passing it the IP address you want to look up.

If the request succeeds, the method call will return a model class for the method you called. This model in turn contains multiple record classes, each of which represents part of the data returned by the database. If the database does not contain the requested information, the attributes on the record class will have a null value.

If the address is not in the database, an exception will be thrown. If an invalid IP address is passed to one of the methods, a SPL will be thrown. If the database is corrupt or invalid, a will be thrown.

Interfaces, Classes, Traits and Enums

ProviderInterface

Table of Contents

__construct()  : mixed
Constructor.
anonymousIp()  : AnonymousIp
This method returns a GeoIP2 Anonymous IP model.
asn()  : Asn
This method returns a GeoLite2 ASN model.
city()  : City
This method returns a GeoIP2 City model.
close()  : void
Closes the GeoIP2 database and returns the resources to the system.
connectionType()  : ConnectionType
This method returns a GeoIP2 Connection Type model.
country()  : Country
This method returns a GeoIP2 Country model.
domain()  : Domain
This method returns a GeoIP2 Domain model.
enterprise()  : Enterprise
This method returns a GeoIP2 Enterprise model.
isp()  : Isp
This method returns a GeoIP2 ISP model.
metadata()  : Metadata

Methods

__construct()

Constructor.

public __construct(string $filename[, array<string|int, mixed> $locales = ['en'] ]) : mixed
Parameters
$filename : string

the path to the GeoIP2 database file

$locales : array<string|int, mixed> = ['en']

list of locale codes to use in name property from most preferred to least preferred

Tags
throws
InvalidDatabaseException

if the database is corrupt or invalid

Return values
mixed

anonymousIp()

This method returns a GeoIP2 Anonymous IP model.

public anonymousIp(string $ipAddress) : AnonymousIp
Parameters
$ipAddress : string

an IPv4 or IPv6 address as a string

Tags
throws
AddressNotFoundException

if the address is not in the database

throws
InvalidDatabaseException

if the database is corrupt or invalid

Return values
AnonymousIp

asn()

This method returns a GeoLite2 ASN model.

public asn(string $ipAddress) : Asn
Parameters
$ipAddress : string

an IPv4 or IPv6 address as a string

Tags
throws
AddressNotFoundException

if the address is not in the database

throws
InvalidDatabaseException

if the database is corrupt or invalid

Return values
Asn

city()

This method returns a GeoIP2 City model.

public city(string $ipAddress) : City
Parameters
$ipAddress : string

an IPv4 or IPv6 address as a string

Tags
throws
AddressNotFoundException

if the address is not in the database

throws
InvalidDatabaseException

if the database is corrupt or invalid

Return values
City

a City model for the requested IP address

close()

Closes the GeoIP2 database and returns the resources to the system.

public close() : void
Return values
void

connectionType()

This method returns a GeoIP2 Connection Type model.

public connectionType(string $ipAddress) : ConnectionType
Parameters
$ipAddress : string

an IPv4 or IPv6 address as a string

Tags
throws
AddressNotFoundException

if the address is not in the database

throws
InvalidDatabaseException

if the database is corrupt or invalid

Return values
ConnectionType

country()

This method returns a GeoIP2 Country model.

public country(string $ipAddress) : Country
Parameters
$ipAddress : string

an IPv4 or IPv6 address as a string

Tags
throws
AddressNotFoundException

if the address is not in the database

throws
InvalidDatabaseException

if the database is corrupt or invalid

Return values
Country

a Country model for the requested IP address

domain()

This method returns a GeoIP2 Domain model.

public domain(string $ipAddress) : Domain
Parameters
$ipAddress : string

an IPv4 or IPv6 address as a string

Tags
throws
AddressNotFoundException

if the address is not in the database

throws
InvalidDatabaseException

if the database is corrupt or invalid

Return values
Domain

enterprise()

This method returns a GeoIP2 Enterprise model.

public enterprise(string $ipAddress) : Enterprise
Parameters
$ipAddress : string

an IPv4 or IPv6 address as a string

Tags
throws
AddressNotFoundException

if the address is not in the database

throws
InvalidDatabaseException

if the database is corrupt or invalid

Return values
Enterprise

isp()

This method returns a GeoIP2 ISP model.

public isp(string $ipAddress) : Isp
Parameters
$ipAddress : string

an IPv4 or IPv6 address as a string

Tags
throws
AddressNotFoundException

if the address is not in the database

throws
InvalidDatabaseException

if the database is corrupt or invalid

Return values
Isp

metadata()

public metadata() : Metadata
Tags
throws
InvalidArgumentException

if arguments are passed to the method

throws
BadMethodCallException

if the database has been closed

Return values
Metadata

object for the database

Search results