Update docblocks
This commit is contained in:
@@ -4,6 +4,9 @@ declare(strict_types=1);
|
||||
|
||||
namespace Pcm\GeocodeBundle\Interface\Entity;
|
||||
|
||||
/**
|
||||
* Defines latitude and longitude getters and setters
|
||||
*/
|
||||
interface GeocodeInterface
|
||||
{
|
||||
public function getLatitude(): ?float;
|
||||
@@ -14,5 +17,9 @@ interface GeocodeInterface
|
||||
|
||||
public function setLongitude(float $lon): self;
|
||||
|
||||
/**
|
||||
* @return bool True if both latitude and longitude is set
|
||||
*/
|
||||
public function isGeocoded(): bool;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,9 @@ use Pcm\GeocodeBundle\Model\GeoCoordinates;
|
||||
use Symfony\Contracts\HttpClient\HttpClientInterface;
|
||||
use Symfony\Contracts\HttpClient\ResponseInterface;
|
||||
|
||||
/**
|
||||
* Find the geo-coordinates of a postcode
|
||||
*/
|
||||
final class Geocoder
|
||||
{
|
||||
private const string API_URL = "https://nominatim.openstreetmap.org/search";
|
||||
@@ -17,12 +20,16 @@ final class Geocoder
|
||||
public function __construct(private HttpClientInterface $client) {}
|
||||
|
||||
/**
|
||||
* Convert a postcode into latitude and longitude. Returns null if conversion failed.
|
||||
* Find and return the geo-coordinates of a postcode
|
||||
*
|
||||
* @param string $postcode
|
||||
* @return null|GeoCoordinates
|
||||
*
|
||||
* @return GeoCoordinates
|
||||
*
|
||||
* @throws NoResultsFoundException when no results were found for the provided postcode
|
||||
* @throws ApiErrorException when the API response contains an error
|
||||
*/
|
||||
public function geocodePostcode(string $postcode): ?GeoCoordinates
|
||||
public function geocodePostcode(string $postcode): GeoCoordinates
|
||||
{
|
||||
$client = $this->createClient();
|
||||
$response = $this->makeApiRequest($client, $postcode);
|
||||
|
||||
@@ -43,11 +43,6 @@ trait GeocodeTrait
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if both latitude and longitude have been set
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isGeocoded(): bool
|
||||
{
|
||||
return null !== $this->getLatitude() && null !== $this->getLongitude();
|
||||
|
||||
Reference in New Issue
Block a user