File tree Expand file tree Collapse file tree 3 files changed +16
-16
lines changed Expand file tree Collapse file tree 3 files changed +16
-16
lines changed Original file line number Diff line number Diff line change @@ -125,4 +125,16 @@ protected function getLocalhostDefaults()
125125 'country ' => 'localhost ' ,
126126 );
127127 }
128+
129+ /**
130+ * @param array $results
131+ *
132+ * @return array
133+ */
134+ protected function fixEncoding (array $ results )
135+ {
136+ return array_map (function ($ value ) {
137+ return is_string ($ value ) ? utf8_encode ($ value ) : $ value ;
138+ }, $ results );
139+ }
128140}
Original file line number Diff line number Diff line change @@ -58,7 +58,7 @@ public function getGeocodedData($address)
5858 $ timezone = @geoip_time_zone_by_country_and_region ($ results ['country_code ' ], $ results ['region ' ]) ?: null ;
5959 $ region = @geoip_region_name_by_code ($ results ['country_code ' ], $ results ['region ' ]) ?: $ results ['region ' ];
6060
61- $ results = array_merge ($ this ->getDefaults (), array (
61+ return $ this -> fixEncoding ( array_merge ($ this ->getDefaults (), array (
6262 'latitude ' => $ results ['latitude ' ],
6363 'longitude ' => $ results ['longitude ' ],
6464 'city ' => $ results ['city ' ],
@@ -68,13 +68,7 @@ public function getGeocodedData($address)
6868 'country ' => $ results ['country_name ' ],
6969 'countryCode ' => $ results ['country_code ' ],
7070 'timezone ' => $ timezone ,
71- ));
72-
73- $ results = array_map (function ($ value ) {
74- return is_string ($ value ) ? utf8_encode ($ value ) : $ value ;
75- }, $ results );
76-
77- return $ results ;
71+ )));
7872 }
7973
8074 /**
Original file line number Diff line number Diff line change @@ -75,20 +75,14 @@ public function getGeocodedData($address)
7575 throw new NoResultException (sprintf ('No results found for IP address %s ' , $ address ));
7676 }
7777
78- $ results = array_merge ($ this ->getDefaults (), array (
78+ return $ this -> fixEncoding ( array_merge ($ this ->getDefaults (), array (
7979 'countryCode ' => $ geoIpRecord ->country_code ,
8080 'country ' => $ geoIpRecord ->country_name ,
8181 'region ' => $ geoIpRecord ->region ,
8282 'city ' => $ geoIpRecord ->city ,
8383 'latitude ' => $ geoIpRecord ->latitude ,
8484 'longitude ' => $ geoIpRecord ->longitude ,
85- ));
86-
87- $ results = array_map (function ($ value ) {
88- return is_string ($ value ) ? utf8_encode ($ value ) : $ value ;
89- }, $ results );
90-
91- return $ results ;
85+ )));
9286 }
9387
9488 /**
You can’t perform that action at this time.
0 commit comments