GeoIP2 PHP API v2.4.4
  • Namespace
  • Class

Namespaces

  • GeoIp2
    • Database
    • Exception
    • Model
    • Record
    • WebService
  • MaxMind
    • Db
      • Reader
  • PHP

Classes

  • GeoIp2\Database\Reader
  • GeoIp2\Model\AnonymousIp
  • GeoIp2\Model\City
  • GeoIp2\Model\ConnectionType
  • GeoIp2\Model\Country
  • GeoIp2\Model\Domain
  • GeoIp2\Model\Enterprise
  • GeoIp2\Model\Insights
  • GeoIp2\Model\Isp
  • GeoIp2\Record\AbstractPlaceRecord
  • GeoIp2\Record\AbstractRecord
  • GeoIp2\Record\City
  • GeoIp2\Record\Continent
  • GeoIp2\Record\Country
  • GeoIp2\Record\Location
  • GeoIp2\Record\MaxMind
  • GeoIp2\Record\Postal
  • GeoIp2\Record\RepresentedCountry
  • GeoIp2\Record\Subdivision
  • GeoIp2\Record\Traits
  • GeoIp2\WebService\Client
  • MaxMind\Db\Reader
  • MaxMind\Db\Reader\Decoder
  • MaxMind\Db\Reader\Metadata
  • MaxMind\Db\Reader\Util

Interfaces

  • GeoIp2\ProviderInterface

Exceptions

  • BadFunctionCallException
  • BadMethodCallException
  • Exception
  • GeoIp2\Exception\AddressNotFoundException
  • GeoIp2\Exception\AuthenticationException
  • GeoIp2\Exception\GeoIp2Exception
  • GeoIp2\Exception\HttpException
  • GeoIp2\Exception\InvalidRequestException
  • GeoIp2\Exception\OutOfQueriesException
  • InvalidArgumentException
  • LogicException
  • MaxMind\Db\Reader\InvalidDatabaseException
 1 <?php
 2 
 3 namespace MaxMind\Db\Reader;
 4 
 5 use MaxMind\Db\Reader\InvalidDatabaseException;
 6 
 7 class Util
 8 {
 9     public static function read($stream, $offset, $numberOfBytes)
10     {
11         if ($numberOfBytes == 0) {
12             return '';
13         }
14         if (fseek($stream, $offset) == 0) {
15             $value = fread($stream, $numberOfBytes);
16 
17             // We check that the number of bytes read is equal to the number
18             // asked for. We use ftell as getting the length of $value is
19             // much slower.
20             if (ftell($stream) - $offset === $numberOfBytes) {
21                 return $value;
22             }
23         }
24         throw new InvalidDatabaseException(
25             "The MaxMind DB file contains bad data"
26         );
27     }
28 }
29 
GeoIP2 PHP API v2.4.4 API documentation generated by ApiGen