File tree Expand file tree Collapse file tree 2 files changed +10
-20
lines changed Expand file tree Collapse file tree 2 files changed +10
-20
lines changed Original file line number Diff line number Diff line change @@ -75,26 +75,10 @@ protected function updateMaxmindDatabase()
7575 */
7676 protected function gzdecode ($ data )
7777 {
78- do {
79- $ tempName = uniqid ('temp ' );
80- } while (file_exists ($ tempName ));
81-
82- if (file_put_contents ($ tempName , $ data )) {
83- try {
84- ob_start ();
85- @readgzfile ($ tempName );
86- $ uncompressed = ob_get_clean ();
87- } catch (Exception $ e ) {
88- $ ex = $ e ;
89- }
90-
91- unlink ($ tempName );
92-
93- if (isset ($ ex )) {
94- throw $ ex ;
95- }
96-
97- return $ uncompressed ;
78+ if (!function_exists ('gzdecode ' )) {
79+ return gzinflate (substr ($ data , 10 , -8 ));
9880 }
81+
82+ return gzdecode ($ data );
9983 }
10084}
Original file line number Diff line number Diff line change @@ -161,6 +161,8 @@ public function test_maxmind_database()
161161
162162 $ this ->assertEquals ('United Kingdom ' , $ geoip ->getCountry ());
163163
164+ $ this ->assertInstanceOf ('GeoIp2\Model\City ' , $ geoip ->getRaw ());
165+
164166 $ geoip = $ geoip ->setIp ($ this ->invalidIp );
165167
166168 $ this ->assertEquals ([
@@ -209,6 +211,10 @@ public function test_ip_api()
209211
210212 $ geoip = $ geoip ->setIp ($ this ->invalidIp );
211213
214+ $ this ->assertArraySubset ([
215+ 'status ' => 'fail ' ,
216+ ], $ geoip ->getRaw ());
217+
212218 $ this ->assertEquals ([
213219 'city ' => null ,
214220 'country ' => null ,
You can’t perform that action at this time.
0 commit comments