Differences Between: [Versions 310 and 403] [Versions 39 and 403]
1 <?php 2 3 declare(strict_types=1); 4 5 namespace MaxMind\Db\Reader; 6 7 use ArgumentCountError; 8 9 /** 10 * This class provides the metadata for the MaxMind DB file. 11 */ 12 class Metadata 13 { 14 /** 15 * This is an unsigned 16-bit integer indicating the major version number 16 * for the database's binary format. 17 * 18 * @var int 19 */ 20 public $binaryFormatMajorVersion; 21 /** 22 * This is an unsigned 16-bit integer indicating the minor version number 23 * for the database's binary format. 24 * 25 * @var int 26 */ 27 public $binaryFormatMinorVersion; 28 /** 29 * This is an unsigned 64-bit integer that contains the database build 30 * timestamp as a Unix epoch value. 31 * 32 * @var int 33 */ 34 public $buildEpoch; 35 /** 36 * This is a string that indicates the structure of each data record 37 * associated with an IP address. The actual definition of these 38 * structures is left up to the database creator. 39 * 40 * @var string 41 */ 42 public $databaseType; 43 /** 44 * This key will always point to a map (associative array). The keys of 45 * that map will be language codes, and the values will be a description 46 * in that language as a UTF-8 string. May be undefined for some 47 * databases. 48 * 49 * @var array 50 */ 51 public $description; 52 /** 53 * This is an unsigned 16-bit integer which is always 4 or 6. It indicates 54 * whether the database contains IPv4 or IPv6 address data. 55 * 56 * @var int 57 */ 58 public $ipVersion; 59 /** 60 * An array of strings, each of which is a language code. A given record 61 * may contain data items that have been localized to some or all of 62 * these languages. This may be undefined. 63 * 64 * @var array 65 */ 66 public $languages; 67 /** 68 * @var int 69 */ 70 public $nodeByteSize; 71 /** 72 * This is an unsigned 32-bit integer indicating the number of nodes in 73 * the search tree. 74 * 75 * @var int 76 */ 77 public $nodeCount; 78 /** 79 * This is an unsigned 16-bit integer. It indicates the number of bits in a 80 * record in the search tree. Note that each node consists of two records. 81 * 82 * @var int 83 */ 84 public $recordSize; 85 /** 86 * @var int 87 */ 88 public $searchTreeSize; 89 90 public function __construct(array $metadata) 91 { 92 if (\func_num_args() !== 1) { 93 throw new ArgumentCountError( 94 sprintf('%s() expects exactly 1 parameter, %d given', __METHOD__, \func_num_args()) 95 ); 96 } 97 98 $this->binaryFormatMajorVersion = 99 $metadata['binary_format_major_version']; 100 $this->binaryFormatMinorVersion = 101 $metadata['binary_format_minor_version']; 102 $this->buildEpoch = $metadata['build_epoch']; 103 $this->databaseType = $metadata['database_type']; 104 $this->languages = $metadata['languages']; 105 $this->description = $metadata['description']; 106 $this->ipVersion = $metadata['ip_version']; 107 $this->nodeCount = $metadata['node_count']; 108 $this->recordSize = $metadata['record_size']; 109 $this->nodeByteSize = $this->recordSize / 4; 110 $this->searchTreeSize = $this->nodeCount * $this->nodeByteSize; 111 } 112 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body