1
+ namespace GeoIP2\Database\Reader;
2
+ /**
3
+ * This class provides the metadata for the MaxMind DB file.
4
+ *
5
+ * @property int nodeCount This is an unsigned 32-bit integer indicating
6
+ * the number of nodes in the search tree.
7
+ * @property int recordSize This is an unsigned 16-bit integer. It
8
+ * indicates the number of bits in a record in the search tree. Note that each
9
+ * node consists of two records.
10
+ * @property int ipVersion This is an unsigned 16-bit integer which is
11
+ * always 4 or 6. It indicates whether the database contains IPv4 or IPv6
12
+ * address data.
13
+ * @property string databaseType This is a string that indicates the structure
14
+ * of each data record associated with an IP address. The actual definition of
15
+ * these structures is left up to the database creator.
16
+ * @property array languages An array of strings, each of which is a language
17
+ * code. A given record may contain data items that have been localized to
18
+ * some or all of these languages. This may be undefined.
19
+ * @property int binaryFormatMajorVersion This is an unsigned 16-bit
20
+ * integer indicating the major version number for the database's binary
21
+ * format.
22
+ * @property int binaryFormatMinorVersion This is an unsigned 16-bit
23
+ * integer indicating the minor version number for the database's binary format.
24
+ * @property int buildEpoch This is an unsigned 64-bit integer that
25
+ * contains the database build timestamp as a Unix epoch value.
26
+ * @property array description This key will always point to a map
27
+ * (associative array). The keys of that map will be language codes, and the
28
+ * values will be a description in that language as a UTF-8 string. May be
29
+ * undefined for some databases.
30
+ */
31
+ class Metadata
32
+ {
33
+ private binaryFormatMajorVersion;
34
+ private binaryFormatMinorVersion;
35
+ private buildEpoch;
36
+ private databaseType;
37
+ private description;
38
+ private ipVersion;
39
+ private languages;
40
+ private nodeByteSize;
41
+ private nodeCount;
42
+ private recordSize;
43
+ private searchTreeSize;
44
+
45
+ public function __construct (var metadata )
46
+ {
47
+ let this -> binaryFormatMajorVersion =
48
+ metadata[" binary_format_major_version" ];
49
+ let this -> binaryFormatMinorVersion =
50
+ metadata[" binary_format_minor_version" ];
51
+ let this -> buildEpoch = metadata[" build_epoch" ];
52
+ let this -> databaseType = metadata[" database_type" ];
53
+ let this -> languages = metadata[" languages" ];
54
+ let this -> description = metadata[" description" ];
55
+ let this -> ipVersion = metadata[" ip_version" ];
56
+ let this -> nodeCount = metadata[" node_count" ];
57
+ let this -> recordSize = metadata[" record_size" ];
58
+ let this -> nodeByteSize = this -> recordSize / 4 ;
59
+ let this -> searchTreeSize = this -> nodeCount * this -> nodeByteSize;
60
+ }
61
+ public function __get (var v )
62
+ {
63
+ return this -> {v};
64
+ }
65
+ }
0 commit comments