Skip to content

Commit 3fd7fe2

Browse files
author
Amrouche Hamza
committed
feature: remove all non-https support
1 parent 6490826 commit 3fd7fe2

File tree

11 files changed

+84
-212
lines changed

11 files changed

+84
-212
lines changed

src/Geocoder/Provider/ArcGISOnline.php

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,34 +22,28 @@ final class ArcGISOnline extends AbstractHttpProvider implements Provider
2222
/**
2323
* @var string
2424
*/
25-
const ENDPOINT_URL = '%s://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/find?text=%s';
25+
const ENDPOINT_URL = 'https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/find?text=%s';
2626

2727
/**
2828
* @var string
2929
*/
30-
const REVERSE_ENDPOINT_URL = '%s://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/reverseGeocode?location=%F,%F';
30+
const REVERSE_ENDPOINT_URL = 'https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/reverseGeocode?location=%F,%F';
3131

3232
/**
3333
* @var string
3434
*/
3535
private $sourceCountry;
3636

37-
/**
38-
* @var string
39-
*/
40-
private $protocol;
4137

4238
/**
4339
* @param HttpClient $client An HTTP adapter
4440
* @param string $sourceCountry Country biasing (optional)
45-
* @param bool $useSsl Whether to use an SSL connection (optional)
4641
*/
47-
public function __construct(HttpClient $client, $sourceCountry = null, $useSsl = false)
42+
public function __construct(HttpClient $client, $sourceCountry = null)
4843
{
4944
parent::__construct($client);
5045

5146
$this->sourceCountry = $sourceCountry;
52-
$this->protocol = $useSsl ? 'https' : 'http';
5347
}
5448

5549
/**
@@ -66,7 +60,7 @@ public function geocode($address)
6660
throw new NoResult('Invalid address.');
6761
}
6862

69-
$query = sprintf(self::ENDPOINT_URL, $this->protocol, urlencode($address));
63+
$query = sprintf(self::ENDPOINT_URL, urlencode($address));
7064
$json = $this->executeQuery($query);
7165

7266
// no result
@@ -112,7 +106,7 @@ public function geocode($address)
112106
*/
113107
public function reverse($latitude, $longitude)
114108
{
115-
$query = sprintf(self::REVERSE_ENDPOINT_URL, $this->protocol, $longitude, $latitude);
109+
$query = sprintf(self::REVERSE_ENDPOINT_URL, $longitude, $latitude);
116110
$json = $this->executeQuery($query);
117111

118112
if (property_exists($json, 'error')) {

src/Geocoder/Provider/BingMaps.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ final class BingMaps extends AbstractHttpProvider implements LocaleAwareProvider
2525
/**
2626
* @var string
2727
*/
28-
const GEOCODE_ENDPOINT_URL = 'http://dev.virtualearth.net/REST/v1/Locations/?maxResults=%d&q=%s&key=%s&incl=ciso2';
28+
const GEOCODE_ENDPOINT_URL = 'https://dev.virtualearth.net/REST/v1/Locations/?maxResults=%d&q=%s&key=%s&incl=ciso2';
2929

3030
/**
3131
* @var string
3232
*/
33-
const REVERSE_ENDPOINT_URL = 'http://dev.virtualearth.net/REST/v1/Locations/%F,%F?key=%s&incl=ciso2';
33+
const REVERSE_ENDPOINT_URL = 'https://dev.virtualearth.net/REST/v1/Locations/%F,%F?key=%s&incl=ciso2';
3434

3535
/**
3636
* @var string

src/Geocoder/Provider/GoogleMaps.php

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,11 @@
2222
*/
2323
final class GoogleMaps extends AbstractHttpProvider implements LocaleAwareProvider
2424
{
25-
/**
26-
* @var string
27-
*/
28-
const GEOCODE_ENDPOINT_URL = 'http://maps.googleapis.com/maps/api/geocode/json?address=%s';
29-
3025
/**
3126
* @var string
3227
*/
3328
const GEOCODE_ENDPOINT_URL_SSL = 'https://maps.googleapis.com/maps/api/geocode/json?address=%s';
3429

35-
/**
36-
* @var string
37-
*/
38-
const REVERSE_ENDPOINT_URL = 'http://maps.googleapis.com/maps/api/geocode/json?latlng=%F,%F';
39-
4030
/**
4131
* @var string
4232
*/
@@ -49,11 +39,6 @@ final class GoogleMaps extends AbstractHttpProvider implements LocaleAwareProvid
4939
*/
5040
private $region;
5141

52-
/**
53-
* @var bool
54-
*/
55-
private $useSsl;
56-
5742
/**
5843
* @var string
5944
*/
@@ -78,13 +63,12 @@ final class GoogleMaps extends AbstractHttpProvider implements LocaleAwareProvid
7863
* @param string $privateKey Your Private Key (optional)
7964
* @param string $locale A locale (optional)
8065
* @param string $region Region biasing (optional)
81-
* @param bool $useSsl Whether to use an SSL connection (optional)
8266
* @param string $apiKey Google Geocoding API key (optional)
8367
* @return GoogleMaps
8468
*/
85-
public static function business(HttpClient $client, $clientId, $privateKey = null, $locale = null, $region = null, $useSsl = false, $apiKey = null)
69+
public static function business(HttpClient $client, $clientId, $privateKey = null, $locale = null, $region = null, $apiKey = null)
8670
{
87-
$provider = new self($client, $locale, $region, $useSsl, $apiKey);
71+
$provider = new self($client, $locale, $region, $apiKey);
8872
$provider->clientId = $clientId;
8973
$provider->privateKey = $privateKey;
9074

@@ -95,16 +79,14 @@ public static function business(HttpClient $client, $clientId, $privateKey = nul
9579
* @param HttpClient $client An HTTP adapter
9680
* @param string $locale A locale (optional)
9781
* @param string $region Region biasing (optional)
98-
* @param bool $useSsl Whether to use an SSL connection (optional)
9982
* @param string $apiKey Google Geocoding API key (optional)
10083
*/
101-
public function __construct(HttpClient $client, $locale = null, $region = null, $useSsl = false, $apiKey = null)
84+
public function __construct(HttpClient $client, $locale = null, $region = null, $apiKey = null)
10285
{
10386
parent::__construct($client);
10487

10588
$this->locale = $locale;
10689
$this->region = $region;
107-
$this->useSsl = $useSsl;
10890
$this->apiKey = $apiKey;
10991
}
11092

@@ -119,10 +101,7 @@ public function geocode($address)
119101
throw new UnsupportedOperation('The GoogleMaps provider does not support IP addresses, only street addresses.');
120102
}
121103

122-
$query = sprintf(
123-
$this->useSsl ? self::GEOCODE_ENDPOINT_URL_SSL : self::GEOCODE_ENDPOINT_URL,
124-
rawurlencode($address)
125-
);
104+
$query = sprintf(self::GEOCODE_ENDPOINT_URL_SSL, rawurlencode($address));
126105

127106
return $this->executeQuery($query);
128107
}
@@ -132,10 +111,7 @@ public function geocode($address)
132111
*/
133112
public function reverse($latitude, $longitude)
134113
{
135-
$query = sprintf(
136-
$this->useSsl ? self::REVERSE_ENDPOINT_URL_SSL : self::REVERSE_ENDPOINT_URL,
137-
$latitude, $longitude
138-
);
114+
$query = sprintf(self::REVERSE_ENDPOINT_URL_SSL, $latitude, $longitude);
139115

140116
return $this->executeQuery($query);
141117
}

src/Geocoder/Provider/Mapzen.php

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
*/
1010
namespace Geocoder\Provider;
1111

12+
use Geocoder\Collection;
1213
use Geocoder\Exception\InvalidCredentials;
1314
use Geocoder\Exception\QuotaExceeded;
1415
use Geocoder\Exception\NoResult;
@@ -23,17 +24,12 @@ final class Mapzen extends AbstractHttpProvider
2324
/**
2425
* @var string
2526
*/
26-
const GEOCODE_ENDPOINT_URL = '%s://search.mapzen.com/v1/search?text=%s&key=%s&size=%d';
27+
const GEOCODE_ENDPOINT_URL = 'https://search.mapzen.com/v1/search?text=%s&key=%s&size=%d';
2728

2829
/**
2930
* @var string
3031
*/
31-
const REVERSE_ENDPOINT_URL = '%s://search.mapzen.com/v1/reverse?point.lat=%f&point.lon=%f&key=%s&size=%d';
32-
33-
/**
34-
* @var string
35-
*/
36-
private $scheme;
32+
const REVERSE_ENDPOINT_URL = 'https://search.mapzen.com/v1/reverse?point.lat=%f&point.lon=%f&key=%s&size=%d';
3733

3834
/**
3935
* @var string
@@ -43,14 +39,12 @@ final class Mapzen extends AbstractHttpProvider
4339
/**
4440
* @param HttpClient $client An HTTP adapter.
4541
* @param string $apiKey An API key.
46-
* @param bool $useSsl Whether to use an SSL connection (optional).
4742
*/
48-
public function __construct(HttpClient $client, $apiKey, $useSSL = true)
43+
public function __construct(HttpClient $client, $apiKey)
4944
{
5045
parent::__construct($client);
5146

5247
$this->apiKey = $apiKey;
53-
$this->scheme = $useSSL ? 'https' : 'http';
5448
}
5549

5650
/**
@@ -67,7 +61,7 @@ public function geocode($address)
6761
throw new UnsupportedOperation('The Mapzen provider does not support IP addresses, only street addresses.');
6862
}
6963

70-
$query = sprintf(self::GEOCODE_ENDPOINT_URL, $this->scheme, urlencode($address), $this->apiKey, $this->getLimit());
64+
$query = sprintf(self::GEOCODE_ENDPOINT_URL, urlencode($address), $this->apiKey, $this->getLimit());
7165

7266
return $this->executeQuery($query);
7367
}
@@ -81,7 +75,7 @@ public function reverse($latitude, $longitude)
8175
throw new InvalidCredentials('No API Key provided.');
8276
}
8377

84-
$query = sprintf(self::REVERSE_ENDPOINT_URL, $this->scheme, $latitude, $longitude, $this->apiKey, $this->getLimit());
78+
$query = sprintf(self::REVERSE_ENDPOINT_URL, $latitude, $longitude, $this->apiKey, $this->getLimit());
8579

8680
return $this->executeQuery($query);
8781
}
@@ -96,7 +90,7 @@ public function getName()
9690

9791
/**
9892
* @param $query
99-
* @return \Geocoder\Model\AddressCollection
93+
* @return Collection
10094
*/
10195
private function executeQuery($query)
10296
{

src/Geocoder/Provider/MaxMind.php

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
namespace Geocoder\Provider;
1212

13+
use Geocoder\Collection;
1314
use Geocoder\Exception\InvalidCredentials;
1415
use Geocoder\Exception\NoResult;
1516
use Geocoder\Exception\UnsupportedOperation;
@@ -30,11 +31,6 @@ final class MaxMind extends AbstractHttpProvider implements Provider
3031
*/
3132
const OMNI_SERVICE = 'e';
3233

33-
/**
34-
* @var string
35-
*/
36-
const GEOCODE_ENDPOINT_URL = 'http://geoip.maxmind.com/%s?l=%s&i=%s';
37-
3834
/**
3935
* @var string
4036
*/
@@ -50,24 +46,17 @@ final class MaxMind extends AbstractHttpProvider implements Provider
5046
*/
5147
private $service = null;
5248

53-
/**
54-
* @var bool
55-
*/
56-
private $useSsl = false;
57-
5849
/**
5950
* @param HttpClient $client An HTTP adapter.
6051
* @param string $apiKey An API key.
6152
* @param string $service The specific Maxmind service to use (optional).
62-
* @param bool $useSsl Whether to use an SSL connection (optional).
6353
*/
64-
public function __construct(HttpClient $client, $apiKey, $service = self::CITY_EXTENDED_SERVICE, $useSsl = false)
54+
public function __construct(HttpClient $client, $apiKey, $service = self::CITY_EXTENDED_SERVICE)
6555
{
6656
parent::__construct($client);
6757

6858
$this->apiKey = $apiKey;
6959
$this->service = $service;
70-
$this->useSsl = $useSsl;
7160
}
7261

7362
/**
@@ -87,10 +76,7 @@ public function geocode($address)
8776
return $this->returnResults([ $this->getLocalhostDefaults() ]);
8877
}
8978

90-
$query = sprintf(
91-
$this->useSsl ? self::GEOCODE_ENDPOINT_URL_SSL : self::GEOCODE_ENDPOINT_URL,
92-
$this->service, $this->apiKey, $address
93-
);
79+
$query = sprintf(self::GEOCODE_ENDPOINT_URL_SSL, $this->service, $this->apiKey, $address);
9480

9581
return $this->executeQuery($query);
9682
}
@@ -113,6 +99,8 @@ public function getName()
11399

114100
/**
115101
* @param string $query
102+
*
103+
* @return Collection
116104
*/
117105
private function executeQuery($query)
118106
{

src/Geocoder/Provider/OpenCage.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,10 @@ final class OpenCage extends AbstractHttpProvider implements LocaleAwareProvider
2424
/**
2525
* @var string
2626
*/
27-
const GEOCODE_ENDPOINT_URL = '%s://api.opencagedata.com/geocode/v1/json?key=%s&query=%s&limit=%d&pretty=1';
27+
const GEOCODE_ENDPOINT_URL = 'https://api.opencagedata.com/geocode/v1/json?key=%s&query=%s&limit=%d&pretty=1';
2828

2929
use LocaleTrait;
3030

31-
/**
32-
* @var string
33-
*/
34-
private $scheme;
35-
3631
/**
3732
* @var string
3833
*/
@@ -44,12 +39,11 @@ final class OpenCage extends AbstractHttpProvider implements LocaleAwareProvider
4439
* @param bool $useSsl Whether to use an SSL connection (optional).
4540
* @param string|null $locale A locale (optional).
4641
*/
47-
public function __construct(HttpClient $client, $apiKey, $useSsl = false, $locale = null)
42+
public function __construct(HttpClient $client, $apiKey, $locale = null)
4843
{
4944
parent::__construct($client);
5045

5146
$this->apiKey = $apiKey;
52-
$this->scheme = $useSsl ? 'https' : 'http';
5347
$this->locale = $locale;
5448
}
5549

@@ -67,7 +61,7 @@ public function geocode($address)
6761
throw new UnsupportedOperation('The OpenCage provider does not support IP addresses, only street addresses.');
6862
}
6963

70-
$query = sprintf(self::GEOCODE_ENDPOINT_URL, $this->scheme, $this->apiKey, urlencode($address), $this->getLimit());
64+
$query = sprintf(self::GEOCODE_ENDPOINT_URL, $this->apiKey, urlencode($address), $this->getLimit());
7165

7266
return $this->executeQuery($query);
7367
}

0 commit comments

Comments
 (0)