Skip to content

Commit fcd816b

Browse files
author
Terje Bråten
committed
Changes because we are not allowed to change the common files
1 parent ba4d010 commit fcd816b

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

src/Provider/MapQuest/MapQuest.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
use Geocoder\Collection;
1616
use Geocoder\Exception\InvalidArgument;
1717
use Geocoder\Exception\InvalidCredentials;
18+
use Geocoder\Exception\InvalidServerResponse;
19+
use Geocoder\Exception\QuotaExceeded;
1820
use Geocoder\Exception\UnsupportedOperation;
1921
use Geocoder\Http\Provider\AbstractHttpProvider;
2022
use Geocoder\Location;
@@ -27,6 +29,7 @@
2729
use Geocoder\Query\ReverseQuery;
2830
use Geocoder\Provider\Provider;
2931
use Http\Client\HttpClient;
32+
use Psr\Http\Message\ResponseInterface;
3033

3134
/**
3235
* @author William Durand <william.durand1@gmail.com>
@@ -394,4 +397,23 @@ private function mapBoundsToArray(Bounds $bounds)
394397
'lr' => [static::KEY_LAT => $bounds->getSouth(), static::KEY_LNG => $bounds->getEast()],
395398
];
396399
}
400+
401+
protected function parseHttpResponse(ResponseInterface $response, string $url): string
402+
{
403+
$statusCode = $response->getStatusCode();
404+
if (401 === $statusCode || 403 === $statusCode) {
405+
throw new InvalidCredentials();
406+
} elseif (429 === $statusCode) {
407+
throw new QuotaExceeded();
408+
} elseif ($statusCode >= 300) {
409+
throw InvalidServerResponse::create($url, $statusCode);
410+
}
411+
412+
$body = (string)$response->getBody();
413+
if (empty($body)) {
414+
throw InvalidServerResponse::emptyResponse($url);
415+
}
416+
417+
return $body;
418+
}
397419
}

src/Provider/MapQuest/Tests/MapQuestTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public function testGeocodeWithRealSpecificAddress()
119119

120120
$addressBuilder = new AddressBuilder('tests');
121121
$addressBuilder
122-
->setStreetNumber(4868)
122+
->setStreetNumber('4868')
123123
->setStreetName('Payne Rd')
124124
->setLocality('Nashville')
125125
->setSubLocality('Antioch')

0 commit comments

Comments
 (0)