File tree Expand file tree Collapse file tree 6 files changed +22
-15
lines changed Expand file tree Collapse file tree 6 files changed +22
-15
lines changed Original file line number Diff line number Diff line change @@ -71,6 +71,8 @@ $config = [
7171 'driver' => 'ip-api',
7272 'ip-api' => [
7373 'key' => 'YOUR IP-API KEY',
74+ // optionally set secure (https) connection (default: false)
75+ 'secure' => true
7476 ],
7577];
7678```
Original file line number Diff line number Diff line change @@ -71,8 +71,13 @@ protected function getUrl($ip)
7171 */
7272 protected function create ()
7373 {
74+ $ protocol = 'http: ' ;
75+ if (array_get ($ this ->config , 'secure ' , false )) {
76+ $ protocol = 'https: ' ;
77+ }
78+
7479 if (array_get ($ this ->config , 'key ' , false )) {
75- $ this ->baseUrl = ' http ://pro.ip-api.com/json/ ' ;
80+ $ this ->baseUrl = $ protocol . ' ://pro.ip-api.com/json/ ' ;
7681 $ this ->key = array_get ($ this ->config , 'key ' );
7782 }
7883
Original file line number Diff line number Diff line change @@ -39,18 +39,6 @@ public function getDriver()
3939 return $ this ->driver ;
4040 }
4141
42- /**
43- * Setter for driver
44- *
45- * @return \PulkitJalan\GeoIP\GeoIP
46- */
47- public function setDriver ($ driver )
48- {
49- $ this ->driver = $ driver ;
50-
51- return $ this ;
52- }
53-
5442 /**
5543 * Set ip
5644 *
Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ public function getDriver($driver = null)
3333 $ method = 'create ' .ucfirst (camel_case ($ driver )).'Driver ' ;
3434
3535 if (!method_exists ($ this , $ method )) {
36- throw new InvalidDriverException (sprintf ('Driver [%s] does not exist . ' , $ driver ));
36+ throw new InvalidDriverException (sprintf ('Driver [%s] not supported . ' , $ driver ));
3737 }
3838
3939 return $ this ->{$ method }(array_get ($ this ->config , $ driver , []));
Original file line number Diff line number Diff line change 4848 |--------------------------------------------------------------------------
4949 */
5050 'key ' => '' ,
51+
52+ /*
53+ |--------------------------------------------------------------------------
54+ | IP-API Secure connection
55+ |--------------------------------------------------------------------------
56+ |
57+ | Use https instead of http
58+ | Only applicable with the Pro service
59+ |
60+ */
61+ 'secure ' => false ,
5162 ],
5263];
Original file line number Diff line number Diff line change @@ -124,6 +124,7 @@ public function testIpApiProException()
124124 'driver ' => 'ip-api ' ,
125125 'ip-api ' => [
126126 'key ' => 'test ' ,
127+ 'secure ' => true ,
127128 ],
128129 ];
129130
@@ -132,7 +133,7 @@ public function testIpApiProException()
132133 $ geoip = new \PulkitJalan \GeoIP \GeoIP ($ config );
133134 $ geoip = $ geoip ->setIP ($ this ->validIP );
134135
135- $ this -> assertEquals ( $ geoip ->getCountry (), '' );
136+ $ geoip ->get ( );
136137 }
137138
138139 public function testIpApi ()
You can’t perform that action at this time.
0 commit comments