11<?php
22
3+ declare (strict_types=1 );
4+
35namespace GeoIp2 \Database ;
46
57use GeoIp2 \Exception \AddressNotFoundException ;
@@ -48,8 +50,8 @@ class Reader implements ProviderInterface
4850 * is corrupt or invalid
4951 */
5052 public function __construct (
51- $ filename ,
52- $ locales = ['en ' ]
53+ string $ filename ,
54+ array $ locales = ['en ' ]
5355 ) {
5456 $ this ->dbReader = new DbReader ($ filename );
5557 $ this ->dbType = $ this ->dbReader ->metadata ()->databaseType ;
@@ -65,10 +67,8 @@ public function __construct(
6567 * not in the database
6668 * @throws \MaxMind\Db\Reader\InvalidDatabaseException if the database
6769 * is corrupt or invalid
68- *
69- * @return \GeoIp2\Model\City
7070 */
71- public function city ($ ipAddress )
71+ public function city (string $ ipAddress ): \ GeoIp2 \ Model \ City
7272 {
7373 return $ this ->modelFor ('City ' , 'City ' , $ ipAddress );
7474 }
@@ -82,10 +82,8 @@ public function city($ipAddress)
8282 * not in the database
8383 * @throws \MaxMind\Db\Reader\InvalidDatabaseException if the database
8484 * is corrupt or invalid
85- *
86- * @return \GeoIp2\Model\Country
8785 */
88- public function country ($ ipAddress )
86+ public function country (string $ ipAddress ): \ GeoIp2 \ Model \ Country
8987 {
9088 return $ this ->modelFor ('Country ' , 'Country ' , $ ipAddress );
9189 }
@@ -99,10 +97,8 @@ public function country($ipAddress)
9997 * not in the database
10098 * @throws \MaxMind\Db\Reader\InvalidDatabaseException if the database
10199 * is corrupt or invalid
102- *
103- * @return \GeoIp2\Model\AnonymousIp
104100 */
105- public function anonymousIp ($ ipAddress )
101+ public function anonymousIp (string $ ipAddress ): \ GeoIp2 \ Model \ AnonymousIp
106102 {
107103 return $ this ->flatModelFor (
108104 'AnonymousIp ' ,
@@ -120,10 +116,8 @@ public function anonymousIp($ipAddress)
120116 * not in the database
121117 * @throws \MaxMind\Db\Reader\InvalidDatabaseException if the database
122118 * is corrupt or invalid
123- *
124- * @return \GeoIp2\Model\Asn
125119 */
126- public function asn ($ ipAddress )
120+ public function asn (string $ ipAddress ): \ GeoIp2 \ Model \ Asn
127121 {
128122 return $ this ->flatModelFor (
129123 'Asn ' ,
@@ -141,10 +135,8 @@ public function asn($ipAddress)
141135 * not in the database
142136 * @throws \MaxMind\Db\Reader\InvalidDatabaseException if the database
143137 * is corrupt or invalid
144- *
145- * @return \GeoIp2\Model\ConnectionType
146138 */
147- public function connectionType ($ ipAddress )
139+ public function connectionType (string $ ipAddress ): \ GeoIp2 \ Model \ ConnectionType
148140 {
149141 return $ this ->flatModelFor (
150142 'ConnectionType ' ,
@@ -162,10 +154,8 @@ public function connectionType($ipAddress)
162154 * not in the database
163155 * @throws \MaxMind\Db\Reader\InvalidDatabaseException if the database
164156 * is corrupt or invalid
165- *
166- * @return \GeoIp2\Model\Domain
167157 */
168- public function domain ($ ipAddress )
158+ public function domain (string $ ipAddress ): \ GeoIp2 \ Model \ Domain
169159 {
170160 return $ this ->flatModelFor (
171161 'Domain ' ,
@@ -183,10 +173,8 @@ public function domain($ipAddress)
183173 * not in the database
184174 * @throws \MaxMind\Db\Reader\InvalidDatabaseException if the database
185175 * is corrupt or invalid
186- *
187- * @return \GeoIp2\Model\Enterprise
188176 */
189- public function enterprise ($ ipAddress )
177+ public function enterprise (string $ ipAddress ): \ GeoIp2 \ Model \ Enterprise
190178 {
191179 return $ this ->modelFor ('Enterprise ' , 'Enterprise ' , $ ipAddress );
192180 }
@@ -200,10 +188,8 @@ public function enterprise($ipAddress)
200188 * not in the database
201189 * @throws \MaxMind\Db\Reader\InvalidDatabaseException if the database
202190 * is corrupt or invalid
203- *
204- * @return \GeoIp2\Model\Isp
205191 */
206- public function isp ($ ipAddress )
192+ public function isp (string $ ipAddress ): \ GeoIp2 \ Model \ Isp
207193 {
208194 return $ this ->flatModelFor (
209195 'Isp ' ,
@@ -212,7 +198,7 @@ public function isp($ipAddress)
212198 );
213199 }
214200
215- private function modelFor ($ class , $ type , $ ipAddress )
201+ private function modelFor (string $ class , string $ type , string $ ipAddress )
216202 {
217203 list ($ record , $ prefixLen ) = $ this ->getRecord ($ class , $ type , $ ipAddress );
218204
@@ -224,7 +210,7 @@ private function modelFor($class, $type, $ipAddress)
224210 return new $ class ($ record , $ this ->locales );
225211 }
226212
227- private function flatModelFor ($ class , $ type , $ ipAddress )
213+ private function flatModelFor (string $ class , string $ type , string $ ipAddress )
228214 {
229215 list ($ record , $ prefixLen ) = $ this ->getRecord ($ class , $ type , $ ipAddress );
230216
@@ -235,7 +221,7 @@ private function flatModelFor($class, $type, $ipAddress)
235221 return new $ class ($ record );
236222 }
237223
238- private function getRecord ($ class , $ type , $ ipAddress )
224+ private function getRecord (string $ class , string $ type , string $ ipAddress ): array
239225 {
240226 if (strpos ($ this ->dbType , $ type ) === false ) {
241227 $ method = lcfirst ($ class );
@@ -272,15 +258,15 @@ private function getRecord($class, $type, $ipAddress)
272258 *
273259 * @return \MaxMind\Db\Reader\Metadata object for the database
274260 */
275- public function metadata ()
261+ public function metadata (): \ MaxMind \ Db \ Reader \ Metadata
276262 {
277263 return $ this ->dbReader ->metadata ();
278264 }
279265
280266 /**
281267 * Closes the GeoIP2 database and returns the resources to the system.
282268 */
283- public function close ()
269+ public function close (): void
284270 {
285271 $ this ->dbReader ->close ();
286272 }
0 commit comments