-
Notifications
You must be signed in to change notification settings - Fork 522
Implement Httplug #512
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Implement Httplug #512
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
b1b7063
Implement httplug
Baachi 294eccc
Fix tests and remove .puli from repo
Baachi a2b1d60
Remove php 5.4
Baachi 27dcf69
Rename to
Baachi 6996556
Add scrutinizr patches
Baachi 6ccb907
Use explicit @beta statements
Baachi 1697ef4
Minor fixes
Nyholm ec9de73
Updated dependencies
Nyholm dd23be6
Doc update and use latest discovery
Nyholm 454471a
Make sure we using phpuinit 4
Nyholm a514e08
updating deps
Nyholm 27eba31
typo
Nyholm 510cfbc
Using discovery 1.0
Nyholm 45a3ecf
Syntax update to make travis run again
Nyholm 056dce1
Fixed doc block alignment
Nyholm 902144d
Use PSR7 implementations instead of mocks
Nyholm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ composer.lock | |
composer.phar | ||
phpunit.xml | ||
php-cs-fixer.phar | ||
.puli/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,35 +10,81 @@ | |
|
||
namespace Geocoder\Provider; | ||
|
||
use Ivory\HttpAdapter\HttpAdapterInterface; | ||
use Http\Message\MessageFactory; | ||
use Http\Discovery\HttpClientDiscovery; | ||
use Http\Discovery\MessageFactoryDiscovery; | ||
use Http\Client\HttpClient; | ||
|
||
/** | ||
* @author William Durand <[email protected]> | ||
*/ | ||
class AbstractHttpProvider extends AbstractProvider | ||
{ | ||
/** | ||
* @var HttpAdapterInterface | ||
* @var HttpClient | ||
*/ | ||
private $adapter; | ||
private $client; | ||
|
||
/** | ||
* @param HttpAdapterInterface $adapter An HTTP adapter | ||
* @var MessageFactory | ||
*/ | ||
public function __construct(HttpAdapterInterface $adapter) | ||
private $messageFactory; | ||
|
||
/** | ||
* @param HttpClient $client | ||
* @param MessageFactory|null $factory | ||
*/ | ||
public function __construct(HttpClient $client, MessageFactory $factory = null) | ||
{ | ||
parent::__construct(); | ||
|
||
$this->adapter = $adapter; | ||
$this->client = $client; | ||
$this->messageFactory = $factory; | ||
} | ||
|
||
/** | ||
* Returns the HTTP adapter. | ||
* | ||
* @return HttpAdapterInterface | ||
* @return HttpClient | ||
*/ | ||
protected function getHttpClient() | ||
{ | ||
return $this->client; | ||
} | ||
|
||
/** | ||
* @return MessageFactory | ||
*/ | ||
public function getAdapter() | ||
protected function getMessageFactory() | ||
{ | ||
return $this->adapter; | ||
if ($this->messageFactory === null) { | ||
$this->messageFactory = MessageFactoryDiscovery::find(); | ||
} | ||
|
||
return $this->messageFactory; | ||
} | ||
|
||
/** | ||
* @param HttpClient $client | ||
* | ||
* @return AbstractHttpProvider | ||
*/ | ||
public function setClient(HttpClient $client) | ||
{ | ||
$this->client = $client; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* @param MessageFactory $messageFactory | ||
* | ||
* @return AbstractHttpProvider | ||
*/ | ||
public function setMessageFactory(MessageFactory $messageFactory) | ||
{ | ||
$this->messageFactory = $messageFactory; | ||
|
||
return $this; | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ | |
|
||
use Geocoder\Exception\NoResult; | ||
use Geocoder\Exception\UnsupportedOperation; | ||
use Ivory\HttpAdapter\HttpAdapterInterface; | ||
use Http\Client\HttpClient; | ||
|
||
/** | ||
* @author ALKOUM Dorian <[email protected]> | ||
|
@@ -40,13 +40,13 @@ class ArcGISOnline extends AbstractHttpProvider implements Provider | |
private $protocol; | ||
|
||
/** | ||
* @param HttpAdapterInterface $adapter An HTTP adapter | ||
* @param string $sourceCountry Country biasing (optional) | ||
* @param bool $useSsl Whether to use an SSL connection (optional) | ||
* @param HttpClient $client An HTTP adapter | ||
* @param string $sourceCountry Country biasing (optional) | ||
* @param bool $useSsl Whether to use an SSL connection (optional) | ||
*/ | ||
public function __construct(HttpAdapterInterface $adapter, $sourceCountry = null, $useSsl = false) | ||
public function __construct(HttpClient $client, $sourceCountry = null, $useSsl = false) | ||
{ | ||
parent::__construct($adapter); | ||
parent::__construct($client); | ||
|
||
$this->sourceCountry = $sourceCountry; | ||
$this->protocol = $useSsl ? 'https' : 'http'; | ||
|
@@ -167,8 +167,9 @@ private function buildQuery($query) | |
*/ | ||
private function executeQuery($query) | ||
{ | ||
$query = $this->buildQuery($query); | ||
$content = (string) $this->getAdapter()->get($query)->getBody(); | ||
$query = $this->buildQuery($query); | ||
$request = $this->getMessageFactory()->createRequest('GET', $query); | ||
$content = (string) $this->getHttpClient()->sendRequest($request)->getBody(); | ||
|
||
if (empty($content)) { | ||
throw new NoResult(sprintf('Could not execute query "%s".', $query)); | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ | |
use Geocoder\Exception\InvalidCredentials; | ||
use Geocoder\Exception\NoResult; | ||
use Geocoder\Exception\UnsupportedOperation; | ||
use Ivory\HttpAdapter\HttpAdapterInterface; | ||
use Http\Client\HttpClient; | ||
|
||
/** | ||
* @author David Guyon <[email protected]> | ||
|
@@ -38,13 +38,13 @@ class BingMaps extends AbstractHttpProvider implements LocaleAwareProvider | |
private $apiKey; | ||
|
||
/** | ||
* @param HttpAdapterInterface $adapter An HTTP adapter | ||
* @param string $apiKey An API key | ||
* @param string $locale A locale (optional) | ||
* @param HttpClient $client An HTTP adapter | ||
* @param string $apiKey An API key | ||
* @param string $locale A locale (optional) | ||
*/ | ||
public function __construct(HttpAdapterInterface $adapter, $apiKey, $locale = null) | ||
public function __construct(HttpClient $client, $apiKey, $locale = null) | ||
{ | ||
parent::__construct($adapter); | ||
parent::__construct($client); | ||
|
||
$this->apiKey = $apiKey; | ||
$this->locale = $locale; | ||
|
@@ -100,7 +100,8 @@ private function executeQuery($query) | |
$query = sprintf('%s&culture=%s', $query, str_replace('_', '-', $this->getLocale())); | ||
} | ||
|
||
$content = (string) $this->getAdapter()->get($query)->getBody(); | ||
$request = $this->getMessageFactory()->createRequest('GET', $query); | ||
$content = (string) $this->getHttpClient()->sendRequest($request)->getBody(); | ||
|
||
if (empty($content)) { | ||
throw new NoResult(sprintf('Could not execute query "%s".', $query)); | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ | |
use Geocoder\Exception\NoResult; | ||
use Geocoder\Exception\QuotaExceeded; | ||
use Geocoder\Exception\UnsupportedOperation; | ||
use Ivory\HttpAdapter\HttpAdapterInterface; | ||
use Http\Client\HttpClient; | ||
|
||
/** | ||
* @author Andrea Cristaudo <[email protected]> | ||
|
@@ -50,12 +50,12 @@ class GeoIPs extends AbstractHttpProvider implements Provider | |
private $apiKey; | ||
|
||
/** | ||
* @param HttpAdapterInterface $adapter An HTTP adapter | ||
* @param string $apiKey An API key | ||
* @param HttpClient $client An HTTP adapter | ||
* @param string $apiKey An API key | ||
*/ | ||
public function __construct(HttpAdapterInterface $adapter, $apiKey) | ||
public function __construct(HttpClient $client, $apiKey) | ||
{ | ||
parent::__construct($adapter); | ||
parent::__construct($client); | ||
|
||
$this->apiKey = $apiKey; | ||
} | ||
|
@@ -107,7 +107,8 @@ public function getName() | |
*/ | ||
private function executeQuery($query) | ||
{ | ||
$content = (string) $this->getAdapter()->get($query)->getBody(); | ||
$request = $this->getMessageFactory()->createRequest('GET', $query); | ||
$content = (string) $this->getHttpClient()->sendRequest($request)->getBody(); | ||
|
||
if (empty($content)) { | ||
throw new NoResult(sprintf('Invalid response from GeoIPs API for query "%s".', $query)); | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ | |
use Geocoder\Exception\NoResult; | ||
use Geocoder\Exception\UnsupportedOperation; | ||
use Geocoder\Model\AdminLevelCollection; | ||
use Ivory\HttpAdapter\HttpAdapterInterface; | ||
use Http\Client\HttpClient; | ||
|
||
/** | ||
* @author Giovanni Pirrotta <[email protected]> | ||
|
@@ -39,13 +39,13 @@ class Geonames extends AbstractHttpProvider implements LocaleAwareProvider | |
private $username; | ||
|
||
/** | ||
* @param HttpAdapterInterface $adapter An HTTP adapter | ||
* @param string $username Username login (Free registration at http://www.geonames.org/login) | ||
* @param string $locale A locale (optional) | ||
* @param HttpClient $client An HTTP adapter | ||
* @param string $username Username login (Free registration at http://www.geonames.org/login) | ||
* @param string $locale A locale (optional) | ||
*/ | ||
public function __construct(HttpAdapterInterface $adapter, $username, $locale = null) | ||
public function __construct(HttpClient $client, $username, $locale = null) | ||
{ | ||
parent::__construct($adapter); | ||
parent::__construct($client); | ||
|
||
$this->username = $username; | ||
$this->locale = $locale; | ||
|
@@ -102,7 +102,8 @@ private function executeQuery($query) | |
$query = sprintf('%s&lang=%s', $query, substr($this->getLocale(), 0, 2)); | ||
} | ||
|
||
$content = (string) $this->getAdapter()->get($query)->getBody(); | ||
$request = $this->getMessageFactory()->createRequest('GET', $query); | ||
$content = (string) $this->getHttpClient()->sendRequest($request)->getBody(); | ||
|
||
if (empty($content)) { | ||
throw new NoResult(sprintf('Could not execute query "%s".', $query)); | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ | |
use Geocoder\Exception\NoResult; | ||
use Geocoder\Exception\QuotaExceeded; | ||
use Geocoder\Exception\UnsupportedOperation; | ||
use Ivory\HttpAdapter\HttpAdapterInterface; | ||
use Http\Client\HttpClient; | ||
|
||
/** | ||
* @author William Durand <[email protected]> | ||
|
@@ -50,15 +50,15 @@ class GoogleMaps extends AbstractHttpProvider implements LocaleAwareProvider | |
private $apiKey; | ||
|
||
/** | ||
* @param HttpAdapterInterface $adapter An HTTP adapter | ||
* @param string $locale A locale (optional) | ||
* @param string $region Region biasing (optional) | ||
* @param bool $useSsl Whether to use an SSL connection (optional) | ||
* @param string $apiKey Google Geocoding API key (optional) | ||
* @param HttpClient $client An HTTP adapter | ||
* @param string $locale A locale (optional) | ||
* @param string $region Region biasing (optional) | ||
* @param bool $useSsl Whether to use an SSL connection (optional) | ||
* @param string $apiKey Google Geocoding API key (optional) | ||
*/ | ||
public function __construct(HttpAdapterInterface $adapter, $locale = null, $region = null, $useSsl = false, $apiKey = null) | ||
public function __construct(HttpClient $client, $locale = null, $region = null, $useSsl = false, $apiKey = null) | ||
{ | ||
parent::__construct($adapter); | ||
parent::__construct($client); | ||
|
||
$this->locale = $locale; | ||
$this->region = $region; | ||
|
@@ -136,7 +136,8 @@ protected function buildQuery($query) | |
private function executeQuery($query) | ||
{ | ||
$query = $this->buildQuery($query); | ||
$content = (string) $this->getAdapter()->get($query)->getBody(); | ||
$request = $this->getMessageFactory()->createRequest('GET', $query); | ||
$content = (string) $this->getHttpClient()->sendRequest($request)->getBody(); | ||
|
||
// Throw exception if invalid clientID and/or privateKey used with GoogleMapsBusinessProvider | ||
if (strpos($content, "Provided 'signature' is not valid for the provided client ID") !== false) { | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not define a bin directory as
/bin
and avoid executing/vendor/bin/phpunit
?