Skip to content

Commit 129e9dd

Browse files
authored
Merge pull request #29 from programmatordev/OPA-36-improve-geocoding-method-names
Improve Geocoding method names
2 parents 6a107f4 + 68b2425 commit 129e9dd

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

src/Endpoint/GeocodingEndpoint.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class GeocodingEndpoint extends AbstractEndpoint
4343
* @throws UnexpectedErrorException
4444
* @throws ValidationException
4545
*/
46-
public function getCoordinatesByLocationName(string $locationName, int $numResults = self::NUM_RESULTS): array
46+
public function getByLocationName(string $locationName, int $numResults = self::NUM_RESULTS): array
4747
{
4848
$this->validateBlank('locationName', $locationName);
4949
$this->validateGreaterThan('numResults', $numResults, 0);
@@ -69,7 +69,7 @@ public function getCoordinatesByLocationName(string $locationName, int $numResul
6969
* @throws UnexpectedErrorException
7070
* @throws ValidationException
7171
*/
72-
public function getCoordinatesByZipCode(string $zipCode, string $countryCode): ZipCodeLocation
72+
public function getByZipCode(string $zipCode, string $countryCode): ZipCodeLocation
7373
{
7474
$this->validateBlank('zipCode', $zipCode);
7575
$this->validateBlank('countryCode', $countryCode);
@@ -95,7 +95,7 @@ public function getCoordinatesByZipCode(string $zipCode, string $countryCode): Z
9595
* @throws UnexpectedErrorException
9696
* @throws ValidationException
9797
*/
98-
public function getLocationNameByCoordinates(float $latitude, float $longitude, int $numResults = self::NUM_RESULTS): array
98+
public function getByCoordinate(float $latitude, float $longitude, int $numResults = self::NUM_RESULTS): array
9999
{
100100
$this->validateCoordinate($latitude, $longitude);
101101
$this->validateGreaterThan('numResults', $numResults, 0);

tests/GeocodingEndpointTest.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
class GeocodingEndpointTest extends AbstractTest
1515
{
16-
public function testGeocodingGetCoordinatesByLocationName()
16+
public function testGeocodingGetByLocationName()
1717
{
1818
$this->mockHttpClient->addResponse(
1919
new Response(
@@ -22,17 +22,17 @@ public function testGeocodingGetCoordinatesByLocationName()
2222
)
2323
);
2424

25-
$response = $this->getApi()->getGeocoding()->getCoordinatesByLocationName('lisbon, pt');
25+
$response = $this->getApi()->getGeocoding()->getByLocationName('lisbon, pt');
2626
$this->assertLocationListResponse($response);
2727
}
2828

29-
public function testGeocodingGetCoordinatesByLocationNameWithBlankValue()
29+
public function testGeocodingGetByLocationNameWithBlankValue()
3030
{
3131
$this->expectException(ValidationException::class);
32-
$this->getApi()->getGeocoding()->getCoordinatesByLocationName('');
32+
$this->getApi()->getGeocoding()->getByLocationName('');
3333
}
3434

35-
public function testGeocodingGetCoordinatesByZipCode()
35+
public function testGeocodingGetByZipCode()
3636
{
3737
$this->mockHttpClient->addResponse(
3838
new Response(
@@ -41,7 +41,7 @@ public function testGeocodingGetCoordinatesByZipCode()
4141
)
4242
);
4343

44-
$response = $this->getApi()->getGeocoding()->getCoordinatesByZipCode('1000-001', 'pt');
44+
$response = $this->getApi()->getGeocoding()->getByZipCode('1000-001', 'pt');
4545
$this->assertInstanceOf(ZipCodeLocation::class, $response);
4646

4747
$this->assertSame('1000-001', $response->getZipCode());
@@ -54,20 +54,20 @@ public function testGeocodingGetCoordinatesByZipCode()
5454
$this->assertSame(-9.1333, $coordinate->getLongitude());
5555
}
5656

57-
#[DataProvider('provideGeocodingGetCoordinatesByZipCodeWithBlankValueData')]
58-
public function testGeocodingGetCoordinatesByZipCodeWithBlankValue(string $zipCode, string $countryCode)
57+
#[DataProvider('provideGeocodingGetByZipCodeWithBlankValueData')]
58+
public function testGeocodingGetByZipCodeWithBlankValue(string $zipCode, string $countryCode)
5959
{
6060
$this->expectException(ValidationException::class);
61-
$this->getApi()->getGeocoding()->getCoordinatesByZipCode($zipCode, $countryCode);
61+
$this->getApi()->getGeocoding()->getByZipCode($zipCode, $countryCode);
6262
}
6363

64-
public static function provideGeocodingGetCoordinatesByZipCodeWithBlankValueData(): \Generator
64+
public static function provideGeocodingGetByZipCodeWithBlankValueData(): \Generator
6565
{
6666
yield 'blank zip code' => ['', 'pt'];
6767
yield 'blank country code' => ['1000-100', ''];
6868
}
6969

70-
public function testGeocodingGetLocationNameByCoordinates()
70+
public function testGeocodingGetByCoordinate()
7171
{
7272
$this->mockHttpClient->addResponse(
7373
new Response(
@@ -76,29 +76,29 @@ public function testGeocodingGetLocationNameByCoordinates()
7676
)
7777
);
7878

79-
$response = $this->getApi()->getGeocoding()->getLocationNameByCoordinates(38.7077507, -9.1365919);
79+
$response = $this->getApi()->getGeocoding()->getByCoordinate(38.7077507, -9.1365919);
8080
$this->assertLocationListResponse($response);
8181
}
8282

8383
#[DataProviderExternal(InvalidParamDataProvider::class, 'provideInvalidCoordinateData')]
84-
public function testGeocodingGetLocationNameByCoordinatesWithInvalidCoordinate(
84+
public function testGeocodingGetByCoordinateWithInvalidCoordinate(
8585
float $latitude,
8686
float $longitude,
8787
string $expectedException
8888
)
8989
{
9090
$this->expectException($expectedException);
91-
$this->getApi()->getGeocoding()->getLocationNameByCoordinates($latitude, $longitude);
91+
$this->getApi()->getGeocoding()->getByCoordinate($latitude, $longitude);
9292
}
9393

9494
#[DataProviderExternal(InvalidParamDataProvider::class, 'provideInvalidNumResultsData')]
95-
public function testGeocodingGetLocationNameByCoordinatesWithInvalidNumResults(
95+
public function testGeocodingGetByCoordinateWithInvalidNumResults(
9696
int $numResults,
9797
string $expectedException
9898
)
9999
{
100100
$this->expectException($expectedException);
101-
$this->getApi()->getGeocoding()->getLocationNameByCoordinates(38.7077507, -9.1365919, $numResults);
101+
$this->getApi()->getGeocoding()->getByCoordinate(38.7077507, -9.1365919, $numResults);
102102
}
103103

104104
/**

0 commit comments

Comments
 (0)