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()
125
125
'country ' => 'localhost ' ,
126
126
);
127
127
}
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
+ }
128
140
}
Original file line number Diff line number Diff line change @@ -58,7 +58,7 @@ public function getGeocodedData($address)
58
58
$ timezone = @geoip_time_zone_by_country_and_region ($ results ['country_code ' ], $ results ['region ' ]) ?: null ;
59
59
$ region = @geoip_region_name_by_code ($ results ['country_code ' ], $ results ['region ' ]) ?: $ results ['region ' ];
60
60
61
- $ results = array_merge ($ this ->getDefaults (), array (
61
+ return $ this -> fixEncoding ( array_merge ($ this ->getDefaults (), array (
62
62
'latitude ' => $ results ['latitude ' ],
63
63
'longitude ' => $ results ['longitude ' ],
64
64
'city ' => $ results ['city ' ],
@@ -68,13 +68,7 @@ public function getGeocodedData($address)
68
68
'country ' => $ results ['country_name ' ],
69
69
'countryCode ' => $ results ['country_code ' ],
70
70
'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
+ )));
78
72
}
79
73
80
74
/**
Original file line number Diff line number Diff line change @@ -75,20 +75,14 @@ public function getGeocodedData($address)
75
75
throw new NoResultException (sprintf ('No results found for IP address %s ' , $ address ));
76
76
}
77
77
78
- $ results = array_merge ($ this ->getDefaults (), array (
78
+ return $ this -> fixEncoding ( array_merge ($ this ->getDefaults (), array (
79
79
'countryCode ' => $ geoIpRecord ->country_code ,
80
80
'country ' => $ geoIpRecord ->country_name ,
81
81
'region ' => $ geoIpRecord ->region ,
82
82
'city ' => $ geoIpRecord ->city ,
83
83
'latitude ' => $ geoIpRecord ->latitude ,
84
84
'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
+ )));
92
86
}
93
87
94
88
/**
You can’t perform that action at this time.
0 commit comments