From bddd2eee4ee80c955160c2585b42fb8de6af4b13 Mon Sep 17 00:00:00 2001 From: Tobias Nyholm Date: Thu, 8 Sep 2016 16:52:54 +0200 Subject: [PATCH 01/21] Creating interfaces to be more SOLID --- src/Geocoder/Dumper/Dumper.php | 5 +- src/Geocoder/Dumper/GeoJson.php | 3 +- src/Geocoder/Dumper/Gpx.php | 9 +- src/Geocoder/Dumper/Kml.php | 3 +- src/Geocoder/Dumper/Wkb.php | 3 +- src/Geocoder/Dumper/Wkt.php | 3 +- src/Geocoder/Formatter/StringFormatter.php | 11 +- src/Geocoder/Geocoder.php | 6 +- src/Geocoder/GeocoderResult.php | 46 ++++++++ src/Geocoder/Model/Address.php | 26 ++--- src/Geocoder/Model/AddressCollection.php | 17 +-- src/Geocoder/Model/AddressFactory.php | 6 +- src/Geocoder/Model/AdminLevel.php | 14 +-- src/Geocoder/Model/AdminLevelCollection.php | 12 +- .../Model/AdminLevelCollectionInterface.php | 48 ++++++++ src/Geocoder/Model/AdminLevelInterface.php | 37 ++++++ src/Geocoder/Model/Bounds.php | 2 +- src/Geocoder/Model/BoundsInterface.php | 51 +++++++++ src/Geocoder/Model/Coordinates.php | 2 +- src/Geocoder/Model/CoordinatesInterface.php | 23 ++++ src/Geocoder/Model/Country.php | 14 +-- src/Geocoder/Model/CountryInterface.php | 30 +++++ src/Geocoder/Model/Position.php | 107 ++++++++++++++++++ src/Geocoder/Provider/AbstractProvider.php | 3 +- src/Geocoder/Provider/FreeGeoIp.php | 5 +- src/Geocoder/Provider/Geonames.php | 4 +- src/Geocoder/Provider/HostIp.php | 3 +- src/Geocoder/Provider/IpInfoDb.php | 3 +- src/Geocoder/Provider/OpenCage.php | 3 +- src/Geocoder/ProviderAggregator.php | 6 +- .../Tests/Provider/ArcGISOnlineTest.php | 15 +-- .../Geocoder/Tests/Provider/BingMapsTest.php | 21 ++-- .../Geocoder/Tests/Provider/FreeGeoIpTest.php | 9 +- tests/Geocoder/Tests/Provider/GeoIP2Test.php | 5 +- tests/Geocoder/Tests/Provider/GeoIPsTest.php | 9 +- tests/Geocoder/Tests/Provider/GeoipTest.php | 3 +- .../Geocoder/Tests/Provider/GeonamesTest.php | 23 ++-- .../Tests/Provider/GoogleMapsTest.php | 24 ++-- tests/Geocoder/Tests/Provider/HostIpTest.php | 6 +- .../Geocoder/Tests/Provider/IpInfoDbTest.php | 7 +- .../Geocoder/Tests/Provider/MapQuestTest.php | 15 +-- .../Tests/Provider/MaxMindBinaryTest.php | 8 +- tests/Geocoder/Tests/Provider/MaxMindTest.php | 20 ++-- .../Geocoder/Tests/Provider/NominatimTest.php | 32 +++--- .../Geocoder/Tests/Provider/OpenCageTest.php | 19 ++-- tests/Geocoder/Tests/Provider/TomTomTest.php | 21 ++-- tests/Geocoder/Tests/Provider/YandexTest.php | 37 +++--- 47 files changed, 561 insertions(+), 218 deletions(-) create mode 100644 src/Geocoder/GeocoderResult.php create mode 100644 src/Geocoder/Model/AdminLevelCollectionInterface.php create mode 100644 src/Geocoder/Model/AdminLevelInterface.php create mode 100644 src/Geocoder/Model/BoundsInterface.php create mode 100644 src/Geocoder/Model/CoordinatesInterface.php create mode 100644 src/Geocoder/Model/CountryInterface.php create mode 100644 src/Geocoder/Model/Position.php diff --git a/src/Geocoder/Dumper/Dumper.php b/src/Geocoder/Dumper/Dumper.php index 4357d2960..98f807880 100644 --- a/src/Geocoder/Dumper/Dumper.php +++ b/src/Geocoder/Dumper/Dumper.php @@ -11,6 +11,7 @@ namespace Geocoder\Dumper; use Geocoder\Model\Address; +use Geocoder\Model\Position; /** * @author William Durand @@ -21,9 +22,9 @@ interface Dumper * Dumps an `Address` object as a string representation of * the implemented format. * - * @param Address $address + * @param Position $address * * @return string */ - public function dump(Address $address); + public function dump(Position $address); } diff --git a/src/Geocoder/Dumper/GeoJson.php b/src/Geocoder/Dumper/GeoJson.php index f23b818d3..f84c39eb2 100644 --- a/src/Geocoder/Dumper/GeoJson.php +++ b/src/Geocoder/Dumper/GeoJson.php @@ -11,6 +11,7 @@ namespace Geocoder\Dumper; use Geocoder\Model\Address; +use Geocoder\Model\Position; /** * @author Jan Sorgalla @@ -20,7 +21,7 @@ class GeoJson implements Dumper /** * {@inheritDoc} */ - public function dump(Address $address) + public function dump(Position $address) { $properties = array_filter($address->toArray(), function ($value) { return !empty($value); diff --git a/src/Geocoder/Dumper/Gpx.php b/src/Geocoder/Dumper/Gpx.php index 4ce63e877..37887957b 100644 --- a/src/Geocoder/Dumper/Gpx.php +++ b/src/Geocoder/Dumper/Gpx.php @@ -12,6 +12,7 @@ use Geocoder\Geocoder; use Geocoder\Model\Address; +use Geocoder\Model\Position; /** * @author William Durand @@ -19,11 +20,11 @@ class Gpx implements Dumper { /** - * @param Address $address + * @param Position $address * * @return string */ - public function dump(Address $address) + public function dump(Position $address) { $gpx = sprintf(<< @@ -63,11 +64,11 @@ public function dump(Address $address) } /** - * @param Address $address + * @param Position $address * * @return string */ - protected function formatName(Address $address) + protected function formatName(Position $address) { $name = []; $array = $address->toArray(); diff --git a/src/Geocoder/Dumper/Kml.php b/src/Geocoder/Dumper/Kml.php index 7f4c889b7..89b4f320e 100644 --- a/src/Geocoder/Dumper/Kml.php +++ b/src/Geocoder/Dumper/Kml.php @@ -11,6 +11,7 @@ namespace Geocoder\Dumper; use Geocoder\Model\Address; +use Geocoder\Model\Position; /** * @author Jan Sorgalla @@ -20,7 +21,7 @@ class Kml extends Gpx implements Dumper /** * {@inheritDoc} */ - public function dump(Address $address) + public function dump(Position $address) { $name = $this->formatName($address); $kml = << @@ -20,7 +21,7 @@ class Wkb implements Dumper /** * {@inheritDoc} */ - public function dump(Address $address) + public function dump(Position $address) { return pack('cLdd', 1, 1, $address->getLongitude(), $address->getLatitude()); } diff --git a/src/Geocoder/Dumper/Wkt.php b/src/Geocoder/Dumper/Wkt.php index 40ffdc5e8..007105b7e 100644 --- a/src/Geocoder/Dumper/Wkt.php +++ b/src/Geocoder/Dumper/Wkt.php @@ -11,6 +11,7 @@ namespace Geocoder\Dumper; use Geocoder\Model\Address; +use Geocoder\Model\Position; /** * @author Jan Sorgalla @@ -20,7 +21,7 @@ class Wkt implements Dumper /** * {@inheritDoc} */ - public function dump(Address $address) + public function dump(Position $address) { return sprintf('POINT(%F %F)', $address->getLongitude(), $address->getLatitude()); } diff --git a/src/Geocoder/Formatter/StringFormatter.php b/src/Geocoder/Formatter/StringFormatter.php index 1ca09d808..6088d62f2 100644 --- a/src/Geocoder/Formatter/StringFormatter.php +++ b/src/Geocoder/Formatter/StringFormatter.php @@ -11,8 +11,9 @@ namespace Geocoder\Formatter; use Geocoder\Model\Address; +use Geocoder\Model\Position; use Geocoder\Model\AdminLevel; -use Geocoder\Model\AdminLevelCollection; +use Geocoder\Model\AdminLevelCollectionInterface; /** * @author William Durand @@ -42,12 +43,12 @@ class StringFormatter /** * Transform an `Address` instance into a string representation. * - * @param Address $address - * @param string $format + * @param Position $address + * @param string $format * * @return string */ - public function format(Address $address, $format) + public function format(Position $address, $format) { $replace = [ self::STREET_NUMBER => $address->getStreetNumber(), @@ -60,7 +61,7 @@ public function format(Address $address, $format) self::TIMEZONE => $address->getTimezone(), ]; - for ($level = 1; $level <= AdminLevelCollection::MAX_LEVEL_DEPTH; $level ++) { + for ($level = 1; $level <= AdminLevelCollectionInterface::MAX_LEVEL_DEPTH; $level ++) { $replace[self::ADMIN_LEVEL . $level] = null; $replace[self::ADMIN_LEVEL_CODE . $level] = null; } diff --git a/src/Geocoder/Geocoder.php b/src/Geocoder/Geocoder.php index a0557eb11..b731404d3 100644 --- a/src/Geocoder/Geocoder.php +++ b/src/Geocoder/Geocoder.php @@ -10,8 +10,6 @@ namespace Geocoder; -use Geocoder\Model\AddressCollection; - /** * @author William Durand */ @@ -27,7 +25,7 @@ interface Geocoder * * @param string $value * - * @return AddressCollection + * @return GeocoderResult * @throws \Geocoder\Exception\Exception */ public function geocode($value); @@ -38,7 +36,7 @@ public function geocode($value); * @param double $latitude * @param double $longitude * - * @return AddressCollection + * @return GeocoderResult * @throws \Geocoder\Exception\Exception */ public function reverse($latitude, $longitude); diff --git a/src/Geocoder/GeocoderResult.php b/src/Geocoder/GeocoderResult.php new file mode 100644 index 000000000..3a2c8a92a --- /dev/null +++ b/src/Geocoder/GeocoderResult.php @@ -0,0 +1,46 @@ + */ -final class Address +final class Address implements Position { /** - * @var Coordinates + * @var CoordinatesInterface */ private $coordinates; /** - * @var Bounds + * @var BoundsInterface */ private $bounds; @@ -51,12 +51,12 @@ final class Address private $postalCode; /** - * @var AdminLevelCollection + * @var AdminLevelCollectionInterface */ private $adminLevels; /** - * @var Country + * @var CountryInterface */ private $country; @@ -73,15 +73,15 @@ final class Address * @param string $subLocality */ public function __construct( - Coordinates $coordinates = null, - Bounds $bounds = null, + CoordinatesInterface $coordinates = null, + BoundsInterface $bounds = null, $streetNumber = null, $streetName = null, $postalCode = null, $locality = null, $subLocality = null, - AdminLevelCollection $adminLevels = null, - Country $country = null, + AdminLevelCollectionInterface $adminLevels = null, + CountryInterface $country = null, $timezone = null ) { $this->coordinates = $coordinates; @@ -99,7 +99,7 @@ public function __construct( /** * Returns an array of coordinates (latitude, longitude). * - * @return Coordinates + * @return CoordinatesInterface */ public function getCoordinates() { @@ -137,7 +137,7 @@ public function getLongitude() /** * Returns the bounds value. * - * @return Bounds + * @return BoundsInterface */ public function getBounds() { @@ -198,7 +198,7 @@ public function getSubLocality() /** * Returns the administrative levels. * - * @return AdminLevelCollection + * @return AdminLevelCollectionInterface */ public function getAdminLevels() { @@ -208,7 +208,7 @@ public function getAdminLevels() /** * Returns the country value. * - * @return Country + * @return CountryInterface */ public function getCountry() { diff --git a/src/Geocoder/Model/AddressCollection.php b/src/Geocoder/Model/AddressCollection.php index 1eef24945..25d59039e 100644 --- a/src/Geocoder/Model/AddressCollection.php +++ b/src/Geocoder/Model/AddressCollection.php @@ -3,16 +3,17 @@ namespace Geocoder\Model; use Geocoder\Exception\CollectionIsEmpty; +use Geocoder\GeocoderResult; -final class AddressCollection implements \IteratorAggregate, \Countable +final class Address implements GeocoderResult { /** - * @var Address[] + * @var Position[] */ private $addresses; /** - * @param Address[] $addresses + * @param Position[] $addresses */ public function __construct(array $addresses = []) { @@ -36,19 +37,19 @@ public function count() } /** - * @return Address + * @return Position */ public function first() { if (empty($this->addresses)) { - throw new CollectionIsEmpty('The AddressCollection instance is empty.'); + throw new CollectionIsEmpty('The GeocoderResult instance is empty.'); } return reset($this->addresses); } /** - * @return Address[] + * @return Position[] */ public function slice($offset, $length = null) { @@ -64,7 +65,7 @@ public function has($index) } /** - * @return Address + * @return Position * @throws \OutOfBoundsException */ public function get($index) @@ -77,7 +78,7 @@ public function get($index) } /** - * @return Address[] + * @return Position[] */ public function all() { diff --git a/src/Geocoder/Model/AddressFactory.php b/src/Geocoder/Model/AddressFactory.php index 2d28b295f..46b5a7c5b 100644 --- a/src/Geocoder/Model/AddressFactory.php +++ b/src/Geocoder/Model/AddressFactory.php @@ -10,6 +10,8 @@ namespace Geocoder\Model; +use Geocoder\GeocoderResult; + /** * @author Markus Bachmann * @author William Durand @@ -18,7 +20,7 @@ final class AddressFactory { /** * @param array $results - * @return \Geocoder\Model\AddressCollection + * @return GeocoderResult */ public function createFromArray(array $results) { @@ -58,7 +60,7 @@ public function createFromArray(array $results) ); } - return new AddressCollection($addresses); + return new Address($addresses); } /** diff --git a/src/Geocoder/Model/AdminLevel.php b/src/Geocoder/Model/AdminLevel.php index f5227dc5c..1ab6e313d 100644 --- a/src/Geocoder/Model/AdminLevel.php +++ b/src/Geocoder/Model/AdminLevel.php @@ -13,7 +13,7 @@ /** * @author William Durand */ -final class AdminLevel +final class AdminLevel implements AdminLevelInterface { /** * @var int @@ -72,16 +72,6 @@ public function getCode() return $this->code; } - /** - * Returns a string with the administrative level name. - * - * @return string - */ - public function toString() - { - return $this->getName(); - } - /** * Returns a string with the administrative level name. * @@ -89,6 +79,6 @@ public function toString() */ public function __toString() { - return $this->toString(); + return $this->getName(); } } diff --git a/src/Geocoder/Model/AdminLevelCollection.php b/src/Geocoder/Model/AdminLevelCollection.php index 489b18091..6836ae22b 100644 --- a/src/Geocoder/Model/AdminLevelCollection.php +++ b/src/Geocoder/Model/AdminLevelCollection.php @@ -7,12 +7,12 @@ /** * @author Giorgio Premi */ -final class AdminLevelCollection implements \IteratorAggregate, \Countable +final class AdminLevelCollection implements AdminLevelCollectionInterface { const MAX_LEVEL_DEPTH = 5; /** - * @var AdminLevel[] + * @var AdminLevelInterface[] */ private $adminLevels; @@ -52,7 +52,7 @@ public function count() } /** - * @return AdminLevel|null + * @return AdminLevelInterface|null */ public function first() { @@ -64,7 +64,7 @@ public function first() } /** - * @return AdminLevel[] + * @return AdminLevelInterface[] */ public function slice($offset, $length = null) { @@ -80,7 +80,7 @@ public function has($level) } /** - * @return AdminLevel + * @return AdminLevelInterface * @throws \OutOfBoundsException * @throws InvalidArgument */ @@ -96,7 +96,7 @@ public function get($level) } /** - * @return AdminLevel[] + * @return AdminLevelInterface[] */ public function all() { diff --git a/src/Geocoder/Model/AdminLevelCollectionInterface.php b/src/Geocoder/Model/AdminLevelCollectionInterface.php new file mode 100644 index 000000000..8104d5c77 --- /dev/null +++ b/src/Geocoder/Model/AdminLevelCollectionInterface.php @@ -0,0 +1,48 @@ + + */ +interface AdminLevelCollectionInterface extends \IteratorAggregate, \Countable +{ + /** + * {@inheritDoc} + */ + public function getIterator(); + + /** + * {@inheritDoc} + */ + public function count(); + + /** + * @return AdminLevelInterface|null + */ + public function first(); + + /** + * @return AdminLevelInterface[] + */ + public function slice($offset, $length = null); + + /** + * @return bool + */ + public function has($level); + + /** + * @return AdminLevelInterface + * @throws \OutOfBoundsException + * @throws InvalidArgument + */ + public function get($level); + + /** + * @return AdminLevelInterface[] + */ + public function all(); +} \ No newline at end of file diff --git a/src/Geocoder/Model/AdminLevelInterface.php b/src/Geocoder/Model/AdminLevelInterface.php new file mode 100644 index 000000000..1df23f01f --- /dev/null +++ b/src/Geocoder/Model/AdminLevelInterface.php @@ -0,0 +1,37 @@ + + */ +interface AdminLevelInterface +{ + /** + * Returns the administrative level + * + * @return int Level number [1,5] + */ + public function getLevel(); + + /** + * Returns the administrative level name + * + * @return string + */ + public function getName(); + + /** + * Returns the administrative level short name. + * + * @return string + */ + public function getCode(); + + /** + * Returns a string with the administrative level name. + * + * @return string + */ + public function __toString(); +} \ No newline at end of file diff --git a/src/Geocoder/Model/Bounds.php b/src/Geocoder/Model/Bounds.php index 27104d333..dfec71953 100644 --- a/src/Geocoder/Model/Bounds.php +++ b/src/Geocoder/Model/Bounds.php @@ -13,7 +13,7 @@ /** * @author William Durand */ -final class Bounds +final class Bounds implements BoundsInterface { /** * @var double diff --git a/src/Geocoder/Model/BoundsInterface.php b/src/Geocoder/Model/BoundsInterface.php new file mode 100644 index 000000000..5254c6ab6 --- /dev/null +++ b/src/Geocoder/Model/BoundsInterface.php @@ -0,0 +1,51 @@ + + */ +interface BoundsInterface +{ + /** + * Returns the south bound. + * + * @return double + */ + public function getSouth(); + + /** + * Returns the west bound. + * + * @return double + */ + public function getWest(); + + /** + * Returns the north bound. + * + * @return double + */ + public function getNorth(); + + /** + * Returns the east bound. + * + * @return double + */ + public function getEast(); + + /** + * Returns whether or not bounds are defined + * + * @return bool + */ + public function isDefined(); + + /** + * Returns an array with bounds. The array MUST have the following keys: south, west, north, east + * + * @return array + */ + public function toArray(); +} \ No newline at end of file diff --git a/src/Geocoder/Model/Coordinates.php b/src/Geocoder/Model/Coordinates.php index f56be3df2..7f5efc4bf 100644 --- a/src/Geocoder/Model/Coordinates.php +++ b/src/Geocoder/Model/Coordinates.php @@ -13,7 +13,7 @@ /** * @author William Durand */ -final class Coordinates +final class Coordinates implements CoordinatesInterface { /** * @var double diff --git a/src/Geocoder/Model/CoordinatesInterface.php b/src/Geocoder/Model/CoordinatesInterface.php new file mode 100644 index 000000000..6dbe35c7e --- /dev/null +++ b/src/Geocoder/Model/CoordinatesInterface.php @@ -0,0 +1,23 @@ + + */ +interface CoordinatesInterface +{ + /** + * Returns the latitude. + * + * @return double + */ + public function getLatitude(); + + /** + * Returns the longitude. + * + * @return double + */ + public function getLongitude(); +} \ No newline at end of file diff --git a/src/Geocoder/Model/Country.php b/src/Geocoder/Model/Country.php index 9cd3ba839..01e9f3769 100644 --- a/src/Geocoder/Model/Country.php +++ b/src/Geocoder/Model/Country.php @@ -13,7 +13,7 @@ /** * @author William Durand */ -final class Country +final class Country implements CountryInterface { /** * @var string @@ -55,16 +55,6 @@ public function getCode() return $this->code; } - /** - * Returns a string with the country name. - * - * @return string - */ - public function toString() - { - return $this->getName(); - } - /** * Returns a string with the country name. * @@ -72,6 +62,6 @@ public function toString() */ public function __toString() { - return $this->toString(); + return $this->getName(); } } diff --git a/src/Geocoder/Model/CountryInterface.php b/src/Geocoder/Model/CountryInterface.php new file mode 100644 index 000000000..ae73d7848 --- /dev/null +++ b/src/Geocoder/Model/CountryInterface.php @@ -0,0 +1,30 @@ + + */ +interface CountryInterface +{ + /** + * Returns the country name + * + * @return string + */ + public function getName(); + + /** + * Returns the country ISO code. + * + * @return string + */ + public function getCode(); + + /** + * Returns a string with the country name. + * + * @return string + */ + public function __toString(); +} \ No newline at end of file diff --git a/src/Geocoder/Model/Position.php b/src/Geocoder/Model/Position.php new file mode 100644 index 000000000..99d275506 --- /dev/null +++ b/src/Geocoder/Model/Position.php @@ -0,0 +1,107 @@ + + */ +interface Position +{ + /** + * Returns an array of coordinates (latitude, longitude). + * + * @return CoordinatesInterface + */ + public function getCoordinates(); + + /** + * Returns the latitude value. + * + * @return double + */ + public function getLatitude(); + + /** + * Returns the longitude value. + * + * @return double + */ + public function getLongitude(); + + /** + * Returns the bounds value. + * + * @return BoundsInterface + */ + public function getBounds(); + + /** + * Returns the street number value. + * + * @return string|int + */ + public function getStreetNumber(); + + /** + * Returns the street name value. + * + * @return string + */ + public function getStreetName(); + + /** + * Returns the city or locality value. + * + * @return string + */ + public function getLocality(); + + /** + * Returns the postal code or zipcode value. + * + * @return string + */ + public function getPostalCode(); + + /** + * Returns the locality district, or + * sublocality, or neighborhood. + * + * @return string + */ + public function getSubLocality(); + + /** + * Returns the administrative levels. + * + * @return AdminLevelCollectionInterface + */ + public function getAdminLevels(); + + /** + * Returns the country value. + * + * @return CountryInterface + */ + public function getCountry(); + + /** + * Returns the country ISO code. + * + * @return string + */ + public function getCountryCode(); + + /** + * Returns the timezone. + * + * @return string + */ + public function getTimezone(); + + /** + * Returns an array with data indexed by name. + * + * @return array + */ + public function toArray(); +} \ No newline at end of file diff --git a/src/Geocoder/Provider/AbstractProvider.php b/src/Geocoder/Provider/AbstractProvider.php index ea4050fcd..26f0b29da 100644 --- a/src/Geocoder/Provider/AbstractProvider.php +++ b/src/Geocoder/Provider/AbstractProvider.php @@ -11,6 +11,7 @@ namespace Geocoder\Provider; use Geocoder\Geocoder; +use Geocoder\GeocoderResult; use Geocoder\Model\AddressFactory; /** @@ -96,7 +97,7 @@ protected function getLocalhostDefaults() /** * @param array $data An array of data. * - * @return \Geocoder\Model\AddressCollection + * @return GeocoderResult */ protected function returnResults(array $data = []) { diff --git a/src/Geocoder/Provider/FreeGeoIp.php b/src/Geocoder/Provider/FreeGeoIp.php index 0cdfabe3f..c8cc4ec64 100644 --- a/src/Geocoder/Provider/FreeGeoIp.php +++ b/src/Geocoder/Provider/FreeGeoIp.php @@ -12,7 +12,8 @@ use Geocoder\Exception\NoResult; use Geocoder\Exception\UnsupportedOperation; -use Geocoder\Model\AddressCollection; +use Geocoder\GeocoderResult; +use Geocoder\Model\Address; /** * @author William Durand @@ -61,7 +62,7 @@ public function getName() /** * @param string $query * - * @return AddressCollection + * @return GeocoderResult */ private function executeQuery($query) { diff --git a/src/Geocoder/Provider/Geonames.php b/src/Geocoder/Provider/Geonames.php index 2649c1458..2386049bc 100644 --- a/src/Geocoder/Provider/Geonames.php +++ b/src/Geocoder/Provider/Geonames.php @@ -13,7 +13,7 @@ use Geocoder\Exception\InvalidCredentials; use Geocoder\Exception\NoResult; use Geocoder\Exception\UnsupportedOperation; -use Geocoder\Model\AdminLevelCollection; +use Geocoder\Model\AdminLevelCollectionInterface; use Http\Client\HttpClient; /** @@ -138,7 +138,7 @@ private function executeQuery($query) $adminLevels = []; - for ($level = 1; $level <= AdminLevelCollection::MAX_LEVEL_DEPTH; ++ $level) { + for ($level = 1; $level <= AdminLevelCollectionInterface::MAX_LEVEL_DEPTH; ++ $level) { $adminNameProp = 'adminName' . $level; $adminCodeProp = 'adminCode' . $level; if (! empty($item->$adminNameProp) || ! empty($item->$adminCodeProp)) { diff --git a/src/Geocoder/Provider/HostIp.php b/src/Geocoder/Provider/HostIp.php index 5a5eb6dee..796b4ae4c 100644 --- a/src/Geocoder/Provider/HostIp.php +++ b/src/Geocoder/Provider/HostIp.php @@ -12,6 +12,7 @@ use Geocoder\Exception\NoResult; use Geocoder\Exception\UnsupportedOperation; +use Geocoder\GeocoderResult; /** * @author William Durand @@ -65,7 +66,7 @@ public function getName() /** * @param string $query * - * @return \Geocoder\Model\AddressCollection + * @return GeocoderResult */ private function executeQuery($query) { diff --git a/src/Geocoder/Provider/IpInfoDb.php b/src/Geocoder/Provider/IpInfoDb.php index 5a042ef13..a0c5f21a9 100644 --- a/src/Geocoder/Provider/IpInfoDb.php +++ b/src/Geocoder/Provider/IpInfoDb.php @@ -14,6 +14,7 @@ use Geocoder\Exception\InvalidCredentials; use Geocoder\Exception\NoResult; use Geocoder\Exception\UnsupportedOperation; +use Geocoder\GeocoderResult; use Http\Client\HttpClient; /** @@ -117,7 +118,7 @@ public function getName() /** * @param string $query * - * @return \Geocoder\Model\AddressCollection + * @return GeocoderResult */ private function executeQuery($query) { diff --git a/src/Geocoder/Provider/OpenCage.php b/src/Geocoder/Provider/OpenCage.php index a75448f58..9f87043c0 100644 --- a/src/Geocoder/Provider/OpenCage.php +++ b/src/Geocoder/Provider/OpenCage.php @@ -13,6 +13,7 @@ use Geocoder\Exception\QuotaExceeded; use Geocoder\Exception\NoResult; use Geocoder\Exception\UnsupportedOperation; +use Geocoder\GeocoderResult; use Http\Client\HttpClient; /** @@ -91,7 +92,7 @@ public function getName() /** * @param $query - * @return \Geocoder\Model\AddressCollection + * @return GeocoderResult */ private function executeQuery($query) { diff --git a/src/Geocoder/ProviderAggregator.php b/src/Geocoder/ProviderAggregator.php index 33073b0ab..fa6abf535 100644 --- a/src/Geocoder/ProviderAggregator.php +++ b/src/Geocoder/ProviderAggregator.php @@ -12,7 +12,7 @@ use Geocoder\Exception\ProviderNotRegistered; use Geocoder\Provider\Provider; -use Geocoder\Model\AddressCollection; +use Geocoder\Model\Address; /** * @author William Durand @@ -51,7 +51,7 @@ public function geocode($value) if (empty($value)) { // let's save a request - return new AddressCollection(); + return new Address(); } return $this->getProvider() @@ -66,7 +66,7 @@ public function reverse($latitude, $longitude) { if (empty($latitude) || empty($longitude)) { // let's save a request - return new AddressCollection(); + return new Address(); } return $this->getProvider() diff --git a/tests/Geocoder/Tests/Provider/ArcGISOnlineTest.php b/tests/Geocoder/Tests/Provider/ArcGISOnlineTest.php index db69cd09b..f5c173534 100644 --- a/tests/Geocoder/Tests/Provider/ArcGISOnlineTest.php +++ b/tests/Geocoder/Tests/Provider/ArcGISOnlineTest.php @@ -2,6 +2,7 @@ namespace Geocoder\Tests\Provider; +use Geocoder\Model\Position; use Geocoder\Tests\TestCase; use Geocoder\Provider\ArcGISOnline; @@ -80,7 +81,7 @@ public function testGeocodeWithRealAddress() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(5, $results); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(48.863279997000461, $result->getLatitude(), '', 0.0001); @@ -181,7 +182,7 @@ public function testReverseWithRealCoordinates() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(48.863279997000461, $result->getLatitude(), '', 0.0001); @@ -233,7 +234,7 @@ public function testGeocodeWithCity() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(5, $results); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(52.370518568000477, $result->getLatitude(), '', 0.0001); @@ -251,7 +252,7 @@ public function testGeocodeWithCity() $this->assertNull($result->getCountry()->getName()); $this->assertNull($result->getTimezone()); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->get(1); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(47.111386795000499, $result->getLatitude(), '', 0.0001); @@ -262,7 +263,7 @@ public function testGeocodeWithCity() $this->assertEquals('North Dakota', $result->getAdminLevels()->get(1)->getName()); $this->assertEquals('USA', $result->getCountry()->getCode()); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->get(2); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(39.391768472000479, $result->getLatitude(), '', 0.0001); @@ -273,7 +274,7 @@ public function testGeocodeWithCity() $this->assertEquals('Maryland', $result->getAdminLevels()->get(1)->getName()); $this->assertEquals('USA', $result->getCountry()->getCode()); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->get(3); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(53.174198173, $result->getLatitude(), '', 0.0001); @@ -284,7 +285,7 @@ public function testGeocodeWithCity() $this->assertEquals('Niedersachsen', $result->getAdminLevels()->get(1)->getName()); $this->assertEquals('DEU', $result->getCountry()->getCode()); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->get(4); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(-26.281805980999593, $result->getLatitude(), '', 0.0001); diff --git a/tests/Geocoder/Tests/Provider/BingMapsTest.php b/tests/Geocoder/Tests/Provider/BingMapsTest.php index ae0054d09..a58cf0118 100644 --- a/tests/Geocoder/Tests/Provider/BingMapsTest.php +++ b/tests/Geocoder/Tests/Provider/BingMapsTest.php @@ -2,6 +2,7 @@ namespace Geocoder\Tests\Provider; +use Geocoder\Model\Position; use Geocoder\Tests\TestCase; use Geocoder\Provider\BingMaps; @@ -94,7 +95,7 @@ public function testGeocodeReturnsMultipleResults() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(3, $results); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(48.86321675999999, $result->getLatitude(), '', 0.01); @@ -116,7 +117,7 @@ public function testGeocodeReturnsMultipleResults() $this->assertNull($result->getTimezone()); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->get(1); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(48.81342781, $result->getLatitude(), '', 0.01); @@ -136,7 +137,7 @@ public function testGeocodeReturnsMultipleResults() $this->assertEquals('France', $result->getCountry()->getName()); $this->assertEquals('FR', $result->getCountry()->getCode()); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->get(2); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(48.81014147, $result->getLatitude(), '', 0.01); @@ -169,7 +170,7 @@ public function testReverseReturnsSingleResult() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(48.86321648955345, $result->getLatitude(), '', 0.0001); @@ -204,7 +205,6 @@ public function testGeocodeWithRealAddressReturnsSingleResults() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var \Geocoder\Model\Address $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(48.86321675999999, $result->getLatitude(), '', 0.01); @@ -242,7 +242,6 @@ public function testGeocodeWithRealAddressReturnsMultipleResults() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(5, $results); - /** @var \Geocoder\Model\Address $result */ $result = $results->get(0); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(44.786701202393, $result->getLatitude(), '', 0.01); @@ -262,7 +261,7 @@ public function testGeocodeWithRealAddressReturnsMultipleResults() $this->assertEquals('Italie', $result->getCountry()->getName()); $this->assertEquals('IT', $result->getCountry()->getCode()); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->get(1); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(46.05179977417, $result->getLatitude(), '', 0.01); @@ -282,7 +281,7 @@ public function testGeocodeWithRealAddressReturnsMultipleResults() $this->assertEquals('Italie', $result->getCountry()->getName()); $this->assertEquals('IT', $result->getCountry()->getCode()); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->get(2); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(44.987880706787, $result->getLatitude(), '', 0.01); @@ -302,7 +301,7 @@ public function testGeocodeWithRealAddressReturnsMultipleResults() $this->assertEquals('Italie', $result->getCountry()->getName()); $this->assertEquals('IT', $result->getCountry()->getCode()); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->get(3); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(43.82638168335, $result->getLatitude(), '', 0.01); @@ -322,7 +321,7 @@ public function testGeocodeWithRealAddressReturnsMultipleResults() $this->assertEquals('Italie', $result->getCountry()->getName()); $this->assertEquals('IT', $result->getCountry()->getCode()); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->get(4); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(42.295810699463, $result->getLatitude(), '', 0.01); @@ -375,7 +374,7 @@ public function testReverseWithRealCoordinatesReturnsSingleResult() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(48.86321648955345, $result->getLatitude(), '', 0.0001); diff --git a/tests/Geocoder/Tests/Provider/FreeGeoIpTest.php b/tests/Geocoder/Tests/Provider/FreeGeoIpTest.php index b36c24c20..4297f4fd5 100644 --- a/tests/Geocoder/Tests/Provider/FreeGeoIpTest.php +++ b/tests/Geocoder/Tests/Provider/FreeGeoIpTest.php @@ -2,6 +2,7 @@ namespace Geocoder\Tests\Provider; +use Geocoder\Model\Position; use Geocoder\Tests\TestCase; use Geocoder\Provider\FreeGeoIp; @@ -51,7 +52,7 @@ public function testGeocodeWithLocalhostIPv4() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals('localhost', $result->getLocality()); @@ -66,7 +67,7 @@ public function testGeocodeWithLocalhostIPv6() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals('localhost', $result->getLocality()); @@ -101,7 +102,7 @@ public function testGeocodeWithRealIPv4() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(33.0347, $result->getLatitude(), '', 0.01); @@ -122,7 +123,7 @@ public function testGeocodeWithRealIPv6() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(33.0347, $result->getLatitude(), '', 0.01); diff --git a/tests/Geocoder/Tests/Provider/GeoIP2Test.php b/tests/Geocoder/Tests/Provider/GeoIP2Test.php index f9bebb1f6..5327dac3d 100644 --- a/tests/Geocoder/Tests/Provider/GeoIP2Test.php +++ b/tests/Geocoder/Tests/Provider/GeoIP2Test.php @@ -11,6 +11,7 @@ namespace Geocoder\Tests\Provider; use Geocoder\Exception\NoResult; +use Geocoder\Model\Position; use Geocoder\Provider\GeoIP2; use Geocoder\Tests\TestCase; @@ -50,7 +51,7 @@ public function testGeocodeWithLocalhostIPv4() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals('localhost', $result->getLocality()); @@ -162,7 +163,7 @@ public function testRetrievingGeodata($address, $adapterResponse, $expectedGeoda $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals($expectedGeodata['latitude'], $result->getLatitude()); diff --git a/tests/Geocoder/Tests/Provider/GeoIPsTest.php b/tests/Geocoder/Tests/Provider/GeoIPsTest.php index 9d1f3e0aa..80ced45e0 100644 --- a/tests/Geocoder/Tests/Provider/GeoIPsTest.php +++ b/tests/Geocoder/Tests/Provider/GeoIPsTest.php @@ -2,6 +2,7 @@ namespace Geocoder\Tests\Provider; +use Geocoder\Model\Position; use Geocoder\Tests\TestCase; use Geocoder\Provider\GeoIPs; @@ -60,7 +61,7 @@ public function testGeocodeWithLocalhostIPv4() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals('localhost', $result->getLocality()); @@ -131,7 +132,7 @@ public function testGeocodeWithRealIPv4GetsFakeContentFormattedEmpty() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertNull($result->getLatitude()); @@ -174,7 +175,7 @@ public function testGeocodeWithRealIPv4GetsFakeContent() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(40.3402, $result->getLatitude(), '', 0.0001); @@ -333,7 +334,7 @@ public function testGeocodeWithRealIPv4() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(40.3402, $result->getLatitude(), '', 0.0001); diff --git a/tests/Geocoder/Tests/Provider/GeoipTest.php b/tests/Geocoder/Tests/Provider/GeoipTest.php index 722572f70..6f585e6a3 100644 --- a/tests/Geocoder/Tests/Provider/GeoipTest.php +++ b/tests/Geocoder/Tests/Provider/GeoipTest.php @@ -2,6 +2,7 @@ namespace Geocoder\Tests\Provider; +use Geocoder\Model\Position; use Geocoder\Tests\TestCase; use Geocoder\Provider\Geoip; @@ -60,7 +61,7 @@ public function testGeocodeWithLocalhostIPv4() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->first(); $this->assertInstanceOf('Geocoder\Model\Address', $result); $this->assertNull($result->getLatitude()); diff --git a/tests/Geocoder/Tests/Provider/GeonamesTest.php b/tests/Geocoder/Tests/Provider/GeonamesTest.php index b3c779a76..6af9499c0 100644 --- a/tests/Geocoder/Tests/Provider/GeonamesTest.php +++ b/tests/Geocoder/Tests/Provider/GeonamesTest.php @@ -2,6 +2,7 @@ namespace Geocoder\Tests\Provider; +use Geocoder\Model\Position; use Geocoder\Tests\TestCase; use Geocoder\Provider\Geonames; @@ -91,7 +92,6 @@ public function testGeocodeWithRealPlace() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(5, $results); - /** @var \Geocoder\Model\Address $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(51.508528775863, $result->getLatitude(), '', 0.01); @@ -109,7 +109,6 @@ public function testGeocodeWithRealPlace() $this->assertEquals('GB', $result->getCountryCode()); $this->assertEquals('Europe/London', $result->getTimezone()); - /** @var \Geocoder\Model\Address $result */ $result = $results->get(1); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(-33.015285093464, $result->getLatitude(), '', 0.01); @@ -128,7 +127,7 @@ public function testGeocodeWithRealPlace() $this->assertEquals('ZA', $result->getCountryCode()); $this->assertEquals('Africa/Johannesburg', $result->getTimezone()); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->get(2); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(51.512788890295, $result->getLatitude(), '', 0.01); @@ -147,7 +146,7 @@ public function testGeocodeWithRealPlace() $this->assertEquals('GB', $result->getCountryCode()); $this->assertEquals('Europe/London', $result->getTimezone()); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->get(3); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(42.983389283, $result->getLatitude(), '', 0.01); @@ -164,7 +163,7 @@ public function testGeocodeWithRealPlace() $this->assertEquals('CA', $result->getCountryCode()); $this->assertEquals('America/Toronto', $result->getTimezone()); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->get(4); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(41.3556539, $result->getLatitude(), '', 0.01); @@ -195,7 +194,7 @@ public function testGeocodeWithRealPlaceWithLocale() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(5, $results); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(51.50853, $result->getLatitude(), '', 0.01); @@ -213,7 +212,7 @@ public function testGeocodeWithRealPlaceWithLocale() $this->assertEquals('GB', $result->getCountryCode()); $this->assertEquals('Europe/London', $result->getTimezone()); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->get(1); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(-33.015285093464, $result->getLatitude(), '', 0.01); @@ -232,7 +231,7 @@ public function testGeocodeWithRealPlaceWithLocale() $this->assertEquals('ZA', $result->getCountryCode()); $this->assertEquals('Africa/Johannesburg', $result->getTimezone()); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->get(2); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(51.512788890295, $result->getLatitude(), '', 0.01); @@ -251,7 +250,7 @@ public function testGeocodeWithRealPlaceWithLocale() $this->assertEquals('GB', $result->getCountryCode()); $this->assertEquals('Europe/London', $result->getTimezone()); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->get(3); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(42.983389283, $result->getLatitude(), '', 0.01); @@ -268,7 +267,7 @@ public function testGeocodeWithRealPlaceWithLocale() $this->assertEquals('CA', $result->getCountryCode()); $this->assertEquals('America/Toronto', $result->getTimezone()); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->get(4); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(41.3556539, $result->getLatitude(), '', 0.01); @@ -299,7 +298,7 @@ public function testReverseWithRealCoordinates() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(51.50853, $result->getLatitude(), '', 0.01); @@ -325,7 +324,7 @@ public function testReverseWithRealCoordinatesWithLocale() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(51.50853, $result->getLatitude(), '', 0.01); diff --git a/tests/Geocoder/Tests/Provider/GoogleMapsTest.php b/tests/Geocoder/Tests/Provider/GoogleMapsTest.php index 258ed5bfc..ca9b0b4bb 100644 --- a/tests/Geocoder/Tests/Provider/GoogleMapsTest.php +++ b/tests/Geocoder/Tests/Provider/GoogleMapsTest.php @@ -3,6 +3,7 @@ namespace Geocoder\Tests\Provider; use Geocoder\Exception\NoResult; +use Geocoder\Model\Position; use Geocoder\Tests\TestCase; use Geocoder\Provider\GoogleMaps; use Http\Client\HttpClient; @@ -119,7 +120,7 @@ public function testGeocodeWithRealAddress() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(48.8630462, $result->getLatitude(), '', 0.001); @@ -150,7 +151,7 @@ public function testGeocodeWithRealAddressWithSsl() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(48.8630462, $result->getLatitude(), '', 0.001); @@ -182,7 +183,6 @@ public function testGeocodeBoundsWithRealAddressForNonRooftopLocation() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var \Geocoder\Model\Address $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertTrue($result->getBounds()->isDefined()); @@ -200,7 +200,7 @@ public function testGeocodeWithRealAddressReturnsMultipleResults() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(5, $results); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(48.856614, $result->getLatitude(), '', 0.001); @@ -209,7 +209,7 @@ public function testGeocodeWithRealAddressReturnsMultipleResults() $this->assertEquals('France', $result->getCountry()->getName()); $this->assertEquals('FR', $result->getCountry()->getCode()); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->get(1); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(33.6609389, $result->getLatitude(), '', 0.001); @@ -218,7 +218,7 @@ public function testGeocodeWithRealAddressReturnsMultipleResults() $this->assertEquals('United States', $result->getCountry()->getName()); $this->assertEquals('US', $result->getCountry()->getCode()); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->get(2); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(36.3020023, $result->getLatitude(), '', 0.001); @@ -227,7 +227,7 @@ public function testGeocodeWithRealAddressReturnsMultipleResults() $this->assertEquals('United States', $result->getCountry()->getName()); $this->assertEquals('US', $result->getCountry()->getCode()); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->get(3); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(39.611146, $result->getLatitude(), '', 0.001); @@ -236,7 +236,7 @@ public function testGeocodeWithRealAddressReturnsMultipleResults() $this->assertEquals('United States', $result->getCountry()->getName()); $this->assertEquals('US', $result->getCountry()->getCode()); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->get(4); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(38.2097987, $result->getLatitude(), '', 0.001); @@ -264,7 +264,7 @@ public function testReverseWithRealCoordinates() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(5, $results); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(1, $result->getStreetNumber()); @@ -296,7 +296,7 @@ public function testGeocodeWithCityDistrict() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals('Kalbach-Riedberg', $result->getSubLocality()); @@ -325,7 +325,7 @@ public function testGeocodeWithRealValidApiKey() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertNotNull($result->getLatitude()); @@ -356,7 +356,7 @@ public function testGeocodePostalTown() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals('Pontypridd', $result->getLocality()); diff --git a/tests/Geocoder/Tests/Provider/HostIpTest.php b/tests/Geocoder/Tests/Provider/HostIpTest.php index 51bec9d7e..3edbdcced 100644 --- a/tests/Geocoder/Tests/Provider/HostIpTest.php +++ b/tests/Geocoder/Tests/Provider/HostIpTest.php @@ -2,6 +2,7 @@ namespace Geocoder\Tests\Provider; +use Geocoder\Model\Position; use Geocoder\Tests\TestCase; use Geocoder\Provider\HostIp; @@ -51,7 +52,7 @@ public function testGeocodeWithLocalhostIPv4() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertNull($result->getLatitude()); @@ -102,7 +103,7 @@ public function testGeocodeWithRealIPv4() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(45.5333, $result->getLatitude(), '', 0.0001); @@ -142,7 +143,6 @@ public function testGeocodeWithAnotherIp() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var \Geocoder\Model\Address $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertNull($result->getLatitude()); diff --git a/tests/Geocoder/Tests/Provider/IpInfoDbTest.php b/tests/Geocoder/Tests/Provider/IpInfoDbTest.php index fadd0e861..855fea4ab 100644 --- a/tests/Geocoder/Tests/Provider/IpInfoDbTest.php +++ b/tests/Geocoder/Tests/Provider/IpInfoDbTest.php @@ -2,6 +2,7 @@ namespace Geocoder\Tests\Provider; +use Geocoder\Model\Position; use Geocoder\Tests\TestCase; use Geocoder\Provider\IpInfoDb; @@ -79,7 +80,7 @@ public function testGeocodeWithLocalhostIPv4() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertNull($result->getLatitude()); @@ -134,7 +135,7 @@ public function testGeocodeWithRealIPv4() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(37.406, $result->getLatitude(), '', 0.001); @@ -177,7 +178,7 @@ public function testGetGeocodedDataWithCountryPrecision() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertNull($result->getLatitude()); diff --git a/tests/Geocoder/Tests/Provider/MapQuestTest.php b/tests/Geocoder/Tests/Provider/MapQuestTest.php index 74b4f8837..8760df3b0 100644 --- a/tests/Geocoder/Tests/Provider/MapQuestTest.php +++ b/tests/Geocoder/Tests/Provider/MapQuestTest.php @@ -2,6 +2,7 @@ namespace Geocoder\Tests\Provider; +use Geocoder\Model\Position; use Geocoder\Tests\TestCase; use Geocoder\Provider\MapQuest; @@ -60,7 +61,7 @@ public function testGeocodeWithRealAddress() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(48.866205, $result->getLatitude(), '', 0.01); @@ -105,7 +106,7 @@ public function testReverseWithRealCoordinates() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(54.0484068, $result->getLatitude(), '', 0.001); @@ -137,7 +138,7 @@ public function testGeocodeWithCity() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(5, $results); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(52.374478, $result->getLatitude(), '', 0.01); @@ -149,7 +150,7 @@ public function testGeocodeWithCity() $this->assertEquals('DE', $result->getCountry()->getName()); $this->assertEquals('DE', $result->getCountry()->getCode()); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(52.374478000000003, $result->getLatitude(), '', 0.01); @@ -161,7 +162,7 @@ public function testGeocodeWithCity() $this->assertEquals('DE', $result->getCountry()->getName()); $this->assertEquals('DE', $result->getCountry()->getCode()); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(52.374478000000003, $result->getLatitude(), '', 0.01); @@ -173,7 +174,7 @@ public function testGeocodeWithCity() $this->assertEquals('DE', $result->getCountry()->getName()); $this->assertEquals('DE', $result->getCountry()->getCode()); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(52.374478000000003, $result->getLatitude(), '', 0.01); @@ -198,7 +199,7 @@ public function testGeocodeWithCityDistrict() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(50.189062, $result->getLatitude(), '', 0.01); diff --git a/tests/Geocoder/Tests/Provider/MaxMindBinaryTest.php b/tests/Geocoder/Tests/Provider/MaxMindBinaryTest.php index 33ab95b65..c7fc85462 100644 --- a/tests/Geocoder/Tests/Provider/MaxMindBinaryTest.php +++ b/tests/Geocoder/Tests/Provider/MaxMindBinaryTest.php @@ -1,6 +1,7 @@ assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); @@ -77,7 +78,7 @@ public function testLocationResultContainsExpectedFieldsForASpanishIp() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); @@ -108,7 +109,7 @@ public function testFindLocationByIp($ip, $expectedCity, $expectedCountry) $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals($expectedCity, $result->getLocality()); @@ -120,7 +121,6 @@ public function testShouldReturnResultsAsUtf8Encoded() $provider = new MaxMindBinary($this->binaryFile); $results = $provider->geocode('212.51.181.237'); - /** @var \Geocoder\Model\Address $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertSame('Châlette-sur-loing', $result->getLocality()); diff --git a/tests/Geocoder/Tests/Provider/MaxMindTest.php b/tests/Geocoder/Tests/Provider/MaxMindTest.php index cbe313465..0074af20f 100644 --- a/tests/Geocoder/Tests/Provider/MaxMindTest.php +++ b/tests/Geocoder/Tests/Provider/MaxMindTest.php @@ -2,6 +2,7 @@ namespace Geocoder\Tests\Provider; +use Geocoder\Model\Position; use Geocoder\Tests\TestCase; use Geocoder\Provider\MaxMind; @@ -60,7 +61,7 @@ public function testGeocodeWithLocalhostIPv4() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals('localhost', $result->getLocality()); @@ -75,7 +76,7 @@ public function testGeocodeWithLocalhostIPv6() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals('localhost', $result->getLocality()); @@ -130,7 +131,7 @@ public function testGeocodeWithRealIPv4GetsFakeContentFormattedEmpty() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertNull($result->getLatitude()); @@ -155,7 +156,7 @@ public function testGeocodeWithRealIPv4GetsFakeContent() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(33.034698486328, $result->getLatitude(), '', 0.0001); @@ -187,7 +188,7 @@ public function testGeocodeWithRealIPv4GetsFakeContent() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(37.748402, $result->getLatitude(), '', 0.0001); @@ -300,7 +301,7 @@ public function testGeocodeServiceWithRealIPv4() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(33.034698, $result->getLatitude(), '', 0.1); @@ -332,7 +333,7 @@ public function testGeocodeOmniServiceWithRealIPv4() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(33.0347, $result->getLatitude(), '', 0.1); @@ -364,7 +365,6 @@ public function testGeocodeOmniServiceWithRealIPv4WithSslAndEncoding() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var \Geocoder\Model\Address $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(-27.5833, $result->getLatitude(), '', 0.1); @@ -395,7 +395,7 @@ public function testGeocodeWithRealIPv6() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(40.2181, $result->getLatitude(), '', 0.1); @@ -427,7 +427,7 @@ public function testGeocodeOmniServiceWithRealIPv6WithSsl() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(40.2181, $result->getLatitude(), '', 0.1); diff --git a/tests/Geocoder/Tests/Provider/NominatimTest.php b/tests/Geocoder/Tests/Provider/NominatimTest.php index 7fb931548..7fba5dd59 100644 --- a/tests/Geocoder/Tests/Provider/NominatimTest.php +++ b/tests/Geocoder/Tests/Provider/NominatimTest.php @@ -2,6 +2,7 @@ namespace Geocoder\Tests\Provider; +use Geocoder\Model\Position; use Geocoder\Provider\Nominatim; use Geocoder\Tests\TestCase; @@ -15,7 +16,7 @@ public function testGeocodeWithRealAddress() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(5, $results); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(48.8565056, $result->getLatitude(), '', 0.01); @@ -37,7 +38,7 @@ public function testGeocodeWithRealAddress() $this->assertEquals('France', $result->getCountry()->getName()); $this->assertEquals('FR', $result->getCountry()->getCode()); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->get(1); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(48.8588408, $result->getLatitude(), '', 0.01); @@ -59,7 +60,7 @@ public function testGeocodeWithRealAddress() $this->assertEquals('France', $result->getCountry()->getName()); $this->assertEquals('FR', $result->getCountry()->getCode()); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->get(2); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(35.28687645, $result->getLatitude(), '', 0.01); @@ -81,7 +82,7 @@ public function testGeocodeWithRealAddress() $this->assertEquals('United States of America', $result->getCountry()->getName()); $this->assertEquals('US', $result->getCountry()->getCode()); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->get(3); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(33.6751155, $result->getLatitude(), '', 0.01); @@ -103,7 +104,7 @@ public function testGeocodeWithRealAddress() $this->assertEquals('United States of America', $result->getCountry()->getName()); $this->assertEquals('US', $result->getCountry()->getCode()); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->get(4); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(38.2097987, $result->getLatitude(), '', 0.01); @@ -134,7 +135,7 @@ public function testGeocodeWithRealAddressWithLocale() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(2, $results); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(45.7586841, $result->getLatitude(), '', 0.01); @@ -156,7 +157,6 @@ public function testGeocodeWithRealAddressWithLocale() $this->assertEquals('France', $result->getCountry()->getName()); $this->assertEquals('FR', $result->getCountry()->getCode()); - /** @var \Geocoder\Model\Address $result */ $result = $results->get(1); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(45.7586841, $result->getLatitude(), '', 0.01); @@ -187,7 +187,7 @@ public function testReverseWithRealCoordinates() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(60.4539, $result->getLatitude(), '', 0.001); @@ -224,7 +224,7 @@ public function testReverseWithRealCoordinatesWithLocale() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(5, $results); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(50.1856803, $result->getLatitude(), '', 0.01); @@ -245,7 +245,7 @@ public function testReverseWithRealCoordinatesWithLocale() $this->assertEquals('Deutschland', $result->getCountry()->getName()); $this->assertEquals('DE', $result->getCountry()->getCode()); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->get(1); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(50.1845911, $result->getLatitude(), '', 0.01); @@ -266,7 +266,7 @@ public function testReverseWithRealCoordinatesWithLocale() $this->assertEquals('Deutschland', $result->getCountry()->getName()); $this->assertEquals('DE', $result->getCountry()->getCode()); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->get(2); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(50.1862884, $result->getLatitude(), '', 0.01); @@ -287,7 +287,7 @@ public function testReverseWithRealCoordinatesWithLocale() $this->assertEquals('Deutschland', $result->getCountry()->getName()); $this->assertEquals('DE', $result->getCountry()->getCode()); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->get(3); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(50.1861344, $result->getLatitude(), '', 0.01); @@ -317,7 +317,7 @@ public function testGeocodeWithLocalhostIPv4() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals('localhost', $result->getLocality()); @@ -343,7 +343,7 @@ public function testGeocodeWithRealIPv4() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(5, $results); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(43.6189768, $result->getLatitude(), '', 0.01); @@ -374,7 +374,7 @@ public function testGeocodeWithRealIPv4WithLocale() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(5, $results); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(43.6155351, $result->getLatitude(), '', 0.01); @@ -484,7 +484,7 @@ public function testGetNodeStreetName() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals('Rue Quincampoix', $result->getStreetName()); diff --git a/tests/Geocoder/Tests/Provider/OpenCageTest.php b/tests/Geocoder/Tests/Provider/OpenCageTest.php index 9a7ebb1ed..2d72a03cd 100644 --- a/tests/Geocoder/Tests/Provider/OpenCageTest.php +++ b/tests/Geocoder/Tests/Provider/OpenCageTest.php @@ -2,6 +2,7 @@ namespace Geocoder\Tests\Provider; +use Geocoder\Model\Position; use Geocoder\Tests\TestCase; use Geocoder\Provider\OpenCage; @@ -58,7 +59,7 @@ public function testGeocodeWithRealAddress() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(3, $results); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(48.866205, $result->getLatitude(), '', 0.01); @@ -105,7 +106,7 @@ public function testReverseWithRealCoordinates() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(54.0484068, $result->getLatitude(), '', 0.001); @@ -139,7 +140,7 @@ public function testReverseWithVillage() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals('Bray-et-Lû', $result->getLocality()); @@ -157,7 +158,7 @@ public function testGeocodeWithCity() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(5, $results); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(52.374478, $result->getLatitude(), '', 0.01); @@ -168,7 +169,7 @@ public function testGeocodeWithCity() $this->assertEquals('Lower Saxony', $result->getAdminLevels()->get(1)->getName()); $this->assertEquals('Germany', $result->getCountry()->getName()); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->get(1); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(37.744783, $result->getLatitude(), '', 0.01); @@ -178,7 +179,7 @@ public function testGeocodeWithCity() $this->assertEquals('Hanover', $result->getAdminLevels()->get(2)->getName()); $this->assertEquals('United States of America', $result->getCountry()->getName()); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->get(2); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(18.3840489, $result->getLatitude(), '', 0.01); @@ -188,7 +189,7 @@ public function testGeocodeWithCity() $this->assertEquals('Hanover', $result->getAdminLevels()->get(2)->getName()); $this->assertEquals('Jamaica', $result->getCountry()->getName()); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->get(3); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(43.7033073, $result->getLatitude(), '', 0.01); @@ -212,7 +213,7 @@ public function testGeocodeWithCityDistrict() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(2, $results); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(50.189062, $result->getLatitude(), '', 0.01); @@ -242,7 +243,7 @@ public function testGeocodeWithLocale() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(5, $results); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals('Londres', $result->getLocality()); diff --git a/tests/Geocoder/Tests/Provider/TomTomTest.php b/tests/Geocoder/Tests/Provider/TomTomTest.php index 2c67feeaf..931ef6243 100644 --- a/tests/Geocoder/Tests/Provider/TomTomTest.php +++ b/tests/Geocoder/Tests/Provider/TomTomTest.php @@ -2,6 +2,7 @@ namespace Geocoder\Tests\Provider; +use Geocoder\Model\Position; use Geocoder\Tests\TestCase; use Geocoder\Provider\TomTom; @@ -90,7 +91,7 @@ public function testGeocodeWithRealAddress() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(55.704389, $result->getLatitude(), '', 0.0001); @@ -119,7 +120,7 @@ public function testGeocodeWithRealAddressWithFrenchLocale() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(55.704389, $result->getLatitude(), '', 0.0001); @@ -148,7 +149,7 @@ public function testGeocodeWithRealAddressWithSwedishLocale() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(55.704389, $result->getLatitude(), '', 0.0001); @@ -177,7 +178,7 @@ public function testGeocodeWithRealAddressReturnsMultipleResults() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(5, $results); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(48.856898, $result->getLatitude(), '', 0.0001); @@ -195,7 +196,7 @@ public function testGeocodeWithRealAddressReturnsMultipleResults() $this->assertEquals('FRA', $result->getCountry()->getCode()); $this->assertNull($result->getTimezone()); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->get(1); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(33.661426, $result->getLatitude(), '', 0.0001); @@ -206,7 +207,7 @@ public function testGeocodeWithRealAddressReturnsMultipleResults() $this->assertEquals('United States',$result->getCountry()->getName()); $this->assertEquals('USA', $result->getCountry()->getCode()); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->get(2); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(36.302754, $result->getLatitude(), '', 0.0001); @@ -217,7 +218,7 @@ public function testGeocodeWithRealAddressReturnsMultipleResults() $this->assertEquals('United States', $result->getCountry()->getName()); $this->assertEquals('USA', $result->getCountry()->getCode()); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->get(3); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(-19.039448, $result->getLatitude(), '', 0.0001); @@ -228,7 +229,7 @@ public function testGeocodeWithRealAddressReturnsMultipleResults() $this->assertEquals('Zimbabwe', $result->getCountry()->getName()); $this->assertEquals('ZWE', $result->getCountry()->getCode()); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->get(4); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(35.292105, $result->getLatitude(), '', 0.0001); @@ -360,7 +361,7 @@ public function testReverseWithRealCoordinates() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(48.86323, $result->getLatitude(), '', 0.001); @@ -389,7 +390,7 @@ public function testGeocodeWithRealCoordinates() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(56.52435, $result->getLatitude(), '', 0.001); diff --git a/tests/Geocoder/Tests/Provider/YandexTest.php b/tests/Geocoder/Tests/Provider/YandexTest.php index 4a5b42e6e..727d3f9e4 100644 --- a/tests/Geocoder/Tests/Provider/YandexTest.php +++ b/tests/Geocoder/Tests/Provider/YandexTest.php @@ -2,6 +2,7 @@ namespace Geocoder\Tests\Provider; +use Geocoder\Model\Position; use Geocoder\Tests\TestCase; use Geocoder\Provider\Yandex; @@ -94,7 +95,7 @@ public function testGeocodeWithRealAddress() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->first(); $this->assertInstanceOf('Geocoder\Model\Address', $result); $this->assertEquals(48.863277, $result->getLatitude(), '', 0.01); @@ -129,7 +130,7 @@ public function testGeocodeWithRealAddressWithUALocale() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(5, $results);; - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->first(); $this->assertInstanceOf('Geocoder\Model\Address', $result); $this->assertEquals(55.675676, $result->getLatitude(), '', 0.01); @@ -153,25 +154,25 @@ public function testGeocodeWithRealAddressWithUALocale() $this->assertNull($result->getAdminLevels()->get(1)->getCode()); $this->assertNull($result->getTimezone()); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->get(1); $this->assertInstanceOf('Geocoder\Model\Address', $result); $this->assertEquals(55.455739, $result->getLatitude(), '', 0.01); $this->assertEquals(9.972854, $result->getLongitude(), '', 0.01); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->get(2); $this->assertInstanceOf('Geocoder\Model\Address', $result); $this->assertEquals(55.713258, $result->getLatitude(), '', 0.01); $this->assertEquals(12.534930, $result->getLongitude(), '', 0.01); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->get(3); $this->assertInstanceOf('Geocoder\Model\Address', $result); $this->assertEquals(55.698878, $result->getLatitude(), '', 0.01); $this->assertEquals(12.578211, $result->getLongitude(), '', 0.01); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->get(4); $this->assertInstanceOf('Geocoder\Model\Address', $result); $this->assertEquals(55.690380, $result->getLatitude(), '', 0.01); @@ -186,7 +187,7 @@ public function testGeocodeWithRealAddressWithUSLocale() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(5, $results); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->first(); $this->assertInstanceOf('Geocoder\Model\Address', $result); $this->assertEquals(38.897695, $result->getLatitude(), '', 0.01); @@ -220,7 +221,7 @@ public function testGeocodeWithRealAddressWithBYLocale() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->first(); $this->assertInstanceOf('Geocoder\Model\Address', $result); $this->assertEquals(53.898077, $result->getLatitude(), '', 0.01); @@ -282,7 +283,7 @@ public function testReverseWithRealCoordinates() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(5, $results); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->first(); $this->assertInstanceOf('Geocoder\Model\Address', $result); $this->assertEquals(48.863212, $result->getLatitude(), '', 0.01); @@ -308,13 +309,13 @@ public function testReverseWithRealCoordinates() $this->assertNull($result->getAdminLevels()->get(1)->getCode()); $this->assertNull($result->getTimezone()); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->get(1); $this->assertInstanceOf('Geocoder\Model\Address', $result); $this->assertEquals(48.864848, $result->getLatitude(), '', 0.01); $this->assertEquals(2.3993549, $result->getLongitude(), '', 0.01); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->get(2); $this->assertInstanceOf('Geocoder\Model\Address', $result); $this->assertEquals(48.856929, $result->getLatitude(), '', 0.01); @@ -329,7 +330,7 @@ public function testReverseWithRealCoordinatesWithUSLocaleAndStreeToponym() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(5, $results); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->first(); $this->assertInstanceOf('Geocoder\Model\Address', $result); $this->assertEquals(48.87132, $result->getLatitude(), '', 0.01); @@ -355,25 +356,25 @@ public function testReverseWithRealCoordinatesWithUSLocaleAndStreeToponym() $this->assertNull($result->getAdminLevels()->get(1)->getCode()); $this->assertNull($result->getTimezone()); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->get(1); $this->assertInstanceOf('Geocoder\Model\Address', $result); $this->assertEquals(48.863230, $result->getLatitude(), '', 0.01); $this->assertEquals(2.388261, $result->getLongitude(), '', 0.01); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->get(2); $this->assertInstanceOf('Geocoder\Model\Address', $result); $this->assertEquals(48.866022, $result->getLatitude(), '', 0.01); $this->assertEquals(2.389662, $result->getLongitude(), '', 0.01); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->get(3); $this->assertInstanceOf('Geocoder\Model\Address', $result); $this->assertEquals(48.863918, $result->getLatitude(), '', 0.01); $this->assertEquals(2.387767, $result->getLongitude(), '', 0.01); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->get(4); $this->assertInstanceOf('Geocoder\Model\Address', $result); $this->assertEquals(48.863787, $result->getLatitude(), '', 0.01); @@ -388,7 +389,7 @@ public function testReverseWithRealCoordinatesWithUALocaleAndHouseToponym() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(5, $results); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->first(); $this->assertInstanceOf('Geocoder\Model\Address', $result); $this->assertEquals(60.454462, $result->getLatitude(), '', 0.01); @@ -423,7 +424,7 @@ public function testReverseWithRealCoordinatesWithTRLocaleAndLocalityToponym() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(5, $results); - /** @var \Geocoder\Model\Address $result */ + /** @var Position $result */ $result = $results->first(); $this->assertInstanceOf('Geocoder\Model\Address', $result); $this->assertEquals(40.874651, $result->getLatitude(), '', 0.01); From 093925aefc8572aa7a29233dacc18ed5215efbe5 Mon Sep 17 00:00:00 2001 From: Tobias Nyholm Date: Tue, 11 Oct 2016 16:17:43 +0200 Subject: [PATCH 02/21] Removed interfaces for value objects --- src/Geocoder/GeocoderResult.php | 5 +- src/Geocoder/Model/AddressCollection.php | 2 +- src/Geocoder/Model/AddressFactory.php | 2 +- src/Geocoder/Model/AdminLevelCollection.php | 4 ++ src/Geocoder/Model/Bounds.php | 2 +- src/Geocoder/Model/BoundsInterface.php | 51 --------------------- src/Geocoder/Model/Coordinates.php | 2 +- src/Geocoder/Model/CoordinatesInterface.php | 23 ---------- src/Geocoder/Model/Country.php | 2 +- src/Geocoder/Model/CountryInterface.php | 30 ------------ src/Geocoder/Model/Position.php | 9 ++-- 11 files changed, 19 insertions(+), 113 deletions(-) delete mode 100644 src/Geocoder/Model/BoundsInterface.php delete mode 100644 src/Geocoder/Model/CoordinatesInterface.php delete mode 100644 src/Geocoder/Model/CountryInterface.php diff --git a/src/Geocoder/GeocoderResult.php b/src/Geocoder/GeocoderResult.php index 3a2c8a92a..028da0740 100644 --- a/src/Geocoder/GeocoderResult.php +++ b/src/Geocoder/GeocoderResult.php @@ -4,7 +4,10 @@ use Geocoder\Model\Position; /** - * This is the interface that is always return from a geocoder. + * This is the interface that is always return from a Geocoder. + * + * @author William Durand + * @author Tobias Nyholm */ interface GeocoderResult extends \IteratorAggregate, \Countable { diff --git a/src/Geocoder/Model/AddressCollection.php b/src/Geocoder/Model/AddressCollection.php index 25d59039e..b1ab40dfd 100644 --- a/src/Geocoder/Model/AddressCollection.php +++ b/src/Geocoder/Model/AddressCollection.php @@ -5,7 +5,7 @@ use Geocoder\Exception\CollectionIsEmpty; use Geocoder\GeocoderResult; -final class Address implements GeocoderResult +final class AddressCollection implements GeocoderResult { /** * @var Position[] diff --git a/src/Geocoder/Model/AddressFactory.php b/src/Geocoder/Model/AddressFactory.php index 46b5a7c5b..87d553de1 100644 --- a/src/Geocoder/Model/AddressFactory.php +++ b/src/Geocoder/Model/AddressFactory.php @@ -60,7 +60,7 @@ public function createFromArray(array $results) ); } - return new Address($addresses); + return new AddressCollection($addresses); } /** diff --git a/src/Geocoder/Model/AdminLevelCollection.php b/src/Geocoder/Model/AdminLevelCollection.php index 6836ae22b..78ee6b5f0 100644 --- a/src/Geocoder/Model/AdminLevelCollection.php +++ b/src/Geocoder/Model/AdminLevelCollection.php @@ -16,6 +16,10 @@ final class AdminLevelCollection implements AdminLevelCollectionInterface */ private $adminLevels; + /** + * + * @param AdminLevelInterface[] $adminLevels + */ public function __construct(array $adminLevels = []) { $this->adminLevels = []; diff --git a/src/Geocoder/Model/Bounds.php b/src/Geocoder/Model/Bounds.php index dfec71953..27104d333 100644 --- a/src/Geocoder/Model/Bounds.php +++ b/src/Geocoder/Model/Bounds.php @@ -13,7 +13,7 @@ /** * @author William Durand */ -final class Bounds implements BoundsInterface +final class Bounds { /** * @var double diff --git a/src/Geocoder/Model/BoundsInterface.php b/src/Geocoder/Model/BoundsInterface.php deleted file mode 100644 index 5254c6ab6..000000000 --- a/src/Geocoder/Model/BoundsInterface.php +++ /dev/null @@ -1,51 +0,0 @@ - - */ -interface BoundsInterface -{ - /** - * Returns the south bound. - * - * @return double - */ - public function getSouth(); - - /** - * Returns the west bound. - * - * @return double - */ - public function getWest(); - - /** - * Returns the north bound. - * - * @return double - */ - public function getNorth(); - - /** - * Returns the east bound. - * - * @return double - */ - public function getEast(); - - /** - * Returns whether or not bounds are defined - * - * @return bool - */ - public function isDefined(); - - /** - * Returns an array with bounds. The array MUST have the following keys: south, west, north, east - * - * @return array - */ - public function toArray(); -} \ No newline at end of file diff --git a/src/Geocoder/Model/Coordinates.php b/src/Geocoder/Model/Coordinates.php index 7f5efc4bf..f56be3df2 100644 --- a/src/Geocoder/Model/Coordinates.php +++ b/src/Geocoder/Model/Coordinates.php @@ -13,7 +13,7 @@ /** * @author William Durand */ -final class Coordinates implements CoordinatesInterface +final class Coordinates { /** * @var double diff --git a/src/Geocoder/Model/CoordinatesInterface.php b/src/Geocoder/Model/CoordinatesInterface.php deleted file mode 100644 index 6dbe35c7e..000000000 --- a/src/Geocoder/Model/CoordinatesInterface.php +++ /dev/null @@ -1,23 +0,0 @@ - - */ -interface CoordinatesInterface -{ - /** - * Returns the latitude. - * - * @return double - */ - public function getLatitude(); - - /** - * Returns the longitude. - * - * @return double - */ - public function getLongitude(); -} \ No newline at end of file diff --git a/src/Geocoder/Model/Country.php b/src/Geocoder/Model/Country.php index 01e9f3769..f95929a95 100644 --- a/src/Geocoder/Model/Country.php +++ b/src/Geocoder/Model/Country.php @@ -13,7 +13,7 @@ /** * @author William Durand */ -final class Country implements CountryInterface +final class Country { /** * @var string diff --git a/src/Geocoder/Model/CountryInterface.php b/src/Geocoder/Model/CountryInterface.php deleted file mode 100644 index ae73d7848..000000000 --- a/src/Geocoder/Model/CountryInterface.php +++ /dev/null @@ -1,30 +0,0 @@ - - */ -interface CountryInterface -{ - /** - * Returns the country name - * - * @return string - */ - public function getName(); - - /** - * Returns the country ISO code. - * - * @return string - */ - public function getCode(); - - /** - * Returns a string with the country name. - * - * @return string - */ - public function __toString(); -} \ No newline at end of file diff --git a/src/Geocoder/Model/Position.php b/src/Geocoder/Model/Position.php index 99d275506..a4a0ceb00 100644 --- a/src/Geocoder/Model/Position.php +++ b/src/Geocoder/Model/Position.php @@ -2,14 +2,17 @@ namespace Geocoder\Model; /** + * A position is a single result from a Geocoder. + * * @author William Durand + * @author Tobias Nyholm */ interface Position { /** * Returns an array of coordinates (latitude, longitude). * - * @return CoordinatesInterface + * @return Coordinates */ public function getCoordinates(); @@ -30,7 +33,7 @@ public function getLongitude(); /** * Returns the bounds value. * - * @return BoundsInterface + * @return Bounds */ public function getBounds(); @@ -80,7 +83,7 @@ public function getAdminLevels(); /** * Returns the country value. * - * @return CountryInterface + * @return Country */ public function getCountry(); From 56cf7ba6f721d8f8ba48123155dcaefe2e2db126 Mon Sep 17 00:00:00 2001 From: Tobias Nyholm Date: Wed, 12 Oct 2016 10:10:22 +0200 Subject: [PATCH 03/21] Removed interfaces for value objects --- src/Geocoder/GeocoderResult.php | 3 +- src/Geocoder/Model/Address.php | 48 +++++++++++-------- src/Geocoder/Model/AddressCollection.php | 1 + src/Geocoder/Model/AdminLevel.php | 2 +- src/Geocoder/Model/AdminLevelCollection.php | 14 +++--- .../Model/AdminLevelCollectionInterface.php | 48 ------------------- src/Geocoder/Model/AdminLevelInterface.php | 37 -------------- src/Geocoder/Model/Coordinates.php | 14 +++++- src/Geocoder/Model/Country.php | 12 ++++- src/Geocoder/{Model => }/Position.php | 28 ++++++++--- 10 files changed, 83 insertions(+), 124 deletions(-) delete mode 100644 src/Geocoder/Model/AdminLevelCollectionInterface.php delete mode 100644 src/Geocoder/Model/AdminLevelInterface.php rename src/Geocoder/{Model => }/Position.php (72%) diff --git a/src/Geocoder/GeocoderResult.php b/src/Geocoder/GeocoderResult.php index 028da0740..5056e7544 100644 --- a/src/Geocoder/GeocoderResult.php +++ b/src/Geocoder/GeocoderResult.php @@ -1,7 +1,6 @@ */ final class Address implements Position { /** - * @var CoordinatesInterface + * @var Coordinates */ private $coordinates; /** - * @var BoundsInterface + * @var Bounds */ private $bounds; @@ -51,12 +53,12 @@ final class Address implements Position private $postalCode; /** - * @var AdminLevelCollectionInterface + * @var AdminLevelCollection */ private $adminLevels; /** - * @var CountryInterface + * @var Country */ private $country; @@ -66,40 +68,46 @@ final class Address implements Position private $timezone; /** - * @param string $streetNumber - * @param string $streetName - * @param string $postalCode - * @param string $locality - * @param string $subLocality + * + * @param Coordinates|null $coordinates + * @param Bounds|null $bounds + * @param string|null $streetNumber + * @param string|null $streetName + * @param string|null $postalCode + * @param string|null $locality + * @param string|null $subLocality + * @param AdminLevelCollection|null $adminLevels + * @param Country|null $country + * @param string|null $timezone */ public function __construct( - CoordinatesInterface $coordinates = null, - BoundsInterface $bounds = null, + Coordinates $coordinates = null, + Bounds $bounds = null, $streetNumber = null, $streetName = null, $postalCode = null, $locality = null, $subLocality = null, - AdminLevelCollectionInterface $adminLevels = null, - CountryInterface $country = null, + AdminLevelCollection $adminLevels = null, + Country $country = null, $timezone = null ) { - $this->coordinates = $coordinates; - $this->bounds = $bounds; + $this->coordinates = $coordinates ?: new Coordinates(null, null); + $this->bounds = $bounds ?: new Bounds(null, null, null, null); $this->streetNumber = $streetNumber; $this->streetName = $streetName; $this->postalCode = $postalCode; $this->locality = $locality; $this->subLocality = $subLocality; $this->adminLevels = $adminLevels ?: new AdminLevelCollection(); - $this->country = $country; + $this->country = $country ?: new Country(null, null); $this->timezone = $timezone; } /** * Returns an array of coordinates (latitude, longitude). * - * @return CoordinatesInterface + * @return Coordinates */ public function getCoordinates() { @@ -137,7 +145,7 @@ public function getLongitude() /** * Returns the bounds value. * - * @return BoundsInterface + * @return Bounds */ public function getBounds() { @@ -198,7 +206,7 @@ public function getSubLocality() /** * Returns the administrative levels. * - * @return AdminLevelCollectionInterface + * @return AdminLevelCollection */ public function getAdminLevels() { @@ -208,7 +216,7 @@ public function getAdminLevels() /** * Returns the country value. * - * @return CountryInterface + * @return Country */ public function getCountry() { diff --git a/src/Geocoder/Model/AddressCollection.php b/src/Geocoder/Model/AddressCollection.php index b1ab40dfd..f6255814e 100644 --- a/src/Geocoder/Model/AddressCollection.php +++ b/src/Geocoder/Model/AddressCollection.php @@ -4,6 +4,7 @@ use Geocoder\Exception\CollectionIsEmpty; use Geocoder\GeocoderResult; +use Geocoder\Position; final class AddressCollection implements GeocoderResult { diff --git a/src/Geocoder/Model/AdminLevel.php b/src/Geocoder/Model/AdminLevel.php index 1ab6e313d..88e47fc3d 100644 --- a/src/Geocoder/Model/AdminLevel.php +++ b/src/Geocoder/Model/AdminLevel.php @@ -13,7 +13,7 @@ /** * @author William Durand */ -final class AdminLevel implements AdminLevelInterface +final class AdminLevel { /** * @var int diff --git a/src/Geocoder/Model/AdminLevelCollection.php b/src/Geocoder/Model/AdminLevelCollection.php index 78ee6b5f0..0f0ce2a64 100644 --- a/src/Geocoder/Model/AdminLevelCollection.php +++ b/src/Geocoder/Model/AdminLevelCollection.php @@ -7,18 +7,18 @@ /** * @author Giorgio Premi */ -final class AdminLevelCollection implements AdminLevelCollectionInterface +final class AdminLevelCollection implements \IteratorAggregate, \Countable { const MAX_LEVEL_DEPTH = 5; /** - * @var AdminLevelInterface[] + * @var AdminLevel[] */ private $adminLevels; /** * - * @param AdminLevelInterface[] $adminLevels + * @param AdminLevel[] $adminLevels */ public function __construct(array $adminLevels = []) { @@ -56,7 +56,7 @@ public function count() } /** - * @return AdminLevelInterface|null + * @return AdminLevel|null */ public function first() { @@ -68,7 +68,7 @@ public function first() } /** - * @return AdminLevelInterface[] + * @return AdminLevel[] */ public function slice($offset, $length = null) { @@ -84,7 +84,7 @@ public function has($level) } /** - * @return AdminLevelInterface + * @return AdminLevel * @throws \OutOfBoundsException * @throws InvalidArgument */ @@ -100,7 +100,7 @@ public function get($level) } /** - * @return AdminLevelInterface[] + * @return AdminLevel[] */ public function all() { diff --git a/src/Geocoder/Model/AdminLevelCollectionInterface.php b/src/Geocoder/Model/AdminLevelCollectionInterface.php deleted file mode 100644 index 8104d5c77..000000000 --- a/src/Geocoder/Model/AdminLevelCollectionInterface.php +++ /dev/null @@ -1,48 +0,0 @@ - - */ -interface AdminLevelCollectionInterface extends \IteratorAggregate, \Countable -{ - /** - * {@inheritDoc} - */ - public function getIterator(); - - /** - * {@inheritDoc} - */ - public function count(); - - /** - * @return AdminLevelInterface|null - */ - public function first(); - - /** - * @return AdminLevelInterface[] - */ - public function slice($offset, $length = null); - - /** - * @return bool - */ - public function has($level); - - /** - * @return AdminLevelInterface - * @throws \OutOfBoundsException - * @throws InvalidArgument - */ - public function get($level); - - /** - * @return AdminLevelInterface[] - */ - public function all(); -} \ No newline at end of file diff --git a/src/Geocoder/Model/AdminLevelInterface.php b/src/Geocoder/Model/AdminLevelInterface.php deleted file mode 100644 index 1df23f01f..000000000 --- a/src/Geocoder/Model/AdminLevelInterface.php +++ /dev/null @@ -1,37 +0,0 @@ - - */ -interface AdminLevelInterface -{ - /** - * Returns the administrative level - * - * @return int Level number [1,5] - */ - public function getLevel(); - - /** - * Returns the administrative level name - * - * @return string - */ - public function getName(); - - /** - * Returns the administrative level short name. - * - * @return string - */ - public function getCode(); - - /** - * Returns a string with the administrative level name. - * - * @return string - */ - public function __toString(); -} \ No newline at end of file diff --git a/src/Geocoder/Model/Coordinates.php b/src/Geocoder/Model/Coordinates.php index f56be3df2..56d90cd4b 100644 --- a/src/Geocoder/Model/Coordinates.php +++ b/src/Geocoder/Model/Coordinates.php @@ -38,7 +38,7 @@ public function __construct($latitude, $longitude) /** * Returns the latitude. * - * @return double + * @return double|null */ public function getLatitude() { @@ -48,10 +48,20 @@ public function getLatitude() /** * Returns the longitude. * - * @return double + * @return double|null */ public function getLongitude() { return $this->longitude; } + + /** + * Returns true if we have coordinates for both longitude and latitude. + * + * @return bool + */ + public function isDefined() + { + return !empty($this->latitude) && !empty($this->longitude); + } } diff --git a/src/Geocoder/Model/Country.php b/src/Geocoder/Model/Country.php index f95929a95..821dcf8ce 100644 --- a/src/Geocoder/Model/Country.php +++ b/src/Geocoder/Model/Country.php @@ -62,6 +62,16 @@ public function getCode() */ public function __toString() { - return $this->getName(); + return $this->getName() ?: ''; + } + + /** + * Returns true if both name and code is defined. + * + * @return bool + */ + public function isDefined() + { + return !empty($this->code) && !empty($this->name); } } diff --git a/src/Geocoder/Model/Position.php b/src/Geocoder/Position.php similarity index 72% rename from src/Geocoder/Model/Position.php rename to src/Geocoder/Position.php index a4a0ceb00..4f753832e 100644 --- a/src/Geocoder/Model/Position.php +++ b/src/Geocoder/Position.php @@ -1,5 +1,10 @@ Date: Wed, 12 Oct 2016 10:19:06 +0200 Subject: [PATCH 04/21] Updated "use" statements --- src/Geocoder/Dumper/Dumper.php | 9 +++---- src/Geocoder/Dumper/GeoJson.php | 11 ++++---- src/Geocoder/Dumper/Gpx.php | 12 ++++----- src/Geocoder/Dumper/Kml.php | 8 +++--- src/Geocoder/Dumper/Wkb.php | 6 ++--- src/Geocoder/Dumper/Wkt.php | 6 ++--- src/Geocoder/Formatter/StringFormatter.php | 30 ++++++++++------------ 7 files changed, 39 insertions(+), 43 deletions(-) diff --git a/src/Geocoder/Dumper/Dumper.php b/src/Geocoder/Dumper/Dumper.php index 98f807880..cd358c9e6 100644 --- a/src/Geocoder/Dumper/Dumper.php +++ b/src/Geocoder/Dumper/Dumper.php @@ -10,8 +10,7 @@ namespace Geocoder\Dumper; -use Geocoder\Model\Address; -use Geocoder\Model\Position; +use Geocoder\Position; /** * @author William Durand @@ -19,12 +18,12 @@ interface Dumper { /** - * Dumps an `Address` object as a string representation of + * Dumps an `Position` object as a string representation of * the implemented format. * - * @param Position $address + * @param Position $position * * @return string */ - public function dump(Position $address); + public function dump(Position $position); } diff --git a/src/Geocoder/Dumper/GeoJson.php b/src/Geocoder/Dumper/GeoJson.php index f84c39eb2..878469db7 100644 --- a/src/Geocoder/Dumper/GeoJson.php +++ b/src/Geocoder/Dumper/GeoJson.php @@ -10,8 +10,7 @@ namespace Geocoder\Dumper; -use Geocoder\Model\Address; -use Geocoder\Model\Position; +use Geocoder\Position; /** * @author Jan Sorgalla @@ -21,9 +20,9 @@ class GeoJson implements Dumper /** * {@inheritDoc} */ - public function dump(Position $address) + public function dump(Position $position) { - $properties = array_filter($address->toArray(), function ($value) { + $properties = array_filter($position->toArray(), function ($value) { return !empty($value); }); @@ -41,12 +40,12 @@ public function dump(Position $address) 'type' => 'Feature', 'geometry' => [ 'type' => 'Point', - 'coordinates' => [ $address->getLongitude(), $address->getLatitude() ] + 'coordinates' => [ $position->getLongitude(), $position->getLatitude() ] ], 'properties' => $properties, ]; - if (null !== $bounds = $address->getBounds()) { + if (null !== $bounds = $position->getBounds()) { if ($bounds->isDefined()) { $json['bounds'] = $bounds->toArray(); } diff --git a/src/Geocoder/Dumper/Gpx.php b/src/Geocoder/Dumper/Gpx.php index 37887957b..cc0b9cf95 100644 --- a/src/Geocoder/Dumper/Gpx.php +++ b/src/Geocoder/Dumper/Gpx.php @@ -12,7 +12,7 @@ use Geocoder\Geocoder; use Geocoder\Model\Address; -use Geocoder\Model\Position; +use Geocoder\Position; /** * @author William Durand @@ -20,11 +20,11 @@ class Gpx implements Dumper { /** - * @param Position $address + * @param Position $position * * @return string */ - public function dump(Position $address) + public function dump(Position $position) { $gpx = sprintf(<< @@ -38,8 +38,8 @@ public function dump(Position $address) GPX , Geocoder::VERSION); - if ($address->getBounds()->isDefined()) { - $bounds = $address->getBounds(); + if ($position->getBounds()->isDefined()) { + $bounds = $position->getBounds(); $gpx .= sprintf(<< @@ -54,7 +54,7 @@ public function dump(Position $address) GPX - , $address->getLatitude(), $address->getLongitude(), $this->formatName($address)); + , $position->getLatitude(), $position->getLongitude(), $this->formatName($position)); $gpx .= << diff --git a/src/Geocoder/Dumper/Kml.php b/src/Geocoder/Dumper/Kml.php index 89b4f320e..173fefade 100644 --- a/src/Geocoder/Dumper/Kml.php +++ b/src/Geocoder/Dumper/Kml.php @@ -11,7 +11,7 @@ namespace Geocoder\Dumper; use Geocoder\Model\Address; -use Geocoder\Model\Position; +use Geocoder\Position; /** * @author Jan Sorgalla @@ -21,9 +21,9 @@ class Kml extends Gpx implements Dumper /** * {@inheritDoc} */ - public function dump(Position $address) + public function dump(Position $position) { - $name = $this->formatName($address); + $name = $this->formatName($position); $kml = << @@ -39,6 +39,6 @@ public function dump(Position $address) KML; - return sprintf($kml, $name, $name, $address->getLongitude(), $address->getLatitude()); + return sprintf($kml, $name, $name, $position->getLongitude(), $position->getLatitude()); } } diff --git a/src/Geocoder/Dumper/Wkb.php b/src/Geocoder/Dumper/Wkb.php index 43756a13a..12758ea85 100644 --- a/src/Geocoder/Dumper/Wkb.php +++ b/src/Geocoder/Dumper/Wkb.php @@ -11,7 +11,7 @@ namespace Geocoder\Dumper; use Geocoder\Model\Address; -use Geocoder\Model\Position; +use Geocoder\Position; /** * @author Jan Sorgalla @@ -21,8 +21,8 @@ class Wkb implements Dumper /** * {@inheritDoc} */ - public function dump(Position $address) + public function dump(Position $position) { - return pack('cLdd', 1, 1, $address->getLongitude(), $address->getLatitude()); + return pack('cLdd', 1, 1, $position->getLongitude(), $position->getLatitude()); } } diff --git a/src/Geocoder/Dumper/Wkt.php b/src/Geocoder/Dumper/Wkt.php index 007105b7e..23ce4d25d 100644 --- a/src/Geocoder/Dumper/Wkt.php +++ b/src/Geocoder/Dumper/Wkt.php @@ -11,7 +11,7 @@ namespace Geocoder\Dumper; use Geocoder\Model\Address; -use Geocoder\Model\Position; +use Geocoder\Position; /** * @author Jan Sorgalla @@ -21,8 +21,8 @@ class Wkt implements Dumper /** * {@inheritDoc} */ - public function dump(Position $address) + public function dump(Position $position) { - return sprintf('POINT(%F %F)', $address->getLongitude(), $address->getLatitude()); + return sprintf('POINT(%F %F)', $position->getLongitude(), $position->getLatitude()); } } diff --git a/src/Geocoder/Formatter/StringFormatter.php b/src/Geocoder/Formatter/StringFormatter.php index 6088d62f2..341312e0c 100644 --- a/src/Geocoder/Formatter/StringFormatter.php +++ b/src/Geocoder/Formatter/StringFormatter.php @@ -10,10 +10,8 @@ namespace Geocoder\Formatter; -use Geocoder\Model\Address; -use Geocoder\Model\Position; -use Geocoder\Model\AdminLevel; -use Geocoder\Model\AdminLevelCollectionInterface; +use Geocoder\Model\AdminLevelCollection; +use Geocoder\Position; /** * @author William Durand @@ -43,30 +41,30 @@ class StringFormatter /** * Transform an `Address` instance into a string representation. * - * @param Position $address + * @param Position $position * @param string $format * * @return string */ - public function format(Position $address, $format) + public function format(Position $position, $format) { $replace = [ - self::STREET_NUMBER => $address->getStreetNumber(), - self::STREET_NAME => $address->getStreetName(), - self::LOCALITY => $address->getLocality(), - self::POSTAL_CODE => $address->getPostalCode(), - self::SUB_LOCALITY => $address->getSubLocality(), - self::COUNTRY => $address->getCountry()->getName(), - self::COUNTRY_CODE => $address->getCountry()->getCode(), - self::TIMEZONE => $address->getTimezone(), + self::STREET_NUMBER => $position->getStreetNumber(), + self::STREET_NAME => $position->getStreetName(), + self::LOCALITY => $position->getLocality(), + self::POSTAL_CODE => $position->getPostalCode(), + self::SUB_LOCALITY => $position->getSubLocality(), + self::COUNTRY => $position->getCountry()->getName(), + self::COUNTRY_CODE => $position->getCountry()->getCode(), + self::TIMEZONE => $position->getTimezone(), ]; - for ($level = 1; $level <= AdminLevelCollectionInterface::MAX_LEVEL_DEPTH; $level ++) { + for ($level = 1; $level <= AdminLevelCollection::MAX_LEVEL_DEPTH; $level ++) { $replace[self::ADMIN_LEVEL . $level] = null; $replace[self::ADMIN_LEVEL_CODE . $level] = null; } - foreach ($address->getAdminLevels() as $level => $adminLevel) { + foreach ($position->getAdminLevels() as $level => $adminLevel) { $replace[self::ADMIN_LEVEL . $level] = $adminLevel->getName(); $replace[self::ADMIN_LEVEL_CODE . $level] = $adminLevel->getCode(); } From 59999fce7d88619f41ec17bf779daa4d64033998 Mon Sep 17 00:00:00 2001 From: Tobias Nyholm Date: Wed, 12 Oct 2016 10:32:53 +0200 Subject: [PATCH 05/21] bugfix --- src/Geocoder/ProviderAggregator.php | 5 +++-- tests/Geocoder/Tests/Model/AddressFactoryTest.php | 5 ++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Geocoder/ProviderAggregator.php b/src/Geocoder/ProviderAggregator.php index fa6abf535..5ecf43fd0 100644 --- a/src/Geocoder/ProviderAggregator.php +++ b/src/Geocoder/ProviderAggregator.php @@ -11,6 +11,7 @@ namespace Geocoder; use Geocoder\Exception\ProviderNotRegistered; +use Geocoder\Model\AddressCollection; use Geocoder\Provider\Provider; use Geocoder\Model\Address; @@ -51,7 +52,7 @@ public function geocode($value) if (empty($value)) { // let's save a request - return new Address(); + return new AddressCollection(); } return $this->getProvider() @@ -66,7 +67,7 @@ public function reverse($latitude, $longitude) { if (empty($latitude) || empty($longitude)) { // let's save a request - return new Address(); + return new AddressCollection(); } return $this->getProvider() diff --git a/tests/Geocoder/Tests/Model/AddressFactoryTest.php b/tests/Geocoder/Tests/Model/AddressFactoryTest.php index 015b80c13..294c0c183 100644 --- a/tests/Geocoder/Tests/Model/AddressFactoryTest.php +++ b/tests/Geocoder/Tests/Model/AddressFactoryTest.php @@ -3,6 +3,7 @@ namespace Geocoder\Tests\Model; use Geocoder\Model\AddressFactory; +use Geocoder\Position; use Geocoder\Tests\TestCase; /** @@ -11,6 +12,7 @@ */ class AddressFactoryTest extends TestCase { + /** @var AddressFactory */ private $factory; public function setUp() @@ -32,9 +34,10 @@ public function testCreateFromArray() $i = 1; foreach ($addresses as $address) { + /** @var $address Position */ $this->assertInstanceOf('Geocoder\Model\Address', $address); $this->assertInstanceOf('Geocoder\Model\Country', $address->getCountry()); - $this->assertNull($address->getCoordinates()); + $this->assertFalse($address->getCoordinates()->isDefined()); foreach ($address->getAdminLevels() as $level => $adminLevel) { $this->assertInstanceOf('Geocoder\Model\AdminLevel', $adminLevel); From 297fd19844628d66f547cfb22f6e77f74382c23a Mon Sep 17 00:00:00 2001 From: Tobias Nyholm Date: Wed, 12 Oct 2016 10:40:06 +0200 Subject: [PATCH 06/21] Removed unused "use" statements --- src/Geocoder/Dumper/Gpx.php | 1 - src/Geocoder/Dumper/Kml.php | 1 - src/Geocoder/Dumper/Wkb.php | 1 - src/Geocoder/Dumper/Wkt.php | 1 - 4 files changed, 4 deletions(-) diff --git a/src/Geocoder/Dumper/Gpx.php b/src/Geocoder/Dumper/Gpx.php index cc0b9cf95..c95b5114b 100644 --- a/src/Geocoder/Dumper/Gpx.php +++ b/src/Geocoder/Dumper/Gpx.php @@ -11,7 +11,6 @@ namespace Geocoder\Dumper; use Geocoder\Geocoder; -use Geocoder\Model\Address; use Geocoder\Position; /** diff --git a/src/Geocoder/Dumper/Kml.php b/src/Geocoder/Dumper/Kml.php index 173fefade..263b8cdb9 100644 --- a/src/Geocoder/Dumper/Kml.php +++ b/src/Geocoder/Dumper/Kml.php @@ -10,7 +10,6 @@ namespace Geocoder\Dumper; -use Geocoder\Model\Address; use Geocoder\Position; /** diff --git a/src/Geocoder/Dumper/Wkb.php b/src/Geocoder/Dumper/Wkb.php index 12758ea85..a80fbcd4c 100644 --- a/src/Geocoder/Dumper/Wkb.php +++ b/src/Geocoder/Dumper/Wkb.php @@ -10,7 +10,6 @@ namespace Geocoder\Dumper; -use Geocoder\Model\Address; use Geocoder\Position; /** diff --git a/src/Geocoder/Dumper/Wkt.php b/src/Geocoder/Dumper/Wkt.php index 23ce4d25d..6778a8ef7 100644 --- a/src/Geocoder/Dumper/Wkt.php +++ b/src/Geocoder/Dumper/Wkt.php @@ -10,7 +10,6 @@ namespace Geocoder\Dumper; -use Geocoder\Model\Address; use Geocoder\Position; /** From cf3213ba95cbe8673f1da00dbcd2262fb128348e Mon Sep 17 00:00:00 2001 From: Tobias Nyholm Date: Wed, 12 Oct 2016 10:44:21 +0200 Subject: [PATCH 07/21] bugfix --- src/Geocoder/Provider/Geonames.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Geocoder/Provider/Geonames.php b/src/Geocoder/Provider/Geonames.php index 2386049bc..2649c1458 100644 --- a/src/Geocoder/Provider/Geonames.php +++ b/src/Geocoder/Provider/Geonames.php @@ -13,7 +13,7 @@ use Geocoder\Exception\InvalidCredentials; use Geocoder\Exception\NoResult; use Geocoder\Exception\UnsupportedOperation; -use Geocoder\Model\AdminLevelCollectionInterface; +use Geocoder\Model\AdminLevelCollection; use Http\Client\HttpClient; /** @@ -138,7 +138,7 @@ private function executeQuery($query) $adminLevels = []; - for ($level = 1; $level <= AdminLevelCollectionInterface::MAX_LEVEL_DEPTH; ++ $level) { + for ($level = 1; $level <= AdminLevelCollection::MAX_LEVEL_DEPTH; ++ $level) { $adminNameProp = 'adminName' . $level; $adminCodeProp = 'adminCode' . $level; if (! empty($item->$adminNameProp) || ! empty($item->$adminCodeProp)) { From 7ac895a9909ca9ffced6b43141ea3a675438fb9f Mon Sep 17 00:00:00 2001 From: Tobias Nyholm Date: Wed, 12 Oct 2016 11:19:23 +0200 Subject: [PATCH 08/21] Added comment --- src/Geocoder/Position.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Geocoder/Position.php b/src/Geocoder/Position.php index 4f753832e..7f224b130 100644 --- a/src/Geocoder/Position.php +++ b/src/Geocoder/Position.php @@ -87,6 +87,8 @@ public function getSubLocality(); /** * Returns the administrative levels. * + * This method MUST NOT return null. + * * @return AdminLevelCollection */ public function getAdminLevels(); From f7ae14caceb7ad4d313b0648f2fc7153954909c8 Mon Sep 17 00:00:00 2001 From: Tobias Nyholm Date: Wed, 12 Oct 2016 11:19:29 +0200 Subject: [PATCH 09/21] Added test for empty address --- tests/Geocoder/Tests/Model/AddressTest.php | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 tests/Geocoder/Tests/Model/AddressTest.php diff --git a/tests/Geocoder/Tests/Model/AddressTest.php b/tests/Geocoder/Tests/Model/AddressTest.php new file mode 100644 index 000000000..9e74bf6e3 --- /dev/null +++ b/tests/Geocoder/Tests/Model/AddressTest.php @@ -0,0 +1,34 @@ + NULL, + 'longitude' => NULL, + 'bounds' => array ( + 'south' => NULL, + 'west' => NULL, + 'north' => NULL, + 'east' => NULL, + ), + 'streetNumber' => NULL, + 'streetName' => NULL, + 'postalCode' => NULL, + 'locality' => NULL, + 'subLocality' => NULL, + 'adminLevels' => array(), + 'country' => NULL, + 'countryCode' => NULL, + 'timezone' => NULL, + ); + + $address = new Address(); + $this->assertEquals($address->toArray(), $expected); + } +} \ No newline at end of file From c90304971922ebdbab1fcb95d0e12db98d5ddc84 Mon Sep 17 00:00:00 2001 From: Tobias Nyholm Date: Mon, 24 Oct 2016 13:18:40 +0200 Subject: [PATCH 10/21] Changed name from Position to Location --- src/Geocoder/Dumper/Dumper.php | 6 +++--- src/Geocoder/Dumper/GeoJson.php | 4 ++-- src/Geocoder/Dumper/Gpx.php | 10 +++++----- src/Geocoder/Dumper/Kml.php | 4 ++-- src/Geocoder/Dumper/Wkb.php | 4 ++-- src/Geocoder/Dumper/Wkt.php | 4 ++-- src/Geocoder/Formatter/StringFormatter.php | 6 +++--- src/Geocoder/GeocoderResult.php | 8 ++++---- src/Geocoder/{Position.php => Location.php} | 2 +- src/Geocoder/Model/Address.php | 10 +++++----- src/Geocoder/Model/AddressCollection.php | 14 +++++++------- tests/Geocoder/Tests/Model/AddressFactoryTest.php | 4 ++-- 12 files changed, 38 insertions(+), 38 deletions(-) rename src/Geocoder/{Position.php => Location.php} (99%) diff --git a/src/Geocoder/Dumper/Dumper.php b/src/Geocoder/Dumper/Dumper.php index cd358c9e6..812d342b6 100644 --- a/src/Geocoder/Dumper/Dumper.php +++ b/src/Geocoder/Dumper/Dumper.php @@ -10,7 +10,7 @@ namespace Geocoder\Dumper; -use Geocoder\Position; +use Geocoder\Location; /** * @author William Durand @@ -21,9 +21,9 @@ interface Dumper * Dumps an `Position` object as a string representation of * the implemented format. * - * @param Position $position + * @param Location $position * * @return string */ - public function dump(Position $position); + public function dump(Location $position); } diff --git a/src/Geocoder/Dumper/GeoJson.php b/src/Geocoder/Dumper/GeoJson.php index 878469db7..57c7fee04 100644 --- a/src/Geocoder/Dumper/GeoJson.php +++ b/src/Geocoder/Dumper/GeoJson.php @@ -10,7 +10,7 @@ namespace Geocoder\Dumper; -use Geocoder\Position; +use Geocoder\Location; /** * @author Jan Sorgalla @@ -20,7 +20,7 @@ class GeoJson implements Dumper /** * {@inheritDoc} */ - public function dump(Position $position) + public function dump(Location $position) { $properties = array_filter($position->toArray(), function ($value) { return !empty($value); diff --git a/src/Geocoder/Dumper/Gpx.php b/src/Geocoder/Dumper/Gpx.php index c95b5114b..ccd38a578 100644 --- a/src/Geocoder/Dumper/Gpx.php +++ b/src/Geocoder/Dumper/Gpx.php @@ -11,7 +11,7 @@ namespace Geocoder\Dumper; use Geocoder\Geocoder; -use Geocoder\Position; +use Geocoder\Location; /** * @author William Durand @@ -19,11 +19,11 @@ class Gpx implements Dumper { /** - * @param Position $position + * @param Location $position * * @return string */ - public function dump(Position $position) + public function dump(Location $position) { $gpx = sprintf(<< @@ -63,11 +63,11 @@ public function dump(Position $position) } /** - * @param Position $address + * @param Location $address * * @return string */ - protected function formatName(Position $address) + protected function formatName(Location $address) { $name = []; $array = $address->toArray(); diff --git a/src/Geocoder/Dumper/Kml.php b/src/Geocoder/Dumper/Kml.php index 263b8cdb9..09df78a58 100644 --- a/src/Geocoder/Dumper/Kml.php +++ b/src/Geocoder/Dumper/Kml.php @@ -10,7 +10,7 @@ namespace Geocoder\Dumper; -use Geocoder\Position; +use Geocoder\Location; /** * @author Jan Sorgalla @@ -20,7 +20,7 @@ class Kml extends Gpx implements Dumper /** * {@inheritDoc} */ - public function dump(Position $position) + public function dump(Location $position) { $name = $this->formatName($position); $kml = << @@ -20,7 +20,7 @@ class Wkb implements Dumper /** * {@inheritDoc} */ - public function dump(Position $position) + public function dump(Location $position) { return pack('cLdd', 1, 1, $position->getLongitude(), $position->getLatitude()); } diff --git a/src/Geocoder/Dumper/Wkt.php b/src/Geocoder/Dumper/Wkt.php index 6778a8ef7..1abb512bb 100644 --- a/src/Geocoder/Dumper/Wkt.php +++ b/src/Geocoder/Dumper/Wkt.php @@ -10,7 +10,7 @@ namespace Geocoder\Dumper; -use Geocoder\Position; +use Geocoder\Location; /** * @author Jan Sorgalla @@ -20,7 +20,7 @@ class Wkt implements Dumper /** * {@inheritDoc} */ - public function dump(Position $position) + public function dump(Location $position) { return sprintf('POINT(%F %F)', $position->getLongitude(), $position->getLatitude()); } diff --git a/src/Geocoder/Formatter/StringFormatter.php b/src/Geocoder/Formatter/StringFormatter.php index 341312e0c..bbd6889f0 100644 --- a/src/Geocoder/Formatter/StringFormatter.php +++ b/src/Geocoder/Formatter/StringFormatter.php @@ -11,7 +11,7 @@ namespace Geocoder\Formatter; use Geocoder\Model\AdminLevelCollection; -use Geocoder\Position; +use Geocoder\Location; /** * @author William Durand @@ -41,12 +41,12 @@ class StringFormatter /** * Transform an `Address` instance into a string representation. * - * @param Position $position + * @param Location $position * @param string $format * * @return string */ - public function format(Position $position, $format) + public function format(Location $position, $format) { $replace = [ self::STREET_NUMBER => $position->getStreetNumber(), diff --git a/src/Geocoder/GeocoderResult.php b/src/Geocoder/GeocoderResult.php index 5056e7544..e42b37806 100644 --- a/src/Geocoder/GeocoderResult.php +++ b/src/Geocoder/GeocoderResult.php @@ -21,12 +21,12 @@ public function getIterator(); public function count(); /** - * @return Position + * @return Location */ public function first(); /** - * @return Position[] + * @return Location[] */ public function slice($offset, $length = null); @@ -36,13 +36,13 @@ public function slice($offset, $length = null); public function has($index); /** - * @return Position + * @return Location * @throws \OutOfBoundsException */ public function get($index); /** - * @return Position[] + * @return Location[] */ public function all(); } \ No newline at end of file diff --git a/src/Geocoder/Position.php b/src/Geocoder/Location.php similarity index 99% rename from src/Geocoder/Position.php rename to src/Geocoder/Location.php index 7f224b130..29334e262 100644 --- a/src/Geocoder/Position.php +++ b/src/Geocoder/Location.php @@ -12,7 +12,7 @@ * @author William Durand * @author Tobias Nyholm */ -interface Position +interface Location { /** * Will always return the coordinates value object. diff --git a/src/Geocoder/Model/Address.php b/src/Geocoder/Model/Address.php index e9e6ab331..2b554bbd2 100644 --- a/src/Geocoder/Model/Address.php +++ b/src/Geocoder/Model/Address.php @@ -10,12 +10,12 @@ namespace Geocoder\Model; -use Geocoder\Position; +use Geocoder\Location; /** * @author William Durand */ -final class Address implements Position +final class Address implements Location { /** * @var Coordinates @@ -92,15 +92,15 @@ public function __construct( Country $country = null, $timezone = null ) { - $this->coordinates = $coordinates ?: new Coordinates(null, null); - $this->bounds = $bounds ?: new Bounds(null, null, null, null); + $this->coordinates = $coordinates ?: new Coordinates(); + $this->bounds = $bounds ?: new Bounds(); $this->streetNumber = $streetNumber; $this->streetName = $streetName; $this->postalCode = $postalCode; $this->locality = $locality; $this->subLocality = $subLocality; $this->adminLevels = $adminLevels ?: new AdminLevelCollection(); - $this->country = $country ?: new Country(null, null); + $this->country = $country ?: new Country(); $this->timezone = $timezone; } diff --git a/src/Geocoder/Model/AddressCollection.php b/src/Geocoder/Model/AddressCollection.php index f6255814e..868a3a2fd 100644 --- a/src/Geocoder/Model/AddressCollection.php +++ b/src/Geocoder/Model/AddressCollection.php @@ -4,17 +4,17 @@ use Geocoder\Exception\CollectionIsEmpty; use Geocoder\GeocoderResult; -use Geocoder\Position; +use Geocoder\Location; final class AddressCollection implements GeocoderResult { /** - * @var Position[] + * @var Location[] */ private $addresses; /** - * @param Position[] $addresses + * @param Location[] $addresses */ public function __construct(array $addresses = []) { @@ -38,7 +38,7 @@ public function count() } /** - * @return Position + * @return Location */ public function first() { @@ -50,7 +50,7 @@ public function first() } /** - * @return Position[] + * @return Location[] */ public function slice($offset, $length = null) { @@ -66,7 +66,7 @@ public function has($index) } /** - * @return Position + * @return Location * @throws \OutOfBoundsException */ public function get($index) @@ -79,7 +79,7 @@ public function get($index) } /** - * @return Position[] + * @return Location[] */ public function all() { diff --git a/tests/Geocoder/Tests/Model/AddressFactoryTest.php b/tests/Geocoder/Tests/Model/AddressFactoryTest.php index 294c0c183..55986b0be 100644 --- a/tests/Geocoder/Tests/Model/AddressFactoryTest.php +++ b/tests/Geocoder/Tests/Model/AddressFactoryTest.php @@ -3,7 +3,7 @@ namespace Geocoder\Tests\Model; use Geocoder\Model\AddressFactory; -use Geocoder\Position; +use Geocoder\Location; use Geocoder\Tests\TestCase; /** @@ -34,7 +34,7 @@ public function testCreateFromArray() $i = 1; foreach ($addresses as $address) { - /** @var $address Position */ + /** @var $address Location */ $this->assertInstanceOf('Geocoder\Model\Address', $address); $this->assertInstanceOf('Geocoder\Model\Country', $address->getCountry()); $this->assertFalse($address->getCoordinates()->isDefined()); From 02924dbfb59fc4d5e302924bff8764e09420fc1a Mon Sep 17 00:00:00 2001 From: Tobias Nyholm Date: Mon, 24 Oct 2016 13:18:56 +0200 Subject: [PATCH 11/21] Make constructor arguments optional --- src/Geocoder/Model/Bounds.php | 2 +- src/Geocoder/Model/Coordinates.php | 2 +- src/Geocoder/Model/Country.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Geocoder/Model/Bounds.php b/src/Geocoder/Model/Bounds.php index 27104d333..e496f86a0 100644 --- a/src/Geocoder/Model/Bounds.php +++ b/src/Geocoder/Model/Bounds.php @@ -41,7 +41,7 @@ final class Bounds * @param double $north * @param double $east */ - public function __construct($south, $west, $north, $east) + public function __construct($south = null, $west = null, $north = null, $east = null) { $this->south = $south; $this->west = $west; diff --git a/src/Geocoder/Model/Coordinates.php b/src/Geocoder/Model/Coordinates.php index 56d90cd4b..dbae36ad1 100644 --- a/src/Geocoder/Model/Coordinates.php +++ b/src/Geocoder/Model/Coordinates.php @@ -29,7 +29,7 @@ final class Coordinates * @param double $latitude * @param double $longitude */ - public function __construct($latitude, $longitude) + public function __construct($latitude = null, $longitude = null) { $this->latitude = $latitude; $this->longitude = $longitude; diff --git a/src/Geocoder/Model/Country.php b/src/Geocoder/Model/Country.php index 821dcf8ce..a0e2fd262 100644 --- a/src/Geocoder/Model/Country.php +++ b/src/Geocoder/Model/Country.php @@ -29,7 +29,7 @@ final class Country * @param string $name * @param string $code */ - public function __construct($name, $code) + public function __construct($name = null, $code = null) { $this->name = $name; $this->code = $code; From fb322518c75f75fd69bde1274e25b7687dd89044 Mon Sep 17 00:00:00 2001 From: Tobias Nyholm Date: Mon, 24 Oct 2016 13:20:17 +0200 Subject: [PATCH 12/21] We are defined even if (lat, lang) = (0, 0) --- src/Geocoder/Model/Coordinates.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Geocoder/Model/Coordinates.php b/src/Geocoder/Model/Coordinates.php index dbae36ad1..7255b730e 100644 --- a/src/Geocoder/Model/Coordinates.php +++ b/src/Geocoder/Model/Coordinates.php @@ -62,6 +62,6 @@ public function getLongitude() */ public function isDefined() { - return !empty($this->latitude) && !empty($this->longitude); + return $this->latitude !== null && $this->longitude !== null; } } From 114c9c2f8ef8174c821344adf63e83cae0cbf2d5 Mon Sep 17 00:00:00 2001 From: Tobias Nyholm Date: Mon, 24 Oct 2016 13:42:40 +0200 Subject: [PATCH 13/21] Updated variable names --- CHANGELOG.md | 11 ++++++ src/Geocoder/Dumper/Dumper.php | 6 +-- src/Geocoder/Dumper/GeoJson.php | 8 ++-- src/Geocoder/Dumper/Gpx.php | 10 ++--- src/Geocoder/Dumper/Kml.php | 6 +-- src/Geocoder/Dumper/Wkb.php | 4 +- src/Geocoder/Dumper/Wkt.php | 4 +- src/Geocoder/Formatter/StringFormatter.php | 22 +++++------ .../Tests/Model/AddressFactoryTest.php | 16 ++++---- .../Tests/Provider/ArcGISOnlineTest.php | 16 ++++---- .../Geocoder/Tests/Provider/BingMapsTest.php | 22 ++++++----- .../Geocoder/Tests/Provider/FreeGeoIpTest.php | 10 ++--- tests/Geocoder/Tests/Provider/GeoIP2Test.php | 6 +-- tests/Geocoder/Tests/Provider/GeoIPsTest.php | 10 ++--- tests/Geocoder/Tests/Provider/GeoipTest.php | 4 +- .../Geocoder/Tests/Provider/GeonamesTest.php | 24 ++++++------ .../Tests/Provider/GoogleMapsTest.php | 25 ++++++------ tests/Geocoder/Tests/Provider/HostIpTest.php | 7 ++-- .../Geocoder/Tests/Provider/IpInfoDbTest.php | 8 ++-- .../Geocoder/Tests/Provider/MapQuestTest.php | 16 ++++---- .../Tests/Provider/MaxMindBinaryTest.php | 9 +++-- tests/Geocoder/Tests/Provider/MaxMindTest.php | 21 +++++----- .../Geocoder/Tests/Provider/NominatimTest.php | 33 ++++++++-------- .../Geocoder/Tests/Provider/OpenCageTest.php | 20 +++++----- tests/Geocoder/Tests/Provider/TomTomTest.php | 22 +++++------ tests/Geocoder/Tests/Provider/YandexTest.php | 38 +++++++++---------- 26 files changed, 199 insertions(+), 179 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8bb806bfa..bff35d493 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,17 @@ CHANGELOG ========= +### 4.0.0 (2016-xx-xx) + +* Added: Interface for `Geocoder\Model\AddressCollection` called `Geocoder\GeocoderResult`. +* Added: Interface for `Geocoder\Model\Address` called `Geocoder\Location`. +* Added: `Country::isDefined` +* Added: `Cordinates::isDefined` +* Changed: `Location::getCorrdinates`, `Location::getBounds` and `Location::getCountry` will never return null. +* Removed: `AdminLevel::toString` in favor for `AdminLevel::__toString`. +* Removed: `Country::toString` in favor for `Country::__toString`. + + ### 3.3.0 (2015-12-06) * Added: timezone field for `FreeGeoIp` provider diff --git a/src/Geocoder/Dumper/Dumper.php b/src/Geocoder/Dumper/Dumper.php index 812d342b6..5c3fee3c2 100644 --- a/src/Geocoder/Dumper/Dumper.php +++ b/src/Geocoder/Dumper/Dumper.php @@ -18,12 +18,12 @@ interface Dumper { /** - * Dumps an `Position` object as a string representation of + * Dumps an `Location` object as a string representation of * the implemented format. * - * @param Location $position + * @param Location $location * * @return string */ - public function dump(Location $position); + public function dump(Location $location); } diff --git a/src/Geocoder/Dumper/GeoJson.php b/src/Geocoder/Dumper/GeoJson.php index 57c7fee04..6b2257563 100644 --- a/src/Geocoder/Dumper/GeoJson.php +++ b/src/Geocoder/Dumper/GeoJson.php @@ -20,9 +20,9 @@ class GeoJson implements Dumper /** * {@inheritDoc} */ - public function dump(Location $position) + public function dump(Location $location) { - $properties = array_filter($position->toArray(), function ($value) { + $properties = array_filter($location->toArray(), function ($value) { return !empty($value); }); @@ -40,12 +40,12 @@ public function dump(Location $position) 'type' => 'Feature', 'geometry' => [ 'type' => 'Point', - 'coordinates' => [ $position->getLongitude(), $position->getLatitude() ] + 'coordinates' => [$location->getCoordinates()->getLongitude(), $location->getCoordinates()->getLatitude()] ], 'properties' => $properties, ]; - if (null !== $bounds = $position->getBounds()) { + if (null !== $bounds = $location->getBounds()) { if ($bounds->isDefined()) { $json['bounds'] = $bounds->toArray(); } diff --git a/src/Geocoder/Dumper/Gpx.php b/src/Geocoder/Dumper/Gpx.php index ccd38a578..823660171 100644 --- a/src/Geocoder/Dumper/Gpx.php +++ b/src/Geocoder/Dumper/Gpx.php @@ -19,11 +19,11 @@ class Gpx implements Dumper { /** - * @param Location $position + * @param Location $location * * @return string */ - public function dump(Location $position) + public function dump(Location $location) { $gpx = sprintf(<< @@ -37,8 +37,8 @@ public function dump(Location $position) GPX , Geocoder::VERSION); - if ($position->getBounds()->isDefined()) { - $bounds = $position->getBounds(); + if ($location->getBounds()->isDefined()) { + $bounds = $location->getBounds(); $gpx .= sprintf(<< @@ -53,7 +53,7 @@ public function dump(Location $position) GPX - , $position->getLatitude(), $position->getLongitude(), $this->formatName($position)); + , $location->getLatitude(), $location->getLongitude(), $this->formatName($location)); $gpx .= << diff --git a/src/Geocoder/Dumper/Kml.php b/src/Geocoder/Dumper/Kml.php index 09df78a58..0c56123f6 100644 --- a/src/Geocoder/Dumper/Kml.php +++ b/src/Geocoder/Dumper/Kml.php @@ -20,9 +20,9 @@ class Kml extends Gpx implements Dumper /** * {@inheritDoc} */ - public function dump(Location $position) + public function dump(Location $location) { - $name = $this->formatName($position); + $name = $this->formatName($location); $kml = << @@ -38,6 +38,6 @@ public function dump(Location $position) KML; - return sprintf($kml, $name, $name, $position->getLongitude(), $position->getLatitude()); + return sprintf($kml, $name, $name, $location->getCoordinates()->getLongitude(), $location->getCoordinates()->getLatitude()); } } diff --git a/src/Geocoder/Dumper/Wkb.php b/src/Geocoder/Dumper/Wkb.php index b450df7e3..42fd7a56e 100644 --- a/src/Geocoder/Dumper/Wkb.php +++ b/src/Geocoder/Dumper/Wkb.php @@ -20,8 +20,8 @@ class Wkb implements Dumper /** * {@inheritDoc} */ - public function dump(Location $position) + public function dump(Location $location) { - return pack('cLdd', 1, 1, $position->getLongitude(), $position->getLatitude()); + return pack('cLdd', 1, 1, $location->getCoordinates()->getLongitude(), $location->getCoordinates()->getLatitude()); } } diff --git a/src/Geocoder/Dumper/Wkt.php b/src/Geocoder/Dumper/Wkt.php index 1abb512bb..3572a54b8 100644 --- a/src/Geocoder/Dumper/Wkt.php +++ b/src/Geocoder/Dumper/Wkt.php @@ -20,8 +20,8 @@ class Wkt implements Dumper /** * {@inheritDoc} */ - public function dump(Location $position) + public function dump(Location $location) { - return sprintf('POINT(%F %F)', $position->getLongitude(), $position->getLatitude()); + return sprintf('POINT(%F %F)', $location->getCoordinates()->getLongitude(), $location->getCoordinates()->getLatitude()); } } diff --git a/src/Geocoder/Formatter/StringFormatter.php b/src/Geocoder/Formatter/StringFormatter.php index bbd6889f0..39ca4f9da 100644 --- a/src/Geocoder/Formatter/StringFormatter.php +++ b/src/Geocoder/Formatter/StringFormatter.php @@ -41,22 +41,22 @@ class StringFormatter /** * Transform an `Address` instance into a string representation. * - * @param Location $position + * @param Location $location * @param string $format * * @return string */ - public function format(Location $position, $format) + public function format(Location $location, $format) { $replace = [ - self::STREET_NUMBER => $position->getStreetNumber(), - self::STREET_NAME => $position->getStreetName(), - self::LOCALITY => $position->getLocality(), - self::POSTAL_CODE => $position->getPostalCode(), - self::SUB_LOCALITY => $position->getSubLocality(), - self::COUNTRY => $position->getCountry()->getName(), - self::COUNTRY_CODE => $position->getCountry()->getCode(), - self::TIMEZONE => $position->getTimezone(), + self::STREET_NUMBER => $location->getStreetNumber(), + self::STREET_NAME => $location->getStreetName(), + self::LOCALITY => $location->getLocality(), + self::POSTAL_CODE => $location->getPostalCode(), + self::SUB_LOCALITY => $location->getSubLocality(), + self::COUNTRY => $location->getCountry()->getName(), + self::COUNTRY_CODE => $location->getCountry()->getCode(), + self::TIMEZONE => $location->getTimezone(), ]; for ($level = 1; $level <= AdminLevelCollection::MAX_LEVEL_DEPTH; $level ++) { @@ -64,7 +64,7 @@ public function format(Location $position, $format) $replace[self::ADMIN_LEVEL_CODE . $level] = null; } - foreach ($position->getAdminLevels() as $level => $adminLevel) { + foreach ($location->getAdminLevels() as $level => $adminLevel) { $replace[self::ADMIN_LEVEL . $level] = $adminLevel->getName(); $replace[self::ADMIN_LEVEL_CODE . $level] = $adminLevel->getCode(); } diff --git a/tests/Geocoder/Tests/Model/AddressFactoryTest.php b/tests/Geocoder/Tests/Model/AddressFactoryTest.php index 55986b0be..72afdd9d3 100644 --- a/tests/Geocoder/Tests/Model/AddressFactoryTest.php +++ b/tests/Geocoder/Tests/Model/AddressFactoryTest.php @@ -12,7 +12,7 @@ */ class AddressFactoryTest extends TestCase { - /** @var AddressFactory */ + /** @var AddressFactory */ private $factory; public function setUp() @@ -33,19 +33,19 @@ public function testCreateFromArray() $this->assertCount(3, $addresses); $i = 1; - foreach ($addresses as $address) { - /** @var $address Location */ - $this->assertInstanceOf('Geocoder\Model\Address', $address); - $this->assertInstanceOf('Geocoder\Model\Country', $address->getCountry()); - $this->assertFalse($address->getCoordinates()->isDefined()); + foreach ($addresses as $location) { + /** @var $location Location */ + $this->assertInstanceOf('Geocoder\Model\Address', $location); + $this->assertInstanceOf('Geocoder\Model\Country', $location->getCountry()); + $this->assertFalse($location->getCoordinates()->isDefined()); - foreach ($address->getAdminLevels() as $level => $adminLevel) { + foreach ($location->getAdminLevels() as $level => $adminLevel) { $this->assertInstanceOf('Geocoder\Model\AdminLevel', $adminLevel); $this->assertSame($level, $adminLevel->getLevel()); $this->assertEquals('admin ' . $level, $adminLevel->getName()); } - $this->assertEquals($i++, $address->getStreetNumber()); + $this->assertEquals($i++, $location->getStreetNumber()); } } diff --git a/tests/Geocoder/Tests/Provider/ArcGISOnlineTest.php b/tests/Geocoder/Tests/Provider/ArcGISOnlineTest.php index f5c173534..f03726179 100644 --- a/tests/Geocoder/Tests/Provider/ArcGISOnlineTest.php +++ b/tests/Geocoder/Tests/Provider/ArcGISOnlineTest.php @@ -2,7 +2,7 @@ namespace Geocoder\Tests\Provider; -use Geocoder\Model\Position; +use Geocoder\Location; use Geocoder\Tests\TestCase; use Geocoder\Provider\ArcGISOnline; @@ -81,7 +81,7 @@ public function testGeocodeWithRealAddress() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(5, $results); - /** @var Position $result */ + /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(48.863279997000461, $result->getLatitude(), '', 0.0001); @@ -182,7 +182,7 @@ public function testReverseWithRealCoordinates() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var Position $result */ + /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(48.863279997000461, $result->getLatitude(), '', 0.0001); @@ -234,7 +234,7 @@ public function testGeocodeWithCity() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(5, $results); - /** @var Position $result */ + /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(52.370518568000477, $result->getLatitude(), '', 0.0001); @@ -252,7 +252,7 @@ public function testGeocodeWithCity() $this->assertNull($result->getCountry()->getName()); $this->assertNull($result->getTimezone()); - /** @var Position $result */ + /** @var Location $result */ $result = $results->get(1); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(47.111386795000499, $result->getLatitude(), '', 0.0001); @@ -263,7 +263,7 @@ public function testGeocodeWithCity() $this->assertEquals('North Dakota', $result->getAdminLevels()->get(1)->getName()); $this->assertEquals('USA', $result->getCountry()->getCode()); - /** @var Position $result */ + /** @var Location $result */ $result = $results->get(2); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(39.391768472000479, $result->getLatitude(), '', 0.0001); @@ -274,7 +274,7 @@ public function testGeocodeWithCity() $this->assertEquals('Maryland', $result->getAdminLevels()->get(1)->getName()); $this->assertEquals('USA', $result->getCountry()->getCode()); - /** @var Position $result */ + /** @var Location $result */ $result = $results->get(3); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(53.174198173, $result->getLatitude(), '', 0.0001); @@ -285,7 +285,7 @@ public function testGeocodeWithCity() $this->assertEquals('Niedersachsen', $result->getAdminLevels()->get(1)->getName()); $this->assertEquals('DEU', $result->getCountry()->getCode()); - /** @var Position $result */ + /** @var Location $result */ $result = $results->get(4); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(-26.281805980999593, $result->getLatitude(), '', 0.0001); diff --git a/tests/Geocoder/Tests/Provider/BingMapsTest.php b/tests/Geocoder/Tests/Provider/BingMapsTest.php index a58cf0118..db8873efe 100644 --- a/tests/Geocoder/Tests/Provider/BingMapsTest.php +++ b/tests/Geocoder/Tests/Provider/BingMapsTest.php @@ -2,7 +2,7 @@ namespace Geocoder\Tests\Provider; -use Geocoder\Model\Position; +use Geocoder\Location; use Geocoder\Tests\TestCase; use Geocoder\Provider\BingMaps; @@ -95,7 +95,7 @@ public function testGeocodeReturnsMultipleResults() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(3, $results); - /** @var Position $result */ + /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(48.86321675999999, $result->getLatitude(), '', 0.01); @@ -117,7 +117,7 @@ public function testGeocodeReturnsMultipleResults() $this->assertNull($result->getTimezone()); - /** @var Position $result */ + /** @var Location $result */ $result = $results->get(1); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(48.81342781, $result->getLatitude(), '', 0.01); @@ -137,7 +137,7 @@ public function testGeocodeReturnsMultipleResults() $this->assertEquals('France', $result->getCountry()->getName()); $this->assertEquals('FR', $result->getCountry()->getCode()); - /** @var Position $result */ + /** @var Location $result */ $result = $results->get(2); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(48.81014147, $result->getLatitude(), '', 0.01); @@ -170,7 +170,7 @@ public function testReverseReturnsSingleResult() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var Position $result */ + /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(48.86321648955345, $result->getLatitude(), '', 0.0001); @@ -205,6 +205,7 @@ public function testGeocodeWithRealAddressReturnsSingleResults() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); + /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(48.86321675999999, $result->getLatitude(), '', 0.01); @@ -242,6 +243,7 @@ public function testGeocodeWithRealAddressReturnsMultipleResults() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(5, $results); + /** @var Location $result */ $result = $results->get(0); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(44.786701202393, $result->getLatitude(), '', 0.01); @@ -261,7 +263,7 @@ public function testGeocodeWithRealAddressReturnsMultipleResults() $this->assertEquals('Italie', $result->getCountry()->getName()); $this->assertEquals('IT', $result->getCountry()->getCode()); - /** @var Position $result */ + /** @var Location $result */ $result = $results->get(1); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(46.05179977417, $result->getLatitude(), '', 0.01); @@ -281,7 +283,7 @@ public function testGeocodeWithRealAddressReturnsMultipleResults() $this->assertEquals('Italie', $result->getCountry()->getName()); $this->assertEquals('IT', $result->getCountry()->getCode()); - /** @var Position $result */ + /** @var Location $result */ $result = $results->get(2); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(44.987880706787, $result->getLatitude(), '', 0.01); @@ -301,7 +303,7 @@ public function testGeocodeWithRealAddressReturnsMultipleResults() $this->assertEquals('Italie', $result->getCountry()->getName()); $this->assertEquals('IT', $result->getCountry()->getCode()); - /** @var Position $result */ + /** @var Location $result */ $result = $results->get(3); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(43.82638168335, $result->getLatitude(), '', 0.01); @@ -321,7 +323,7 @@ public function testGeocodeWithRealAddressReturnsMultipleResults() $this->assertEquals('Italie', $result->getCountry()->getName()); $this->assertEquals('IT', $result->getCountry()->getCode()); - /** @var Position $result */ + /** @var Location $result */ $result = $results->get(4); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(42.295810699463, $result->getLatitude(), '', 0.01); @@ -374,7 +376,7 @@ public function testReverseWithRealCoordinatesReturnsSingleResult() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var Position $result */ + /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(48.86321648955345, $result->getLatitude(), '', 0.0001); diff --git a/tests/Geocoder/Tests/Provider/FreeGeoIpTest.php b/tests/Geocoder/Tests/Provider/FreeGeoIpTest.php index 4297f4fd5..defb3bf1e 100644 --- a/tests/Geocoder/Tests/Provider/FreeGeoIpTest.php +++ b/tests/Geocoder/Tests/Provider/FreeGeoIpTest.php @@ -2,7 +2,7 @@ namespace Geocoder\Tests\Provider; -use Geocoder\Model\Position; +use Geocoder\Location; use Geocoder\Tests\TestCase; use Geocoder\Provider\FreeGeoIp; @@ -52,7 +52,7 @@ public function testGeocodeWithLocalhostIPv4() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var Position $result */ + /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals('localhost', $result->getLocality()); @@ -67,7 +67,7 @@ public function testGeocodeWithLocalhostIPv6() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var Position $result */ + /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals('localhost', $result->getLocality()); @@ -102,7 +102,7 @@ public function testGeocodeWithRealIPv4() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var Position $result */ + /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(33.0347, $result->getLatitude(), '', 0.01); @@ -123,7 +123,7 @@ public function testGeocodeWithRealIPv6() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var Position $result */ + /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(33.0347, $result->getLatitude(), '', 0.01); diff --git a/tests/Geocoder/Tests/Provider/GeoIP2Test.php b/tests/Geocoder/Tests/Provider/GeoIP2Test.php index 5327dac3d..87ecffd4c 100644 --- a/tests/Geocoder/Tests/Provider/GeoIP2Test.php +++ b/tests/Geocoder/Tests/Provider/GeoIP2Test.php @@ -11,7 +11,7 @@ namespace Geocoder\Tests\Provider; use Geocoder\Exception\NoResult; -use Geocoder\Model\Position; +use Geocoder\Location; use Geocoder\Provider\GeoIP2; use Geocoder\Tests\TestCase; @@ -51,7 +51,7 @@ public function testGeocodeWithLocalhostIPv4() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var Position $result */ + /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals('localhost', $result->getLocality()); @@ -163,7 +163,7 @@ public function testRetrievingGeodata($address, $adapterResponse, $expectedGeoda $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var Position $result */ + /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals($expectedGeodata['latitude'], $result->getLatitude()); diff --git a/tests/Geocoder/Tests/Provider/GeoIPsTest.php b/tests/Geocoder/Tests/Provider/GeoIPsTest.php index 80ced45e0..d0ae23eef 100644 --- a/tests/Geocoder/Tests/Provider/GeoIPsTest.php +++ b/tests/Geocoder/Tests/Provider/GeoIPsTest.php @@ -2,7 +2,7 @@ namespace Geocoder\Tests\Provider; -use Geocoder\Model\Position; +use Geocoder\Location; use Geocoder\Tests\TestCase; use Geocoder\Provider\GeoIPs; @@ -61,7 +61,7 @@ public function testGeocodeWithLocalhostIPv4() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var Position $result */ + /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals('localhost', $result->getLocality()); @@ -132,7 +132,7 @@ public function testGeocodeWithRealIPv4GetsFakeContentFormattedEmpty() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var Position $result */ + /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertNull($result->getLatitude()); @@ -175,7 +175,7 @@ public function testGeocodeWithRealIPv4GetsFakeContent() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var Position $result */ + /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(40.3402, $result->getLatitude(), '', 0.0001); @@ -334,7 +334,7 @@ public function testGeocodeWithRealIPv4() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var Position $result */ + /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(40.3402, $result->getLatitude(), '', 0.0001); diff --git a/tests/Geocoder/Tests/Provider/GeoipTest.php b/tests/Geocoder/Tests/Provider/GeoipTest.php index 6f585e6a3..708e4290a 100644 --- a/tests/Geocoder/Tests/Provider/GeoipTest.php +++ b/tests/Geocoder/Tests/Provider/GeoipTest.php @@ -2,7 +2,7 @@ namespace Geocoder\Tests\Provider; -use Geocoder\Model\Position; +use Geocoder\Location; use Geocoder\Tests\TestCase; use Geocoder\Provider\Geoip; @@ -61,7 +61,7 @@ public function testGeocodeWithLocalhostIPv4() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var Position $result */ + /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('Geocoder\Model\Address', $result); $this->assertNull($result->getLatitude()); diff --git a/tests/Geocoder/Tests/Provider/GeonamesTest.php b/tests/Geocoder/Tests/Provider/GeonamesTest.php index 6af9499c0..d1f54c20b 100644 --- a/tests/Geocoder/Tests/Provider/GeonamesTest.php +++ b/tests/Geocoder/Tests/Provider/GeonamesTest.php @@ -2,7 +2,7 @@ namespace Geocoder\Tests\Provider; -use Geocoder\Model\Position; +use Geocoder\Location; use Geocoder\Tests\TestCase; use Geocoder\Provider\Geonames; @@ -92,6 +92,7 @@ public function testGeocodeWithRealPlace() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(5, $results); + /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(51.508528775863, $result->getLatitude(), '', 0.01); @@ -109,6 +110,7 @@ public function testGeocodeWithRealPlace() $this->assertEquals('GB', $result->getCountryCode()); $this->assertEquals('Europe/London', $result->getTimezone()); + /** @var Location $result */ $result = $results->get(1); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(-33.015285093464, $result->getLatitude(), '', 0.01); @@ -127,7 +129,7 @@ public function testGeocodeWithRealPlace() $this->assertEquals('ZA', $result->getCountryCode()); $this->assertEquals('Africa/Johannesburg', $result->getTimezone()); - /** @var Position $result */ + /** @var Location $result */ $result = $results->get(2); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(51.512788890295, $result->getLatitude(), '', 0.01); @@ -146,7 +148,7 @@ public function testGeocodeWithRealPlace() $this->assertEquals('GB', $result->getCountryCode()); $this->assertEquals('Europe/London', $result->getTimezone()); - /** @var Position $result */ + /** @var Location $result */ $result = $results->get(3); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(42.983389283, $result->getLatitude(), '', 0.01); @@ -163,7 +165,7 @@ public function testGeocodeWithRealPlace() $this->assertEquals('CA', $result->getCountryCode()); $this->assertEquals('America/Toronto', $result->getTimezone()); - /** @var Position $result */ + /** @var Location $result */ $result = $results->get(4); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(41.3556539, $result->getLatitude(), '', 0.01); @@ -194,7 +196,7 @@ public function testGeocodeWithRealPlaceWithLocale() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(5, $results); - /** @var Position $result */ + /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(51.50853, $result->getLatitude(), '', 0.01); @@ -212,7 +214,7 @@ public function testGeocodeWithRealPlaceWithLocale() $this->assertEquals('GB', $result->getCountryCode()); $this->assertEquals('Europe/London', $result->getTimezone()); - /** @var Position $result */ + /** @var Location $result */ $result = $results->get(1); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(-33.015285093464, $result->getLatitude(), '', 0.01); @@ -231,7 +233,7 @@ public function testGeocodeWithRealPlaceWithLocale() $this->assertEquals('ZA', $result->getCountryCode()); $this->assertEquals('Africa/Johannesburg', $result->getTimezone()); - /** @var Position $result */ + /** @var Location $result */ $result = $results->get(2); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(51.512788890295, $result->getLatitude(), '', 0.01); @@ -250,7 +252,7 @@ public function testGeocodeWithRealPlaceWithLocale() $this->assertEquals('GB', $result->getCountryCode()); $this->assertEquals('Europe/London', $result->getTimezone()); - /** @var Position $result */ + /** @var Location $result */ $result = $results->get(3); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(42.983389283, $result->getLatitude(), '', 0.01); @@ -267,7 +269,7 @@ public function testGeocodeWithRealPlaceWithLocale() $this->assertEquals('CA', $result->getCountryCode()); $this->assertEquals('America/Toronto', $result->getTimezone()); - /** @var Position $result */ + /** @var Location $result */ $result = $results->get(4); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(41.3556539, $result->getLatitude(), '', 0.01); @@ -298,7 +300,7 @@ public function testReverseWithRealCoordinates() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var Position $result */ + /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(51.50853, $result->getLatitude(), '', 0.01); @@ -324,7 +326,7 @@ public function testReverseWithRealCoordinatesWithLocale() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var Position $result */ + /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(51.50853, $result->getLatitude(), '', 0.01); diff --git a/tests/Geocoder/Tests/Provider/GoogleMapsTest.php b/tests/Geocoder/Tests/Provider/GoogleMapsTest.php index ca9b0b4bb..ae01ffceb 100644 --- a/tests/Geocoder/Tests/Provider/GoogleMapsTest.php +++ b/tests/Geocoder/Tests/Provider/GoogleMapsTest.php @@ -3,7 +3,7 @@ namespace Geocoder\Tests\Provider; use Geocoder\Exception\NoResult; -use Geocoder\Model\Position; +use Geocoder\Location; use Geocoder\Tests\TestCase; use Geocoder\Provider\GoogleMaps; use Http\Client\HttpClient; @@ -120,7 +120,7 @@ public function testGeocodeWithRealAddress() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var Position $result */ + /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(48.8630462, $result->getLatitude(), '', 0.001); @@ -151,7 +151,7 @@ public function testGeocodeWithRealAddressWithSsl() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var Position $result */ + /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(48.8630462, $result->getLatitude(), '', 0.001); @@ -183,6 +183,7 @@ public function testGeocodeBoundsWithRealAddressForNonRooftopLocation() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); + /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertTrue($result->getBounds()->isDefined()); @@ -200,7 +201,7 @@ public function testGeocodeWithRealAddressReturnsMultipleResults() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(5, $results); - /** @var Position $result */ + /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(48.856614, $result->getLatitude(), '', 0.001); @@ -209,7 +210,7 @@ public function testGeocodeWithRealAddressReturnsMultipleResults() $this->assertEquals('France', $result->getCountry()->getName()); $this->assertEquals('FR', $result->getCountry()->getCode()); - /** @var Position $result */ + /** @var Location $result */ $result = $results->get(1); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(33.6609389, $result->getLatitude(), '', 0.001); @@ -218,7 +219,7 @@ public function testGeocodeWithRealAddressReturnsMultipleResults() $this->assertEquals('United States', $result->getCountry()->getName()); $this->assertEquals('US', $result->getCountry()->getCode()); - /** @var Position $result */ + /** @var Location $result */ $result = $results->get(2); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(36.3020023, $result->getLatitude(), '', 0.001); @@ -227,7 +228,7 @@ public function testGeocodeWithRealAddressReturnsMultipleResults() $this->assertEquals('United States', $result->getCountry()->getName()); $this->assertEquals('US', $result->getCountry()->getCode()); - /** @var Position $result */ + /** @var Location $result */ $result = $results->get(3); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(39.611146, $result->getLatitude(), '', 0.001); @@ -236,7 +237,7 @@ public function testGeocodeWithRealAddressReturnsMultipleResults() $this->assertEquals('United States', $result->getCountry()->getName()); $this->assertEquals('US', $result->getCountry()->getCode()); - /** @var Position $result */ + /** @var Location $result */ $result = $results->get(4); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(38.2097987, $result->getLatitude(), '', 0.001); @@ -264,7 +265,7 @@ public function testReverseWithRealCoordinates() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(5, $results); - /** @var Position $result */ + /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(1, $result->getStreetNumber()); @@ -296,7 +297,7 @@ public function testGeocodeWithCityDistrict() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var Position $result */ + /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals('Kalbach-Riedberg', $result->getSubLocality()); @@ -325,7 +326,7 @@ public function testGeocodeWithRealValidApiKey() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var Position $result */ + /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertNotNull($result->getLatitude()); @@ -356,7 +357,7 @@ public function testGeocodePostalTown() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var Position $result */ + /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals('Pontypridd', $result->getLocality()); diff --git a/tests/Geocoder/Tests/Provider/HostIpTest.php b/tests/Geocoder/Tests/Provider/HostIpTest.php index 3edbdcced..bc456b2d8 100644 --- a/tests/Geocoder/Tests/Provider/HostIpTest.php +++ b/tests/Geocoder/Tests/Provider/HostIpTest.php @@ -2,7 +2,7 @@ namespace Geocoder\Tests\Provider; -use Geocoder\Model\Position; +use Geocoder\Location; use Geocoder\Tests\TestCase; use Geocoder\Provider\HostIp; @@ -52,7 +52,7 @@ public function testGeocodeWithLocalhostIPv4() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var Position $result */ + /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertNull($result->getLatitude()); @@ -103,7 +103,7 @@ public function testGeocodeWithRealIPv4() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var Position $result */ + /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(45.5333, $result->getLatitude(), '', 0.0001); @@ -143,6 +143,7 @@ public function testGeocodeWithAnotherIp() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); + /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertNull($result->getLatitude()); diff --git a/tests/Geocoder/Tests/Provider/IpInfoDbTest.php b/tests/Geocoder/Tests/Provider/IpInfoDbTest.php index 855fea4ab..2763829d0 100644 --- a/tests/Geocoder/Tests/Provider/IpInfoDbTest.php +++ b/tests/Geocoder/Tests/Provider/IpInfoDbTest.php @@ -2,7 +2,7 @@ namespace Geocoder\Tests\Provider; -use Geocoder\Model\Position; +use Geocoder\Location; use Geocoder\Tests\TestCase; use Geocoder\Provider\IpInfoDb; @@ -80,7 +80,7 @@ public function testGeocodeWithLocalhostIPv4() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var Position $result */ + /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertNull($result->getLatitude()); @@ -135,7 +135,7 @@ public function testGeocodeWithRealIPv4() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var Position $result */ + /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(37.406, $result->getLatitude(), '', 0.001); @@ -178,7 +178,7 @@ public function testGetGeocodedDataWithCountryPrecision() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var Position $result */ + /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertNull($result->getLatitude()); diff --git a/tests/Geocoder/Tests/Provider/MapQuestTest.php b/tests/Geocoder/Tests/Provider/MapQuestTest.php index 8760df3b0..f55f6ec4e 100644 --- a/tests/Geocoder/Tests/Provider/MapQuestTest.php +++ b/tests/Geocoder/Tests/Provider/MapQuestTest.php @@ -2,7 +2,7 @@ namespace Geocoder\Tests\Provider; -use Geocoder\Model\Position; +use Geocoder\Location; use Geocoder\Tests\TestCase; use Geocoder\Provider\MapQuest; @@ -61,7 +61,7 @@ public function testGeocodeWithRealAddress() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var Position $result */ + /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(48.866205, $result->getLatitude(), '', 0.01); @@ -106,7 +106,7 @@ public function testReverseWithRealCoordinates() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var Position $result */ + /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(54.0484068, $result->getLatitude(), '', 0.001); @@ -138,7 +138,7 @@ public function testGeocodeWithCity() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(5, $results); - /** @var Position $result */ + /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(52.374478, $result->getLatitude(), '', 0.01); @@ -150,7 +150,7 @@ public function testGeocodeWithCity() $this->assertEquals('DE', $result->getCountry()->getName()); $this->assertEquals('DE', $result->getCountry()->getCode()); - /** @var Position $result */ + /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(52.374478000000003, $result->getLatitude(), '', 0.01); @@ -162,7 +162,7 @@ public function testGeocodeWithCity() $this->assertEquals('DE', $result->getCountry()->getName()); $this->assertEquals('DE', $result->getCountry()->getCode()); - /** @var Position $result */ + /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(52.374478000000003, $result->getLatitude(), '', 0.01); @@ -174,7 +174,7 @@ public function testGeocodeWithCity() $this->assertEquals('DE', $result->getCountry()->getName()); $this->assertEquals('DE', $result->getCountry()->getCode()); - /** @var Position $result */ + /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(52.374478000000003, $result->getLatitude(), '', 0.01); @@ -199,7 +199,7 @@ public function testGeocodeWithCityDistrict() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var Position $result */ + /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(50.189062, $result->getLatitude(), '', 0.01); diff --git a/tests/Geocoder/Tests/Provider/MaxMindBinaryTest.php b/tests/Geocoder/Tests/Provider/MaxMindBinaryTest.php index c7fc85462..f2551fe51 100644 --- a/tests/Geocoder/Tests/Provider/MaxMindBinaryTest.php +++ b/tests/Geocoder/Tests/Provider/MaxMindBinaryTest.php @@ -1,7 +1,7 @@ assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var Position $result */ + /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); @@ -78,7 +78,7 @@ public function testLocationResultContainsExpectedFieldsForASpanishIp() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var Position $result */ + /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); @@ -109,7 +109,7 @@ public function testFindLocationByIp($ip, $expectedCity, $expectedCountry) $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var Position $result */ + /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals($expectedCity, $result->getLocality()); @@ -121,6 +121,7 @@ public function testShouldReturnResultsAsUtf8Encoded() $provider = new MaxMindBinary($this->binaryFile); $results = $provider->geocode('212.51.181.237'); + /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertSame('Châlette-sur-loing', $result->getLocality()); diff --git a/tests/Geocoder/Tests/Provider/MaxMindTest.php b/tests/Geocoder/Tests/Provider/MaxMindTest.php index 0074af20f..86894ccd4 100644 --- a/tests/Geocoder/Tests/Provider/MaxMindTest.php +++ b/tests/Geocoder/Tests/Provider/MaxMindTest.php @@ -2,7 +2,7 @@ namespace Geocoder\Tests\Provider; -use Geocoder\Model\Position; +use Geocoder\Location; use Geocoder\Tests\TestCase; use Geocoder\Provider\MaxMind; @@ -61,7 +61,7 @@ public function testGeocodeWithLocalhostIPv4() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var Position $result */ + /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals('localhost', $result->getLocality()); @@ -76,7 +76,7 @@ public function testGeocodeWithLocalhostIPv6() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var Position $result */ + /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals('localhost', $result->getLocality()); @@ -131,7 +131,7 @@ public function testGeocodeWithRealIPv4GetsFakeContentFormattedEmpty() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var Position $result */ + /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertNull($result->getLatitude()); @@ -156,7 +156,7 @@ public function testGeocodeWithRealIPv4GetsFakeContent() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var Position $result */ + /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(33.034698486328, $result->getLatitude(), '', 0.0001); @@ -188,7 +188,7 @@ public function testGeocodeWithRealIPv4GetsFakeContent() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var Position $result */ + /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(37.748402, $result->getLatitude(), '', 0.0001); @@ -301,7 +301,7 @@ public function testGeocodeServiceWithRealIPv4() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var Position $result */ + /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(33.034698, $result->getLatitude(), '', 0.1); @@ -333,7 +333,7 @@ public function testGeocodeOmniServiceWithRealIPv4() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var Position $result */ + /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(33.0347, $result->getLatitude(), '', 0.1); @@ -365,6 +365,7 @@ public function testGeocodeOmniServiceWithRealIPv4WithSslAndEncoding() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); + /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(-27.5833, $result->getLatitude(), '', 0.1); @@ -395,7 +396,7 @@ public function testGeocodeWithRealIPv6() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var Position $result */ + /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(40.2181, $result->getLatitude(), '', 0.1); @@ -427,7 +428,7 @@ public function testGeocodeOmniServiceWithRealIPv6WithSsl() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var Position $result */ + /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(40.2181, $result->getLatitude(), '', 0.1); diff --git a/tests/Geocoder/Tests/Provider/NominatimTest.php b/tests/Geocoder/Tests/Provider/NominatimTest.php index 7fba5dd59..a9e02d475 100644 --- a/tests/Geocoder/Tests/Provider/NominatimTest.php +++ b/tests/Geocoder/Tests/Provider/NominatimTest.php @@ -2,7 +2,7 @@ namespace Geocoder\Tests\Provider; -use Geocoder\Model\Position; +use Geocoder\Location; use Geocoder\Provider\Nominatim; use Geocoder\Tests\TestCase; @@ -16,7 +16,7 @@ public function testGeocodeWithRealAddress() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(5, $results); - /** @var Position $result */ + /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(48.8565056, $result->getLatitude(), '', 0.01); @@ -38,7 +38,7 @@ public function testGeocodeWithRealAddress() $this->assertEquals('France', $result->getCountry()->getName()); $this->assertEquals('FR', $result->getCountry()->getCode()); - /** @var Position $result */ + /** @var Location $result */ $result = $results->get(1); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(48.8588408, $result->getLatitude(), '', 0.01); @@ -60,7 +60,7 @@ public function testGeocodeWithRealAddress() $this->assertEquals('France', $result->getCountry()->getName()); $this->assertEquals('FR', $result->getCountry()->getCode()); - /** @var Position $result */ + /** @var Location $result */ $result = $results->get(2); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(35.28687645, $result->getLatitude(), '', 0.01); @@ -82,7 +82,7 @@ public function testGeocodeWithRealAddress() $this->assertEquals('United States of America', $result->getCountry()->getName()); $this->assertEquals('US', $result->getCountry()->getCode()); - /** @var Position $result */ + /** @var Location $result */ $result = $results->get(3); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(33.6751155, $result->getLatitude(), '', 0.01); @@ -104,7 +104,7 @@ public function testGeocodeWithRealAddress() $this->assertEquals('United States of America', $result->getCountry()->getName()); $this->assertEquals('US', $result->getCountry()->getCode()); - /** @var Position $result */ + /** @var Location $result */ $result = $results->get(4); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(38.2097987, $result->getLatitude(), '', 0.01); @@ -135,7 +135,7 @@ public function testGeocodeWithRealAddressWithLocale() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(2, $results); - /** @var Position $result */ + /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(45.7586841, $result->getLatitude(), '', 0.01); @@ -157,6 +157,7 @@ public function testGeocodeWithRealAddressWithLocale() $this->assertEquals('France', $result->getCountry()->getName()); $this->assertEquals('FR', $result->getCountry()->getCode()); + /** @var Location $result */ $result = $results->get(1); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(45.7586841, $result->getLatitude(), '', 0.01); @@ -187,7 +188,7 @@ public function testReverseWithRealCoordinates() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var Position $result */ + /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(60.4539, $result->getLatitude(), '', 0.001); @@ -224,7 +225,7 @@ public function testReverseWithRealCoordinatesWithLocale() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(5, $results); - /** @var Position $result */ + /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(50.1856803, $result->getLatitude(), '', 0.01); @@ -245,7 +246,7 @@ public function testReverseWithRealCoordinatesWithLocale() $this->assertEquals('Deutschland', $result->getCountry()->getName()); $this->assertEquals('DE', $result->getCountry()->getCode()); - /** @var Position $result */ + /** @var Location $result */ $result = $results->get(1); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(50.1845911, $result->getLatitude(), '', 0.01); @@ -266,7 +267,7 @@ public function testReverseWithRealCoordinatesWithLocale() $this->assertEquals('Deutschland', $result->getCountry()->getName()); $this->assertEquals('DE', $result->getCountry()->getCode()); - /** @var Position $result */ + /** @var Location $result */ $result = $results->get(2); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(50.1862884, $result->getLatitude(), '', 0.01); @@ -287,7 +288,7 @@ public function testReverseWithRealCoordinatesWithLocale() $this->assertEquals('Deutschland', $result->getCountry()->getName()); $this->assertEquals('DE', $result->getCountry()->getCode()); - /** @var Position $result */ + /** @var Location $result */ $result = $results->get(3); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(50.1861344, $result->getLatitude(), '', 0.01); @@ -317,7 +318,7 @@ public function testGeocodeWithLocalhostIPv4() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var Position $result */ + /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals('localhost', $result->getLocality()); @@ -343,7 +344,7 @@ public function testGeocodeWithRealIPv4() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(5, $results); - /** @var Position $result */ + /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(43.6189768, $result->getLatitude(), '', 0.01); @@ -374,7 +375,7 @@ public function testGeocodeWithRealIPv4WithLocale() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(5, $results); - /** @var Position $result */ + /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(43.6155351, $result->getLatitude(), '', 0.01); @@ -484,7 +485,7 @@ public function testGetNodeStreetName() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var Position $result */ + /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals('Rue Quincampoix', $result->getStreetName()); diff --git a/tests/Geocoder/Tests/Provider/OpenCageTest.php b/tests/Geocoder/Tests/Provider/OpenCageTest.php index 2d72a03cd..335cbdd29 100644 --- a/tests/Geocoder/Tests/Provider/OpenCageTest.php +++ b/tests/Geocoder/Tests/Provider/OpenCageTest.php @@ -2,7 +2,7 @@ namespace Geocoder\Tests\Provider; -use Geocoder\Model\Position; +use Geocoder\Location; use Geocoder\Tests\TestCase; use Geocoder\Provider\OpenCage; @@ -59,7 +59,7 @@ public function testGeocodeWithRealAddress() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(3, $results); - /** @var Position $result */ + /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(48.866205, $result->getLatitude(), '', 0.01); @@ -106,7 +106,7 @@ public function testReverseWithRealCoordinates() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var Position $result */ + /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(54.0484068, $result->getLatitude(), '', 0.001); @@ -140,7 +140,7 @@ public function testReverseWithVillage() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var Position $result */ + /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals('Bray-et-Lû', $result->getLocality()); @@ -158,7 +158,7 @@ public function testGeocodeWithCity() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(5, $results); - /** @var Position $result */ + /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(52.374478, $result->getLatitude(), '', 0.01); @@ -169,7 +169,7 @@ public function testGeocodeWithCity() $this->assertEquals('Lower Saxony', $result->getAdminLevels()->get(1)->getName()); $this->assertEquals('Germany', $result->getCountry()->getName()); - /** @var Position $result */ + /** @var Location $result */ $result = $results->get(1); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(37.744783, $result->getLatitude(), '', 0.01); @@ -179,7 +179,7 @@ public function testGeocodeWithCity() $this->assertEquals('Hanover', $result->getAdminLevels()->get(2)->getName()); $this->assertEquals('United States of America', $result->getCountry()->getName()); - /** @var Position $result */ + /** @var Location $result */ $result = $results->get(2); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(18.3840489, $result->getLatitude(), '', 0.01); @@ -189,7 +189,7 @@ public function testGeocodeWithCity() $this->assertEquals('Hanover', $result->getAdminLevels()->get(2)->getName()); $this->assertEquals('Jamaica', $result->getCountry()->getName()); - /** @var Position $result */ + /** @var Location $result */ $result = $results->get(3); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(43.7033073, $result->getLatitude(), '', 0.01); @@ -213,7 +213,7 @@ public function testGeocodeWithCityDistrict() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(2, $results); - /** @var Position $result */ + /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(50.189062, $result->getLatitude(), '', 0.01); @@ -243,7 +243,7 @@ public function testGeocodeWithLocale() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(5, $results); - /** @var Position $result */ + /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals('Londres', $result->getLocality()); diff --git a/tests/Geocoder/Tests/Provider/TomTomTest.php b/tests/Geocoder/Tests/Provider/TomTomTest.php index 931ef6243..748c2b012 100644 --- a/tests/Geocoder/Tests/Provider/TomTomTest.php +++ b/tests/Geocoder/Tests/Provider/TomTomTest.php @@ -2,7 +2,7 @@ namespace Geocoder\Tests\Provider; -use Geocoder\Model\Position; +use Geocoder\Location; use Geocoder\Tests\TestCase; use Geocoder\Provider\TomTom; @@ -91,7 +91,7 @@ public function testGeocodeWithRealAddress() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var Position $result */ + /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(55.704389, $result->getLatitude(), '', 0.0001); @@ -120,7 +120,7 @@ public function testGeocodeWithRealAddressWithFrenchLocale() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var Position $result */ + /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(55.704389, $result->getLatitude(), '', 0.0001); @@ -149,7 +149,7 @@ public function testGeocodeWithRealAddressWithSwedishLocale() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var Position $result */ + /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(55.704389, $result->getLatitude(), '', 0.0001); @@ -178,7 +178,7 @@ public function testGeocodeWithRealAddressReturnsMultipleResults() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(5, $results); - /** @var Position $result */ + /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(48.856898, $result->getLatitude(), '', 0.0001); @@ -196,7 +196,7 @@ public function testGeocodeWithRealAddressReturnsMultipleResults() $this->assertEquals('FRA', $result->getCountry()->getCode()); $this->assertNull($result->getTimezone()); - /** @var Position $result */ + /** @var Location $result */ $result = $results->get(1); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(33.661426, $result->getLatitude(), '', 0.0001); @@ -207,7 +207,7 @@ public function testGeocodeWithRealAddressReturnsMultipleResults() $this->assertEquals('United States',$result->getCountry()->getName()); $this->assertEquals('USA', $result->getCountry()->getCode()); - /** @var Position $result */ + /** @var Location $result */ $result = $results->get(2); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(36.302754, $result->getLatitude(), '', 0.0001); @@ -218,7 +218,7 @@ public function testGeocodeWithRealAddressReturnsMultipleResults() $this->assertEquals('United States', $result->getCountry()->getName()); $this->assertEquals('USA', $result->getCountry()->getCode()); - /** @var Position $result */ + /** @var Location $result */ $result = $results->get(3); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(-19.039448, $result->getLatitude(), '', 0.0001); @@ -229,7 +229,7 @@ public function testGeocodeWithRealAddressReturnsMultipleResults() $this->assertEquals('Zimbabwe', $result->getCountry()->getName()); $this->assertEquals('ZWE', $result->getCountry()->getCode()); - /** @var Position $result */ + /** @var Location $result */ $result = $results->get(4); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(35.292105, $result->getLatitude(), '', 0.0001); @@ -361,7 +361,7 @@ public function testReverseWithRealCoordinates() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var Position $result */ + /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(48.86323, $result->getLatitude(), '', 0.001); @@ -390,7 +390,7 @@ public function testGeocodeWithRealCoordinates() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var Position $result */ + /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(56.52435, $result->getLatitude(), '', 0.001); diff --git a/tests/Geocoder/Tests/Provider/YandexTest.php b/tests/Geocoder/Tests/Provider/YandexTest.php index 727d3f9e4..77ea0170a 100644 --- a/tests/Geocoder/Tests/Provider/YandexTest.php +++ b/tests/Geocoder/Tests/Provider/YandexTest.php @@ -2,7 +2,7 @@ namespace Geocoder\Tests\Provider; -use Geocoder\Model\Position; +use Geocoder\Location; use Geocoder\Tests\TestCase; use Geocoder\Provider\Yandex; @@ -95,7 +95,7 @@ public function testGeocodeWithRealAddress() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var Position $result */ + /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('Geocoder\Model\Address', $result); $this->assertEquals(48.863277, $result->getLatitude(), '', 0.01); @@ -130,7 +130,7 @@ public function testGeocodeWithRealAddressWithUALocale() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(5, $results);; - /** @var Position $result */ + /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('Geocoder\Model\Address', $result); $this->assertEquals(55.675676, $result->getLatitude(), '', 0.01); @@ -154,25 +154,25 @@ public function testGeocodeWithRealAddressWithUALocale() $this->assertNull($result->getAdminLevels()->get(1)->getCode()); $this->assertNull($result->getTimezone()); - /** @var Position $result */ + /** @var Location $result */ $result = $results->get(1); $this->assertInstanceOf('Geocoder\Model\Address', $result); $this->assertEquals(55.455739, $result->getLatitude(), '', 0.01); $this->assertEquals(9.972854, $result->getLongitude(), '', 0.01); - /** @var Position $result */ + /** @var Location $result */ $result = $results->get(2); $this->assertInstanceOf('Geocoder\Model\Address', $result); $this->assertEquals(55.713258, $result->getLatitude(), '', 0.01); $this->assertEquals(12.534930, $result->getLongitude(), '', 0.01); - /** @var Position $result */ + /** @var Location $result */ $result = $results->get(3); $this->assertInstanceOf('Geocoder\Model\Address', $result); $this->assertEquals(55.698878, $result->getLatitude(), '', 0.01); $this->assertEquals(12.578211, $result->getLongitude(), '', 0.01); - /** @var Position $result */ + /** @var Location $result */ $result = $results->get(4); $this->assertInstanceOf('Geocoder\Model\Address', $result); $this->assertEquals(55.690380, $result->getLatitude(), '', 0.01); @@ -187,7 +187,7 @@ public function testGeocodeWithRealAddressWithUSLocale() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(5, $results); - /** @var Position $result */ + /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('Geocoder\Model\Address', $result); $this->assertEquals(38.897695, $result->getLatitude(), '', 0.01); @@ -221,7 +221,7 @@ public function testGeocodeWithRealAddressWithBYLocale() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); - /** @var Position $result */ + /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('Geocoder\Model\Address', $result); $this->assertEquals(53.898077, $result->getLatitude(), '', 0.01); @@ -283,7 +283,7 @@ public function testReverseWithRealCoordinates() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(5, $results); - /** @var Position $result */ + /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('Geocoder\Model\Address', $result); $this->assertEquals(48.863212, $result->getLatitude(), '', 0.01); @@ -309,13 +309,13 @@ public function testReverseWithRealCoordinates() $this->assertNull($result->getAdminLevels()->get(1)->getCode()); $this->assertNull($result->getTimezone()); - /** @var Position $result */ + /** @var Location $result */ $result = $results->get(1); $this->assertInstanceOf('Geocoder\Model\Address', $result); $this->assertEquals(48.864848, $result->getLatitude(), '', 0.01); $this->assertEquals(2.3993549, $result->getLongitude(), '', 0.01); - /** @var Position $result */ + /** @var Location $result */ $result = $results->get(2); $this->assertInstanceOf('Geocoder\Model\Address', $result); $this->assertEquals(48.856929, $result->getLatitude(), '', 0.01); @@ -330,7 +330,7 @@ public function testReverseWithRealCoordinatesWithUSLocaleAndStreeToponym() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(5, $results); - /** @var Position $result */ + /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('Geocoder\Model\Address', $result); $this->assertEquals(48.87132, $result->getLatitude(), '', 0.01); @@ -356,25 +356,25 @@ public function testReverseWithRealCoordinatesWithUSLocaleAndStreeToponym() $this->assertNull($result->getAdminLevels()->get(1)->getCode()); $this->assertNull($result->getTimezone()); - /** @var Position $result */ + /** @var Location $result */ $result = $results->get(1); $this->assertInstanceOf('Geocoder\Model\Address', $result); $this->assertEquals(48.863230, $result->getLatitude(), '', 0.01); $this->assertEquals(2.388261, $result->getLongitude(), '', 0.01); - /** @var Position $result */ + /** @var Location $result */ $result = $results->get(2); $this->assertInstanceOf('Geocoder\Model\Address', $result); $this->assertEquals(48.866022, $result->getLatitude(), '', 0.01); $this->assertEquals(2.389662, $result->getLongitude(), '', 0.01); - /** @var Position $result */ + /** @var Location $result */ $result = $results->get(3); $this->assertInstanceOf('Geocoder\Model\Address', $result); $this->assertEquals(48.863918, $result->getLatitude(), '', 0.01); $this->assertEquals(2.387767, $result->getLongitude(), '', 0.01); - /** @var Position $result */ + /** @var Location $result */ $result = $results->get(4); $this->assertInstanceOf('Geocoder\Model\Address', $result); $this->assertEquals(48.863787, $result->getLatitude(), '', 0.01); @@ -389,7 +389,7 @@ public function testReverseWithRealCoordinatesWithUALocaleAndHouseToponym() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(5, $results); - /** @var Position $result */ + /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('Geocoder\Model\Address', $result); $this->assertEquals(60.454462, $result->getLatitude(), '', 0.01); @@ -424,7 +424,7 @@ public function testReverseWithRealCoordinatesWithTRLocaleAndLocalityToponym() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(5, $results); - /** @var Position $result */ + /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('Geocoder\Model\Address', $result); $this->assertEquals(40.874651, $result->getLatitude(), '', 0.01); From d642d81a88cdbb3b1600da99c9be51c2c737cef2 Mon Sep 17 00:00:00 2001 From: Tobias Nyholm Date: Mon, 24 Oct 2016 13:43:56 +0200 Subject: [PATCH 14/21] minor --- src/Geocoder/Dumper/Gpx.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Geocoder/Dumper/Gpx.php b/src/Geocoder/Dumper/Gpx.php index 823660171..d7f1e61e4 100644 --- a/src/Geocoder/Dumper/Gpx.php +++ b/src/Geocoder/Dumper/Gpx.php @@ -53,7 +53,7 @@ public function dump(Location $location) GPX - , $location->getLatitude(), $location->getLongitude(), $this->formatName($location)); + , $location->getCoordinates()->getLatitude(), $location->getCoordinates()->getLongitude(), $this->formatName($location)); $gpx .= << From be8709aff74dd3dc303f998a1ca02477df3b4b60 Mon Sep 17 00:00:00 2001 From: Tobias Nyholm Date: Mon, 24 Oct 2016 13:48:45 +0200 Subject: [PATCH 15/21] Removed some deprecated functions --- src/Geocoder/Location.php | 24 --------------------- src/Geocoder/Model/Address.php | 38 ---------------------------------- 2 files changed, 62 deletions(-) diff --git a/src/Geocoder/Location.php b/src/Geocoder/Location.php index 29334e262..0c89cc61f 100644 --- a/src/Geocoder/Location.php +++ b/src/Geocoder/Location.php @@ -23,22 +23,6 @@ interface Location */ public function getCoordinates(); - /** - * Returns the latitude value. - * - * @return double - * @deprecated - */ - public function getLatitude(); - - /** - * Returns the longitude value. - * - * @return double - * @deprecated - */ - public function getLongitude(); - /** * Returns the bounds value object. * @@ -102,14 +86,6 @@ public function getAdminLevels(); */ public function getCountry(); - /** - * Returns the country ISO code. - * - * @return string - * @deprecated - */ - public function getCountryCode(); - /** * Returns the timezone for the Position. The timezone MUST be in the list of supported timezones. * diff --git a/src/Geocoder/Model/Address.php b/src/Geocoder/Model/Address.php index 2b554bbd2..26a4b226d 100644 --- a/src/Geocoder/Model/Address.php +++ b/src/Geocoder/Model/Address.php @@ -114,34 +114,6 @@ public function getCoordinates() return $this->coordinates; } - /** - * Returns the latitude value. - * - * @return double - */ - public function getLatitude() - { - if (null === $this->coordinates) { - return null; - } - - return $this->coordinates->getLatitude(); - } - - /** - * Returns the longitude value. - * - * @return double - */ - public function getLongitude() - { - if (null === $this->coordinates) { - return null; - } - - return $this->coordinates->getLongitude(); - } - /** * Returns the bounds value. * @@ -223,16 +195,6 @@ public function getCountry() return $this->country; } - /** - * Returns the country ISO code. - * - * @return string - */ - public function getCountryCode() - { - return $this->country->getCode(); - } - /** * Returns the timezone. * From d24dde24164e0d4741bb967a89ba61221425fed9 Mon Sep 17 00:00:00 2001 From: Tobias Nyholm Date: Mon, 24 Oct 2016 13:48:53 +0200 Subject: [PATCH 16/21] Updated changelon --- CHANGELOG.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bff35d493..940279cf5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,13 +3,16 @@ CHANGELOG ### 4.0.0 (2016-xx-xx) -* Added: Interface for `Geocoder\Model\AddressCollection` called `Geocoder\GeocoderResult`. -* Added: Interface for `Geocoder\Model\Address` called `Geocoder\Location`. +* Added: Interface for `Geocoder\Model\AddressCollection` called `Geocoder\GeocoderResult`. Public APIs are updated to type hint for `Geocoder\GeocoderResult`. +* Added: Interface for `Geocoder\Model\Address` called `Geocoder\Location`. Public APIs are updated to type hint for `Geocoder\Location`. * Added: `Country::isDefined` * Added: `Cordinates::isDefined` -* Changed: `Location::getCorrdinates`, `Location::getBounds` and `Location::getCountry` will never return null. +* Changed: `Location::getCoordinates`, `Location::getBounds` and `Location::getCountry` will never return null. * Removed: `AdminLevel::toString` in favor for `AdminLevel::__toString`. * Removed: `Country::toString` in favor for `Country::__toString`. +* Removed: `Address::getCountryCode` in favor for `Address::getCountry()->getCode()`. +* Removed: `Address::getLongitude` in favor for `Address::getCoordinates()->getLongitude()`. +* Removed: `Address::getLatitude` in favor for `Address::getCoordinates()->getLatitude()`. ### 3.3.0 (2015-12-06) From f2095a3dfe9fdb29c5e1e767b936938559003729 Mon Sep 17 00:00:00 2001 From: Tobias Nyholm Date: Mon, 24 Oct 2016 13:52:52 +0200 Subject: [PATCH 17/21] Updated tests --- src/Geocoder/Model/Address.php | 4 +- tests/Geocoder/Tests/Dumper/GpxTest.php | 2 +- .../Tests/Provider/ArcGISOnlineTest.php | 36 +++++----- .../Geocoder/Tests/Provider/BingMapsTest.php | 44 ++++++------ .../Geocoder/Tests/Provider/FreeGeoIpTest.php | 8 +-- tests/Geocoder/Tests/Provider/GeoIP2Test.php | 4 +- tests/Geocoder/Tests/Provider/GeoIPsTest.php | 12 ++-- .../Geocoder/Tests/Provider/GeoPluginTest.php | 4 +- tests/Geocoder/Tests/Provider/GeoipTest.php | 4 +- .../Geocoder/Tests/Provider/GeonamesTest.php | 48 ++++++------- .../Tests/Provider/GoogleMapsTest.php | 32 ++++----- tests/Geocoder/Tests/Provider/HostIpTest.php | 12 ++-- .../Geocoder/Tests/Provider/IpInfoDbTest.php | 12 ++-- .../Geocoder/Tests/Provider/MapQuestTest.php | 28 ++++---- tests/Geocoder/Tests/Provider/MapzenTest.php | 24 +++---- .../Tests/Provider/MaxMindBinaryTest.php | 8 +-- tests/Geocoder/Tests/Provider/MaxMindTest.php | 32 ++++----- .../Geocoder/Tests/Provider/NominatimTest.php | 56 +++++++-------- .../Geocoder/Tests/Provider/OpenCageTest.php | 28 ++++---- tests/Geocoder/Tests/Provider/TomTomTest.php | 40 +++++------ tests/Geocoder/Tests/Provider/YandexTest.php | 72 +++++++++---------- 21 files changed, 255 insertions(+), 255 deletions(-) diff --git a/src/Geocoder/Model/Address.php b/src/Geocoder/Model/Address.php index 26a4b226d..94579bb64 100644 --- a/src/Geocoder/Model/Address.php +++ b/src/Geocoder/Model/Address.php @@ -221,8 +221,8 @@ public function toArray() } return array( - 'latitude' => $this->getLatitude(), - 'longitude' => $this->getLongitude(), + 'latitude' => $this->getCoordinates()->getLatitude(), + 'longitude' => $this->getCoordinates()->getLongitude(), 'bounds' => $this->bounds->toArray(), 'streetNumber' => $this->streetNumber, 'streetName' => $this->streetName, diff --git a/tests/Geocoder/Tests/Dumper/GpxTest.php b/tests/Geocoder/Tests/Dumper/GpxTest.php index f8514753a..beefb57da 100644 --- a/tests/Geocoder/Tests/Dumper/GpxTest.php +++ b/tests/Geocoder/Tests/Dumper/GpxTest.php @@ -64,7 +64,7 @@ public function testDumpWithData() GPX - , Geocoder::VERSION, $address->getLatitude(), $address->getLongitude()); + , Geocoder::VERSION, $address->getCoordinates()->getLatitude(), $address->getCoordinates()->getLongitude()); $result = $this->dumper->dump($address); diff --git a/tests/Geocoder/Tests/Provider/ArcGISOnlineTest.php b/tests/Geocoder/Tests/Provider/ArcGISOnlineTest.php index f03726179..919bd62d4 100644 --- a/tests/Geocoder/Tests/Provider/ArcGISOnlineTest.php +++ b/tests/Geocoder/Tests/Provider/ArcGISOnlineTest.php @@ -84,8 +84,8 @@ public function testGeocodeWithRealAddress() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(48.863279997000461, $result->getLatitude(), '', 0.0001); - $this->assertEquals(2.3890199980004354, $result->getLongitude(), '', 0.0001); + $this->assertEquals(48.863279997000461, $result->getCoordinates()->getLatitude(), '', 0.0001); + $this->assertEquals(2.3890199980004354, $result->getCoordinates()->getLongitude(), '', 0.0001); $this->assertEquals(10, $result->getStreetNumber()); $this->assertEquals('10 Avenue Gambetta, 75020, 20e Arrondissement, Paris, Île-de-France', $result->getStreetName()); $this->assertEquals(75020, $result->getPostalCode()); @@ -114,8 +114,8 @@ public function testGeocodeWithRealAddressAndHttps() /** @var \Geocoder\Model\Address $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(48.863279997000461, $result->getLatitude(), '', 0.0001); - $this->assertEquals(2.3890199980004354, $result->getLongitude(), '', 0.0001); + $this->assertEquals(48.863279997000461, $result->getCoordinates()->getLatitude(), '', 0.0001); + $this->assertEquals(2.3890199980004354, $result->getCoordinates()->getLongitude(), '', 0.0001); $this->assertEquals(10, $result->getStreetNumber()); $this->assertEquals('10 Avenue Gambetta, 75020, 20e Arrondissement, Paris, Île-de-France', $result->getStreetName()); $this->assertEquals(75020, $result->getPostalCode()); @@ -185,8 +185,8 @@ public function testReverseWithRealCoordinates() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(48.863279997000461, $result->getLatitude(), '', 0.0001); - $this->assertEquals(2.3890199980004354, $result->getLongitude(), '', 0.0001); + $this->assertEquals(48.863279997000461, $result->getCoordinates()->getLatitude(), '', 0.0001); + $this->assertEquals(2.3890199980004354, $result->getCoordinates()->getLongitude(), '', 0.0001); $this->assertNull($result->getStreetNumber()); $this->assertEquals('3 Avenue Gambetta', $result->getStreetName()); $this->assertEquals(75020, $result->getPostalCode()); @@ -211,8 +211,8 @@ public function testReverseWithRealCoordinatesWithHttps() /** @var \Geocoder\Model\Address $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(48.863279997000461, $result->getLatitude(), '', 0.0001); - $this->assertEquals(2.3890199980004354, $result->getLongitude(), '', 0.0001); + $this->assertEquals(48.863279997000461, $result->getCoordinates()->getLatitude(), '', 0.0001); + $this->assertEquals(2.3890199980004354, $result->getCoordinates()->getLongitude(), '', 0.0001); $this->assertNull($result->getStreetNumber()); $this->assertEquals('3 Avenue Gambetta', $result->getStreetName()); $this->assertEquals(75020, $result->getPostalCode()); @@ -237,8 +237,8 @@ public function testGeocodeWithCity() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(52.370518568000477, $result->getLatitude(), '', 0.0001); - $this->assertEquals(9.7332166860004463, $result->getLongitude(), '', 0.0001); + $this->assertEquals(52.370518568000477, $result->getCoordinates()->getLatitude(), '', 0.0001); + $this->assertEquals(9.7332166860004463, $result->getCoordinates()->getLongitude(), '', 0.0001); $this->assertNull($result->getStreetNumber()); $this->assertEquals('Hannover, Niedersachsen, Deutschland', $result->getStreetName()); $this->assertNull($result->getPostalCode()); @@ -255,8 +255,8 @@ public function testGeocodeWithCity() /** @var Location $result */ $result = $results->get(1); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(47.111386795000499, $result->getLatitude(), '', 0.0001); - $this->assertEquals(-101.4265391569997, $result->getLongitude(), '', 0.0001); + $this->assertEquals(47.111386795000499, $result->getCoordinates()->getLatitude(), '', 0.0001); + $this->assertEquals(-101.4265391569997, $result->getCoordinates()->getLongitude(), '', 0.0001); $this->assertEquals('Hannover, North Dakota, United States', $result->getStreetName()); $this->assertNull($result->getLocality()); $this->assertCount(2, $result->getAdminLevels()); @@ -266,8 +266,8 @@ public function testGeocodeWithCity() /** @var Location $result */ $result = $results->get(2); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(39.391768472000479, $result->getLatitude(), '', 0.0001); - $this->assertEquals(-77.440257128999633, $result->getLongitude(), '', 0.0001); + $this->assertEquals(39.391768472000479, $result->getCoordinates()->getLatitude(), '', 0.0001); + $this->assertEquals(-77.440257128999633, $result->getCoordinates()->getLongitude(), '', 0.0001); $this->assertEquals('Hannover, Maryland, United States', $result->getStreetName()); $this->assertNull($result->getLocality()); $this->assertCount(2, $result->getAdminLevels()); @@ -277,8 +277,8 @@ public function testGeocodeWithCity() /** @var Location $result */ $result = $results->get(3); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(53.174198173, $result->getLatitude(), '', 0.0001); - $this->assertEquals(8.5069383810005, $result->getLongitude(), '', 0.0001); + $this->assertEquals(53.174198173, $result->getCoordinates()->getLatitude(), '', 0.0001); + $this->assertEquals(8.5069383810005, $result->getCoordinates()->getLongitude(), '', 0.0001); $this->assertEquals('Hannöver, Niedersachsen, Deutschland', $result->getStreetName()); $this->assertNull($result->getLocality()); $this->assertCount(1, $result->getAdminLevels()); @@ -288,8 +288,8 @@ public function testGeocodeWithCity() /** @var Location $result */ $result = $results->get(4); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(-26.281805980999593, $result->getLatitude(), '', 0.0001); - $this->assertEquals(-48.849389793999649, $result->getLongitude(), '', 0.0001); + $this->assertEquals(-26.281805980999593, $result->getCoordinates()->getLatitude(), '', 0.0001); + $this->assertEquals(-48.849389793999649, $result->getCoordinates()->getLongitude(), '', 0.0001); $this->assertEquals('Hannover', $result->getStreetName()); $this->assertCount(2, $result->getAdminLevels()); $this->assertEquals('Sul', $result->getAdminLevels()->get(1)->getName()); diff --git a/tests/Geocoder/Tests/Provider/BingMapsTest.php b/tests/Geocoder/Tests/Provider/BingMapsTest.php index db8873efe..d7c5f7971 100644 --- a/tests/Geocoder/Tests/Provider/BingMapsTest.php +++ b/tests/Geocoder/Tests/Provider/BingMapsTest.php @@ -98,8 +98,8 @@ public function testGeocodeReturnsMultipleResults() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(48.86321675999999, $result->getLatitude(), '', 0.01); - $this->assertEquals(2.3887721299999995, $result->getLongitude(), '', 0.01); + $this->assertEquals(48.86321675999999, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(2.3887721299999995, $result->getCoordinates()->getLongitude(), '', 0.01); $this->assertTrue($result->getBounds()->isDefined()); $this->assertEquals(48.859354042429, $result->getBounds()->getSouth(), '', 0.01); $this->assertEquals(2.3809438666389, $result->getBounds()->getWest(), '', 0.01); @@ -120,8 +120,8 @@ public function testGeocodeReturnsMultipleResults() /** @var Location $result */ $result = $results->get(1); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(48.81342781, $result->getLatitude(), '', 0.01); - $this->assertEquals(2.32503767, $result->getLongitude(), '', 0.01); + $this->assertEquals(48.81342781, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(2.32503767, $result->getCoordinates()->getLongitude(), '', 0.01); $this->assertTrue($result->getBounds()->isDefined()); $this->assertEquals(48.809565092429, $result->getBounds()->getSouth(), '', 0.01); $this->assertEquals(2.3172171827738, $result->getBounds()->getWest(), '', 0.01); @@ -140,8 +140,8 @@ public function testGeocodeReturnsMultipleResults() /** @var Location $result */ $result = $results->get(2); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(48.81014147, $result->getLatitude(), '', 0.01); - $this->assertEquals(2.43568048, $result->getLongitude(), '', 0.01); + $this->assertEquals(48.81014147, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(2.43568048, $result->getCoordinates()->getLongitude(), '', 0.01); $this->assertTrue($result->getBounds()->isDefined()); $this->assertEquals(48.806278752429, $result->getBounds()->getSouth(), '', 0.01); $this->assertEquals(2.4278605052897, $result->getBounds()->getWest(), '', 0.01); @@ -173,8 +173,8 @@ public function testReverseReturnsSingleResult() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(48.86321648955345, $result->getLatitude(), '', 0.0001); - $this->assertEquals(2.3887719959020615, $result->getLongitude(), '', 0.0001); + $this->assertEquals(48.86321648955345, $result->getCoordinates()->getLatitude(), '', 0.0001); + $this->assertEquals(2.3887719959020615, $result->getCoordinates()->getLongitude(), '', 0.0001); $this->assertTrue($result->getBounds()->isDefined()); $this->assertEquals(48.859353771983, $result->getBounds()->getSouth(), '', 0.0001); $this->assertEquals(2.3809437325833, $result->getBounds()->getWest(), '', 0.0001); @@ -208,8 +208,8 @@ public function testGeocodeWithRealAddressReturnsSingleResults() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(48.86321675999999, $result->getLatitude(), '', 0.01); - $this->assertEquals(2.3887721299999995, $result->getLongitude(), '', 0.01); + $this->assertEquals(48.86321675999999, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(2.3887721299999995, $result->getCoordinates()->getLongitude(), '', 0.01); $this->assertTrue($result->getBounds()->isDefined()); $this->assertEquals(48.859354042429, $result->getBounds()->getSouth(), '', 0.01); $this->assertEquals(2.3809438666389, $result->getBounds()->getWest(), '', 0.01); @@ -246,8 +246,8 @@ public function testGeocodeWithRealAddressReturnsMultipleResults() /** @var Location $result */ $result = $results->get(0); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(44.786701202393, $result->getLatitude(), '', 0.01); - $this->assertEquals(8.2841901779175, $result->getLongitude(), '', 0.01); + $this->assertEquals(44.786701202393, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(8.2841901779175, $result->getCoordinates()->getLongitude(), '', 0.01); $this->assertTrue($result->getBounds()->isDefined()); $this->assertEquals(44.775325775146, $result->getBounds()->getSouth(), '', 0.01); $this->assertEquals(8.2711343765259, $result->getBounds()->getWest(), '', 0.01); @@ -266,8 +266,8 @@ public function testGeocodeWithRealAddressReturnsMultipleResults() /** @var Location $result */ $result = $results->get(1); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(46.05179977417, $result->getLatitude(), '', 0.01); - $this->assertEquals(11.497699737549, $result->getLongitude(), '', 0.01); + $this->assertEquals(46.05179977417, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(11.497699737549, $result->getCoordinates()->getLongitude(), '', 0.01); $this->assertTrue($result->getBounds()->isDefined()); $this->assertEquals(46.029235839844, $result->getBounds()->getSouth(), '', 0.01); $this->assertEquals(11.473880767822, $result->getBounds()->getWest(), '', 0.01); @@ -286,8 +286,8 @@ public function testGeocodeWithRealAddressReturnsMultipleResults() /** @var Location $result */ $result = $results->get(2); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(44.987880706787, $result->getLatitude(), '', 0.01); - $this->assertEquals(9.442440032959, $result->getLongitude(), '', 0.01); + $this->assertEquals(44.987880706787, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(9.442440032959, $result->getCoordinates()->getLongitude(), '', 0.01); $this->assertTrue($result->getBounds()->isDefined()); $this->assertEquals(44.958910323795, $result->getBounds()->getSouth(), '', 0.01); $this->assertEquals(9.3878520826907, $result->getBounds()->getWest(), '', 0.01); @@ -306,8 +306,8 @@ public function testGeocodeWithRealAddressReturnsMultipleResults() /** @var Location $result */ $result = $results->get(3); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(43.82638168335, $result->getLatitude(), '', 0.01); - $this->assertEquals(11.068260192871, $result->getLongitude(), '', 0.01); + $this->assertEquals(43.82638168335, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(11.068260192871, $result->getCoordinates()->getLongitude(), '', 0.01); $this->assertTrue($result->getBounds()->isDefined()); $this->assertEquals(43.797411300357, $result->getBounds()->getSouth(), '', 0.01); $this->assertEquals(11.014744487393, $result->getBounds()->getWest(), '', 0.01); @@ -326,8 +326,8 @@ public function testGeocodeWithRealAddressReturnsMultipleResults() /** @var Location $result */ $result = $results->get(4); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(42.295810699463, $result->getLatitude(), '', 0.01); - $this->assertEquals(13.626440048218, $result->getLongitude(), '', 0.01); + $this->assertEquals(42.295810699463, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(13.626440048218, $result->getCoordinates()->getLongitude(), '', 0.01); $this->assertTrue($result->getBounds()->isDefined()); $this->assertEquals(42.26684031647, $result->getBounds()->getSouth(), '', 0.01); $this->assertEquals(13.574242599134, $result->getBounds()->getWest(), '', 0.01); @@ -379,8 +379,8 @@ public function testReverseWithRealCoordinatesReturnsSingleResult() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(48.86321648955345, $result->getLatitude(), '', 0.0001); - $this->assertEquals(2.3887719959020615, $result->getLongitude(), '', 0.0001); + $this->assertEquals(48.86321648955345, $result->getCoordinates()->getLatitude(), '', 0.0001); + $this->assertEquals(2.3887719959020615, $result->getCoordinates()->getLongitude(), '', 0.0001); $this->assertTrue($result->getBounds()->isDefined()); $this->assertEquals(48.859353771983, $result->getBounds()->getSouth(), '', 0.0001); $this->assertEquals(2.3809437325833, $result->getBounds()->getWest(), '', 0.0001); diff --git a/tests/Geocoder/Tests/Provider/FreeGeoIpTest.php b/tests/Geocoder/Tests/Provider/FreeGeoIpTest.php index defb3bf1e..a77f9e261 100644 --- a/tests/Geocoder/Tests/Provider/FreeGeoIpTest.php +++ b/tests/Geocoder/Tests/Provider/FreeGeoIpTest.php @@ -105,8 +105,8 @@ public function testGeocodeWithRealIPv4() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(33.0347, $result->getLatitude(), '', 0.01); - $this->assertEquals(-96.8134, $result->getLongitude(), '', 0.01); + $this->assertEquals(33.0347, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(-96.8134, $result->getCoordinates()->getLongitude(), '', 0.01); $this->assertEquals(75093, $result->getPostalCode()); $this->assertEquals('Plano', $result->getLocality()); $this->assertCount(1, $result->getAdminLevels()); @@ -126,8 +126,8 @@ public function testGeocodeWithRealIPv6() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(33.0347, $result->getLatitude(), '', 0.01); - $this->assertEquals(-96.8134, $result->getLongitude(), '', 0.01); + $this->assertEquals(33.0347, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(-96.8134, $result->getCoordinates()->getLongitude(), '', 0.01); $this->assertEquals(75093, $result->getPostalCode()); $this->assertEquals('Plano', $result->getLocality()); $this->assertCount(1, $result->getAdminLevels()); diff --git a/tests/Geocoder/Tests/Provider/GeoIP2Test.php b/tests/Geocoder/Tests/Provider/GeoIP2Test.php index 87ecffd4c..623fe8ba6 100644 --- a/tests/Geocoder/Tests/Provider/GeoIP2Test.php +++ b/tests/Geocoder/Tests/Provider/GeoIP2Test.php @@ -166,8 +166,8 @@ public function testRetrievingGeodata($address, $adapterResponse, $expectedGeoda /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals($expectedGeodata['latitude'], $result->getLatitude()); - $this->assertEquals($expectedGeodata['longitude'], $result->getLongitude()); + $this->assertEquals($expectedGeodata['latitude'], $result->getCoordinates()->getLatitude()); + $this->assertEquals($expectedGeodata['longitude'], $result->getCoordinates()->getLongitude()); $this->assertEquals($expectedGeodata['boundsDefined'], $result->getBounds()->isDefined()); $this->assertEquals($expectedGeodata['streetNumber'], $result->getStreetNumber()); $this->assertEquals($expectedGeodata['streetName'], $result->getStreetName()); diff --git a/tests/Geocoder/Tests/Provider/GeoIPsTest.php b/tests/Geocoder/Tests/Provider/GeoIPsTest.php index d0ae23eef..48f0b9e19 100644 --- a/tests/Geocoder/Tests/Provider/GeoIPsTest.php +++ b/tests/Geocoder/Tests/Provider/GeoIPsTest.php @@ -135,8 +135,8 @@ public function testGeocodeWithRealIPv4GetsFakeContentFormattedEmpty() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertNull($result->getLatitude()); - $this->assertNull($result->getLongitude()); + $this->assertNull($result->getCoordinates()->getLatitude()); + $this->assertNull($result->getCoordinates()->getLongitude()); $this->assertNull($result->getPostalCode()); $this->assertNull($result->getLocality()); $this->assertEmpty($result->getAdminLevels()); @@ -178,8 +178,8 @@ public function testGeocodeWithRealIPv4GetsFakeContent() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(40.3402, $result->getLatitude(), '', 0.0001); - $this->assertEquals(-111.6073, $result->getLongitude(), '', 0.0001); + $this->assertEquals(40.3402, $result->getCoordinates()->getLatitude(), '', 0.0001); + $this->assertEquals(-111.6073, $result->getCoordinates()->getLongitude(), '', 0.0001); $this->assertNull($result->getStreetName()); $this->assertNull($result->getPostalCode()); $this->assertEquals('PROVO', $result->getLocality()); @@ -337,8 +337,8 @@ public function testGeocodeWithRealIPv4() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(40.3402, $result->getLatitude(), '', 0.0001); - $this->assertEquals(-111.6073, $result->getLongitude(), '', 0.0001); + $this->assertEquals(40.3402, $result->getCoordinates()->getLatitude(), '', 0.0001); + $this->assertEquals(-111.6073, $result->getCoordinates()->getLongitude(), '', 0.0001); $this->assertNull($result->getStreetName()); $this->assertNull($result->getPostalCode()); $this->assertEquals('PROVO', $result->getLocality()); diff --git a/tests/Geocoder/Tests/Provider/GeoPluginTest.php b/tests/Geocoder/Tests/Provider/GeoPluginTest.php index 5241ddb4b..fec1ec348 100644 --- a/tests/Geocoder/Tests/Provider/GeoPluginTest.php +++ b/tests/Geocoder/Tests/Provider/GeoPluginTest.php @@ -99,8 +99,8 @@ public function testGeocodeWithRealIPv4() $result = $results->first(); - $this->assertEquals(40.711101999999997, $result->getLatitude(), '', 0.0001); - $this->assertEquals(-73.946899000000002, $result->getLongitude(), '', 0.0001); + $this->assertEquals(40.711101999999997, $result->getCoordinates()->getLatitude(), '', 0.0001); + $this->assertEquals(-73.946899000000002, $result->getCoordinates()->getLongitude(), '', 0.0001); $this->assertNull($result->getLocality()); $this->assertCount(1, $result->getAdminLevels()); $this->assertEquals('New York', $result->getAdminLevels()->get(1)->getName()); diff --git a/tests/Geocoder/Tests/Provider/GeoipTest.php b/tests/Geocoder/Tests/Provider/GeoipTest.php index 708e4290a..3a1c7e6dd 100644 --- a/tests/Geocoder/Tests/Provider/GeoipTest.php +++ b/tests/Geocoder/Tests/Provider/GeoipTest.php @@ -64,8 +64,8 @@ public function testGeocodeWithLocalhostIPv4() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('Geocoder\Model\Address', $result); - $this->assertNull($result->getLatitude()); - $this->assertNull($result->getLongitude()); + $this->assertNull($result->getCoordinates()->getLatitude()); + $this->assertNull($result->getCoordinates()->getLongitude()); $this->assertNull($result->getPostalCode()); $this->assertNull($result->getTimezone()); $this->assertEmpty($result->getAdminLevels()); diff --git a/tests/Geocoder/Tests/Provider/GeonamesTest.php b/tests/Geocoder/Tests/Provider/GeonamesTest.php index d1f54c20b..bbea50056 100644 --- a/tests/Geocoder/Tests/Provider/GeonamesTest.php +++ b/tests/Geocoder/Tests/Provider/GeonamesTest.php @@ -95,8 +95,8 @@ public function testGeocodeWithRealPlace() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(51.508528775863, $result->getLatitude(), '', 0.01); - $this->assertEquals(-0.12574195861816, $result->getLongitude(), '', 0.01); + $this->assertEquals(51.508528775863, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(-0.12574195861816, $result->getCoordinates()->getLongitude(), '', 0.01); $this->assertTrue($result->getBounds()->isDefined()); $this->assertEquals(51.151689398345, $result->getBounds()->getSouth(), '', 0.01); $this->assertEquals(-0.70360885396019, $result->getBounds()->getWest(), '', 0.01); @@ -113,8 +113,8 @@ public function testGeocodeWithRealPlace() /** @var Location $result */ $result = $results->get(1); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(-33.015285093464, $result->getLatitude(), '', 0.01); - $this->assertEquals(27.911624908447, $result->getLongitude(), '', 0.01); + $this->assertEquals(-33.015285093464, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(27.911624908447, $result->getCoordinates()->getLongitude(), '', 0.01); $this->assertTrue($result->getBounds()->isDefined()); $this->assertEquals(-33.104996458003, $result->getBounds()->getSouth(), '', 0.01); $this->assertEquals(27.804746435655, $result->getBounds()->getWest(), '', 0.01); @@ -132,8 +132,8 @@ public function testGeocodeWithRealPlace() /** @var Location $result */ $result = $results->get(2); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(51.512788890295, $result->getLatitude(), '', 0.01); - $this->assertEquals(-0.091838836669922, $result->getLongitude(), '', 0.01); + $this->assertEquals(51.512788890295, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(-0.091838836669922, $result->getCoordinates()->getLongitude(), '', 0.01); $this->assertTrue($result->getBounds()->isDefined()); $this->assertEquals(51.155949512764, $result->getBounds()->getSouth(), '', 0.01); $this->assertEquals(-0.66976046752962, $result->getBounds()->getWest(), '', 0.01); @@ -151,8 +151,8 @@ public function testGeocodeWithRealPlace() /** @var Location $result */ $result = $results->get(3); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(42.983389283, $result->getLatitude(), '', 0.01); - $this->assertEquals(-81.233042387, $result->getLongitude(), '', 0.01); + $this->assertEquals(42.983389283, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(-81.233042387, $result->getCoordinates()->getLongitude(), '', 0.01); $this->assertTrue($result->getBounds()->isDefined()); $this->assertEquals(42.907075642763, $result->getBounds()->getSouth(), '', 0.01); $this->assertEquals(-81.337489676463, $result->getBounds()->getWest(), '', 0.01); @@ -168,8 +168,8 @@ public function testGeocodeWithRealPlace() /** @var Location $result */ $result = $results->get(4); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(41.3556539, $result->getLatitude(), '', 0.01); - $this->assertEquals(-72.0995209, $result->getLongitude(), '', 0.01); + $this->assertEquals(41.3556539, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(-72.0995209, $result->getCoordinates()->getLongitude(), '', 0.01); $this->assertTrue($result->getBounds()->isDefined()); $this->assertEquals(41.334087887904, $result->getBounds()->getSouth(), '', 0.01); $this->assertEquals(-72.128261254846, $result->getBounds()->getWest(), '', 0.01); @@ -199,8 +199,8 @@ public function testGeocodeWithRealPlaceWithLocale() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(51.50853, $result->getLatitude(), '', 0.01); - $this->assertEquals(-0.12574, $result->getLongitude(), '', 0.01); + $this->assertEquals(51.50853, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(-0.12574, $result->getCoordinates()->getLongitude(), '', 0.01); $this->assertTrue($result->getBounds()->isDefined()); $this->assertEquals(51.15169, $result->getBounds()->getSouth(), '', 0.01); $this->assertEquals(-0.70361, $result->getBounds()->getWest(), '', 0.01); @@ -217,8 +217,8 @@ public function testGeocodeWithRealPlaceWithLocale() /** @var Location $result */ $result = $results->get(1); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(-33.015285093464, $result->getLatitude(), '', 0.01); - $this->assertEquals(27.911624908447, $result->getLongitude(), '', 0.01); + $this->assertEquals(-33.015285093464, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(27.911624908447, $result->getCoordinates()->getLongitude(), '', 0.01); $this->assertTrue($result->getBounds()->isDefined()); $this->assertEquals(-33.104996458003, $result->getBounds()->getSouth(), '', 0.01); $this->assertEquals(27.804746435655, $result->getBounds()->getWest(), '', 0.01); @@ -236,8 +236,8 @@ public function testGeocodeWithRealPlaceWithLocale() /** @var Location $result */ $result = $results->get(2); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(51.512788890295, $result->getLatitude(), '', 0.01); - $this->assertEquals(-0.091838836669922, $result->getLongitude(), '', 0.01); + $this->assertEquals(51.512788890295, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(-0.091838836669922, $result->getCoordinates()->getLongitude(), '', 0.01); $this->assertTrue($result->getBounds()->isDefined()); $this->assertEquals(51.155949512764, $result->getBounds()->getSouth(), '', 0.01); $this->assertEquals(-0.66976046752962, $result->getBounds()->getWest(), '', 0.01); @@ -255,8 +255,8 @@ public function testGeocodeWithRealPlaceWithLocale() /** @var Location $result */ $result = $results->get(3); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(42.983389283, $result->getLatitude(), '', 0.01); - $this->assertEquals(-81.233042387, $result->getLongitude(), '', 0.01); + $this->assertEquals(42.983389283, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(-81.233042387, $result->getCoordinates()->getLongitude(), '', 0.01); $this->assertTrue($result->getBounds()->isDefined()); $this->assertEquals(42.907075642763, $result->getBounds()->getSouth(), '', 0.01); $this->assertEquals(-81.337489676463, $result->getBounds()->getWest(), '', 0.01); @@ -272,8 +272,8 @@ public function testGeocodeWithRealPlaceWithLocale() /** @var Location $result */ $result = $results->get(4); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(41.3556539, $result->getLatitude(), '', 0.01); - $this->assertEquals(-72.0995209, $result->getLongitude(), '', 0.01); + $this->assertEquals(41.3556539, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(-72.0995209, $result->getCoordinates()->getLongitude(), '', 0.01); $this->assertTrue($result->getBounds()->isDefined()); $this->assertEquals(41.334087887904, $result->getBounds()->getSouth(), '', 0.01); $this->assertEquals(-72.128261254846, $result->getBounds()->getWest(), '', 0.01); @@ -303,8 +303,8 @@ public function testReverseWithRealCoordinates() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(51.50853, $result->getLatitude(), '', 0.01); - $this->assertEquals(-0.12574, $result->getLongitude(), '', 0.01); + $this->assertEquals(51.50853, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(-0.12574, $result->getCoordinates()->getLongitude(), '', 0.01); $this->assertEquals('London', $result->getLocality()); $this->assertCount(2, $result->getAdminLevels()); $this->assertEquals('Greater London', $result->getAdminLevels()->get(2)->getName()); @@ -329,8 +329,8 @@ public function testReverseWithRealCoordinatesWithLocale() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(51.50853, $result->getLatitude(), '', 0.01); - $this->assertEquals(-0.12574, $result->getLongitude(), '', 0.01); + $this->assertEquals(51.50853, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(-0.12574, $result->getCoordinates()->getLongitude(), '', 0.01); $this->assertEquals('Londra', $result->getLocality()); $this->assertCount(2, $result->getAdminLevels()); $this->assertEquals('Greater London', $result->getAdminLevels()->get(2)->getName()); diff --git a/tests/Geocoder/Tests/Provider/GoogleMapsTest.php b/tests/Geocoder/Tests/Provider/GoogleMapsTest.php index ae01ffceb..21c96ba71 100644 --- a/tests/Geocoder/Tests/Provider/GoogleMapsTest.php +++ b/tests/Geocoder/Tests/Provider/GoogleMapsTest.php @@ -123,8 +123,8 @@ public function testGeocodeWithRealAddress() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(48.8630462, $result->getLatitude(), '', 0.001); - $this->assertEquals(2.3882487, $result->getLongitude(), '', 0.001); + $this->assertEquals(48.8630462, $result->getCoordinates()->getLatitude(), '', 0.001); + $this->assertEquals(2.3882487, $result->getCoordinates()->getLongitude(), '', 0.001); $this->assertTrue($result->getBounds()->isDefined()); $this->assertEquals(48.8630462, $result->getBounds()->getSouth(), '', 0.001); $this->assertEquals(2.3882487, $result->getBounds()->getWest(), '', 0.001); @@ -154,8 +154,8 @@ public function testGeocodeWithRealAddressWithSsl() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(48.8630462, $result->getLatitude(), '', 0.001); - $this->assertEquals(2.3882487, $result->getLongitude(), '', 0.001); + $this->assertEquals(48.8630462, $result->getCoordinates()->getLatitude(), '', 0.001); + $this->assertEquals(2.3882487, $result->getCoordinates()->getLongitude(), '', 0.001); $this->assertTrue($result->getBounds()->isDefined()); $this->assertEquals(48.8630462, $result->getBounds()->getSouth(), '', 0.001); $this->assertEquals(2.3882487, $result->getBounds()->getWest(), '', 0.001); @@ -204,8 +204,8 @@ public function testGeocodeWithRealAddressReturnsMultipleResults() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(48.856614, $result->getLatitude(), '', 0.001); - $this->assertEquals(2.3522219, $result->getLongitude(), '', 0.001); + $this->assertEquals(48.856614, $result->getCoordinates()->getLatitude(), '', 0.001); + $this->assertEquals(2.3522219, $result->getCoordinates()->getLongitude(), '', 0.001); $this->assertEquals('Paris', $result->getLocality()); $this->assertEquals('France', $result->getCountry()->getName()); $this->assertEquals('FR', $result->getCountry()->getCode()); @@ -213,8 +213,8 @@ public function testGeocodeWithRealAddressReturnsMultipleResults() /** @var Location $result */ $result = $results->get(1); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(33.6609389, $result->getLatitude(), '', 0.001); - $this->assertEquals(-95.555513, $result->getLongitude(), '', 0.001); + $this->assertEquals(33.6609389, $result->getCoordinates()->getLatitude(), '', 0.001); + $this->assertEquals(-95.555513, $result->getCoordinates()->getLongitude(), '', 0.001); $this->assertEquals('Paris', $result->getLocality()); $this->assertEquals('United States', $result->getCountry()->getName()); $this->assertEquals('US', $result->getCountry()->getCode()); @@ -222,8 +222,8 @@ public function testGeocodeWithRealAddressReturnsMultipleResults() /** @var Location $result */ $result = $results->get(2); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(36.3020023, $result->getLatitude(), '', 0.001); - $this->assertEquals(-88.3267107, $result->getLongitude(), '', 0.001); + $this->assertEquals(36.3020023, $result->getCoordinates()->getLatitude(), '', 0.001); + $this->assertEquals(-88.3267107, $result->getCoordinates()->getLongitude(), '', 0.001); $this->assertEquals('Paris', $result->getLocality()); $this->assertEquals('United States', $result->getCountry()->getName()); $this->assertEquals('US', $result->getCountry()->getCode()); @@ -231,8 +231,8 @@ public function testGeocodeWithRealAddressReturnsMultipleResults() /** @var Location $result */ $result = $results->get(3); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(39.611146, $result->getLatitude(), '', 0.001); - $this->assertEquals(-87.6961374, $result->getLongitude(), '', 0.001); + $this->assertEquals(39.611146, $result->getCoordinates()->getLatitude(), '', 0.001); + $this->assertEquals(-87.6961374, $result->getCoordinates()->getLongitude(), '', 0.001); $this->assertEquals('Paris', $result->getLocality()); $this->assertEquals('United States', $result->getCountry()->getName()); $this->assertEquals('US', $result->getCountry()->getCode()); @@ -240,8 +240,8 @@ public function testGeocodeWithRealAddressReturnsMultipleResults() /** @var Location $result */ $result = $results->get(4); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(38.2097987, $result->getLatitude(), '', 0.001); - $this->assertEquals(-84.2529869, $result->getLongitude(), '', 0.001); + $this->assertEquals(38.2097987, $result->getCoordinates()->getLatitude(), '', 0.001); + $this->assertEquals(-84.2529869, $result->getCoordinates()->getLongitude(), '', 0.001); $this->assertEquals('Paris', $result->getLocality()); $this->assertEquals('United States',$result->getCountry()->getName()); $this->assertEquals('US', $result->getCountry()->getCode()); @@ -329,8 +329,8 @@ public function testGeocodeWithRealValidApiKey() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertNotNull($result->getLatitude()); - $this->assertNotNull($result->getLongitude()); + $this->assertNotNull($result->getCoordinates()->getLatitude()); + $this->assertNotNull($result->getCoordinates()->getLongitude()); $this->assertTrue($result->getBounds()->isDefined()); $this->assertEquals('New York', $result->getLocality()); $this->assertEquals('Manhattan', $result->getSubLocality()); diff --git a/tests/Geocoder/Tests/Provider/HostIpTest.php b/tests/Geocoder/Tests/Provider/HostIpTest.php index bc456b2d8..8f7c26dab 100644 --- a/tests/Geocoder/Tests/Provider/HostIpTest.php +++ b/tests/Geocoder/Tests/Provider/HostIpTest.php @@ -55,8 +55,8 @@ public function testGeocodeWithLocalhostIPv4() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertNull($result->getLatitude()); - $this->assertNull($result->getLongitude()); + $this->assertNull($result->getCoordinates()->getLatitude()); + $this->assertNull($result->getCoordinates()->getLongitude()); $this->assertNull($result->getPostalCode()); $this->assertNull($result->getTimezone()); $this->assertEmpty($result->getAdminLevels()); @@ -106,8 +106,8 @@ public function testGeocodeWithRealIPv4() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(45.5333, $result->getLatitude(), '', 0.0001); - $this->assertEquals(2.6167, $result->getLongitude(), '', 0.0001); + $this->assertEquals(45.5333, $result->getCoordinates()->getLatitude(), '', 0.0001); + $this->assertEquals(2.6167, $result->getCoordinates()->getLongitude(), '', 0.0001); $this->assertNull($result->getPostalCode()); $this->assertEquals('Aulnat', $result->getLocality()); $this->assertEmpty($result->getAdminLevels()); @@ -146,7 +146,7 @@ public function testGeocodeWithAnotherIp() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertNull($result->getLatitude()); - $this->assertNull($result->getLongitude()); + $this->assertNull($result->getCoordinates()->getLatitude()); + $this->assertNull($result->getCoordinates()->getLongitude()); } } diff --git a/tests/Geocoder/Tests/Provider/IpInfoDbTest.php b/tests/Geocoder/Tests/Provider/IpInfoDbTest.php index 2763829d0..aa2deac26 100644 --- a/tests/Geocoder/Tests/Provider/IpInfoDbTest.php +++ b/tests/Geocoder/Tests/Provider/IpInfoDbTest.php @@ -83,8 +83,8 @@ public function testGeocodeWithLocalhostIPv4() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertNull($result->getLatitude()); - $this->assertNull($result->getLongitude()); + $this->assertNull($result->getCoordinates()->getLatitude()); + $this->assertNull($result->getCoordinates()->getLongitude()); $this->assertNull($result->getPostalCode()); $this->assertNull($result->getTimezone()); $this->assertEmpty($result->getAdminLevels()); @@ -138,8 +138,8 @@ public function testGeocodeWithRealIPv4() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(37.406, $result->getLatitude(), '', 0.001); - $this->assertEquals(-122.079, $result->getLongitude(), '', 0.001); + $this->assertEquals(37.406, $result->getCoordinates()->getLatitude(), '', 0.001); + $this->assertEquals(-122.079, $result->getCoordinates()->getLongitude(), '', 0.001); $this->assertEquals(94043, $result->getPostalCode()); $this->assertEquals('Mountain View', $result->getLocality()); $this->assertCount(1, $result->getAdminLevels()); @@ -181,8 +181,8 @@ public function testGetGeocodedDataWithCountryPrecision() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertNull($result->getLatitude()); - $this->assertNull($result->getLongitude()); + $this->assertNull($result->getCoordinates()->getLatitude()); + $this->assertNull($result->getCoordinates()->getLongitude()); $this->assertNull($result->getPostalCode()); $this->assertNull($result->getLocality()); $this->assertEmpty($result->getAdminLevels()); diff --git a/tests/Geocoder/Tests/Provider/MapQuestTest.php b/tests/Geocoder/Tests/Provider/MapQuestTest.php index f55f6ec4e..6f687f593 100644 --- a/tests/Geocoder/Tests/Provider/MapQuestTest.php +++ b/tests/Geocoder/Tests/Provider/MapQuestTest.php @@ -64,8 +64,8 @@ public function testGeocodeWithRealAddress() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(48.866205, $result->getLatitude(), '', 0.01); - $this->assertEquals(2.389089, $result->getLongitude(), '', 0.01); + $this->assertEquals(48.866205, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(2.389089, $result->getCoordinates()->getLongitude(), '', 0.01); $this->assertEquals('10 Avenue Gambetta', $result->getStreetName()); $this->assertEquals(75020, $result->getPostalCode()); $this->assertEquals('Paris', $result->getLocality()); @@ -109,8 +109,8 @@ public function testReverseWithRealCoordinates() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(54.0484068, $result->getLatitude(), '', 0.001); - $this->assertEquals(-2.7990345, $result->getLongitude(), '', 0.001); + $this->assertEquals(54.0484068, $result->getCoordinates()->getLatitude(), '', 0.001); + $this->assertEquals(-2.7990345, $result->getCoordinates()->getLongitude(), '', 0.001); $this->assertEquals('Lancaster Gate', $result->getStreetName()); $this->assertEquals('LA1 1LZ', $result->getPostalCode()); $this->assertEquals('Lancaster', $result->getLocality()); @@ -141,8 +141,8 @@ public function testGeocodeWithCity() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(52.374478, $result->getLatitude(), '', 0.01); - $this->assertEquals(9.738553, $result->getLongitude(), '', 0.01); + $this->assertEquals(52.374478, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(9.738553, $result->getCoordinates()->getLongitude(), '', 0.01); $this->assertEquals('Hanover', $result->getLocality()); $this->assertCount(2, $result->getAdminLevels()); $this->assertEquals('Region Hannover', $result->getAdminLevels()->get(2)->getName()); @@ -153,8 +153,8 @@ public function testGeocodeWithCity() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(52.374478000000003, $result->getLatitude(), '', 0.01); - $this->assertEquals(9.7385529999999996, $result->getLongitude(), '', 0.01); + $this->assertEquals(52.374478000000003, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(9.7385529999999996, $result->getCoordinates()->getLongitude(), '', 0.01); $this->assertEquals('Hanover', $result->getLocality()); $this->assertCount(2, $result->getAdminLevels()); $this->assertEquals('Region Hannover', $result->getAdminLevels()->get(2)->getName()); @@ -165,8 +165,8 @@ public function testGeocodeWithCity() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(52.374478000000003, $result->getLatitude(), '', 0.01); - $this->assertEquals(9.7385529999999996, $result->getLongitude(), '', 0.01); + $this->assertEquals(52.374478000000003, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(9.7385529999999996, $result->getCoordinates()->getLongitude(), '', 0.01); $this->assertEquals('Hanover', $result->getLocality()); $this->assertCount(2, $result->getAdminLevels()); $this->assertEquals('Region Hannover', $result->getAdminLevels()->get(2)->getName()); @@ -177,8 +177,8 @@ public function testGeocodeWithCity() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(52.374478000000003, $result->getLatitude(), '', 0.01); - $this->assertEquals(9.7385529999999996, $result->getLongitude(), '', 0.01); + $this->assertEquals(52.374478000000003, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(9.7385529999999996, $result->getCoordinates()->getLongitude(), '', 0.01); $this->assertEquals('Hanover', $result->getLocality()); $this->assertCount(2, $result->getAdminLevels()); $this->assertEquals('Region Hannover', $result->getAdminLevels()->get(2)->getName()); @@ -202,8 +202,8 @@ public function testGeocodeWithCityDistrict() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(50.189062, $result->getLatitude(), '', 0.01); - $this->assertEquals(8.636567, $result->getLongitude(), '', 0.01); + $this->assertEquals(50.189062, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(8.636567, $result->getCoordinates()->getLongitude(), '', 0.01); $this->assertEquals('Kalbacher Hauptstraße 10', $result->getStreetName()); $this->assertEquals(60437, $result->getPostalCode()); $this->assertEquals('Frankfurt', $result->getLocality()); diff --git a/tests/Geocoder/Tests/Provider/MapzenTest.php b/tests/Geocoder/Tests/Provider/MapzenTest.php index 6326e95ab..dea610bf5 100644 --- a/tests/Geocoder/Tests/Provider/MapzenTest.php +++ b/tests/Geocoder/Tests/Provider/MapzenTest.php @@ -61,8 +61,8 @@ public function testGeocodeWithRealAddress() /** @var \Geocoder\Model\Address $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(51.521124, $result->getLatitude(), '', 0.01); - $this->assertEquals(-0.20360200000000001, $result->getLongitude(), '', 0.01); + $this->assertEquals(51.521124, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(-0.20360200000000001, $result->getCoordinates()->getLongitude(), '', 0.01); $this->assertEquals(240, $result->getStreetNumber()); $this->assertEquals('Acklam Road', $result->getStreetName()); $this->assertEquals('W10 5QT', $result->getPostalCode()); @@ -102,8 +102,8 @@ public function testReverseWithRealCoordinates() /** @var \Geocoder\Model\Address $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(54.048411999999999, $result->getLatitude(), '', 0.001); - $this->assertEquals(-2.7989549999999999, $result->getLongitude(), '', 0.001); + $this->assertEquals(54.048411999999999, $result->getCoordinates()->getLatitude(), '', 0.001); + $this->assertEquals(-2.7989549999999999, $result->getCoordinates()->getLongitude(), '', 0.001); $this->assertNull($result->getStreetNumber()); $this->assertEquals('Gage Street', $result->getStreetName()); $this->assertNull($result->getPostalCode()); @@ -148,8 +148,8 @@ public function testGeocodeWithCity() /** @var \Geocoder\Model\Address $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(42.027323000000003, $result->getLatitude(), '', 0.01); - $this->assertEquals(-88.204203000000007, $result->getLongitude(), '', 0.01); + $this->assertEquals(42.027323000000003, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(-88.204203000000007, $result->getCoordinates()->getLongitude(), '', 0.01); $this->assertNull($result->getLocality()); $this->assertCount(2, $result->getAdminLevels()); $this->assertEquals('United States', $result->getAdminLevels()->get(4)->getName()); @@ -159,8 +159,8 @@ public function testGeocodeWithCity() /** @var \Geocoder\Model\Address $result */ $result = $results->get(1); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(18.393428, $result->getLatitude(), '', 0.01); - $this->assertEquals(-78.122906, $result->getLongitude(), '', 0.01); + $this->assertEquals(18.393428, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(-78.122906, $result->getCoordinates()->getLongitude(), '', 0.01); $this->assertNull($result->getLocality()); $this->assertCount(2, $result->getAdminLevels()); $this->assertEquals('Hanover', $result->getAdminLevels()->get(1)->getName()); @@ -169,8 +169,8 @@ public function testGeocodeWithCity() /** @var \Geocoder\Model\Address $result */ $result = $results->get(2); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(39.192889999999998, $result->getLatitude(), '', 0.01); - $this->assertEquals(-76.724140000000006, $result->getLongitude(), '', 0.01); + $this->assertEquals(39.192889999999998, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(-76.724140000000006, $result->getCoordinates()->getLongitude(), '', 0.01); $this->assertEquals('Hanover', $result->getLocality()); $this->assertTrue( $result->getAdminLevels()->has(4)); $this->assertEquals('Hanover', $result->getAdminLevels()->get(2)->getName()); @@ -192,8 +192,8 @@ public function testGeocodeWithCityDistrict() /** @var \Geocoder\Model\Address $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(50.189017, $result->getLatitude(), '', 0.01); - $this->assertEquals(8.6367809999999992, $result->getLongitude(), '', 0.01); + $this->assertEquals(50.189017, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(8.6367809999999992, $result->getCoordinates()->getLongitude(), '', 0.01); $this->assertEquals('10a', $result->getStreetNumber()); $this->assertEquals('Kalbacher Hauptstraße', $result->getStreetName()); $this->assertEquals(60437, $result->getPostalCode()); diff --git a/tests/Geocoder/Tests/Provider/MaxMindBinaryTest.php b/tests/Geocoder/Tests/Provider/MaxMindBinaryTest.php index f2551fe51..c73b98fd8 100644 --- a/tests/Geocoder/Tests/Provider/MaxMindBinaryTest.php +++ b/tests/Geocoder/Tests/Provider/MaxMindBinaryTest.php @@ -54,8 +54,8 @@ public function testLocationResultContainsExpectedFieldsForAnAmericanIp() $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals('43.089200000000005', $result->getLatitude(), '', 0.001); - $this->assertEquals('-76.025000000000006', $result->getLongitude(), '', 0.001); + $this->assertEquals('43.089200000000005', $result->getCoordinates()->getLatitude(), '', 0.001); + $this->assertEquals('-76.025000000000006', $result->getCoordinates()->getLongitude(), '', 0.001); $this->assertFalse($result->getBounds()->isDefined()); $this->assertNull($result->getStreetNumber()); $this->assertNull($result->getStreetName()); @@ -82,8 +82,8 @@ public function testLocationResultContainsExpectedFieldsForASpanishIp() $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals('41.543299999999988', $result->getLatitude(), '', 0.001); - $this->assertEquals('2.1093999999999937', $result->getLongitude(), '', 0.001); + $this->assertEquals('41.543299999999988', $result->getCoordinates()->getLatitude(), '', 0.001); + $this->assertEquals('2.1093999999999937', $result->getCoordinates()->getLongitude(), '', 0.001); $this->assertFalse($result->getBounds()->isDefined()); $this->assertNull($result->getStreetNumber()); $this->assertNull($result->getStreetName()); diff --git a/tests/Geocoder/Tests/Provider/MaxMindTest.php b/tests/Geocoder/Tests/Provider/MaxMindTest.php index 86894ccd4..5590e1af7 100644 --- a/tests/Geocoder/Tests/Provider/MaxMindTest.php +++ b/tests/Geocoder/Tests/Provider/MaxMindTest.php @@ -134,8 +134,8 @@ public function testGeocodeWithRealIPv4GetsFakeContentFormattedEmpty() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertNull($result->getLatitude()); - $this->assertNull($result->getLongitude()); + $this->assertNull($result->getCoordinates()->getLatitude()); + $this->assertNull($result->getCoordinates()->getLongitude()); $this->assertNull($result->getStreetNumber()); $this->assertNull($result->getStreetName()); $this->assertNull($result->getPostalCode()); @@ -159,8 +159,8 @@ public function testGeocodeWithRealIPv4GetsFakeContent() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(33.034698486328, $result->getLatitude(), '', 0.0001); - $this->assertEquals(-96.813400268555, $result->getLongitude(), '', 0.0001); + $this->assertEquals(33.034698486328, $result->getCoordinates()->getLatitude(), '', 0.0001); + $this->assertEquals(-96.813400268555, $result->getCoordinates()->getLongitude(), '', 0.0001); $this->assertNull($result->getStreetNumber()); $this->assertNull($result->getStreetName()); $this->assertEquals(75093, $result->getPostalCode()); @@ -191,8 +191,8 @@ public function testGeocodeWithRealIPv4GetsFakeContent() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(37.748402, $result->getLatitude(), '', 0.0001); - $this->assertEquals(-122.415604, $result->getLongitude(), '', 0.0001); + $this->assertEquals(37.748402, $result->getCoordinates()->getLatitude(), '', 0.0001); + $this->assertEquals(-122.415604, $result->getCoordinates()->getLongitude(), '', 0.0001); $this->assertNull($result->getStreetNumber()); $this->assertNull($result->getStreetName()); $this->assertEquals(94110, $result->getPostalCode()); @@ -304,8 +304,8 @@ public function testGeocodeServiceWithRealIPv4() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(33.034698, $result->getLatitude(), '', 0.1); - $this->assertEquals(-96.813400, $result->getLongitude(), '', 0.1); + $this->assertEquals(33.034698, $result->getCoordinates()->getLatitude(), '', 0.1); + $this->assertEquals(-96.813400, $result->getCoordinates()->getLongitude(), '', 0.1); $this->assertFalse($result->getBounds()->isDefined()); $this->assertNull($result->getStreetNumber()); $this->assertNull($result->getStreetName()); @@ -336,8 +336,8 @@ public function testGeocodeOmniServiceWithRealIPv4() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(33.0347, $result->getLatitude(), '', 0.1); - $this->assertEquals(-96.8134, $result->getLongitude(), '', 0.1); + $this->assertEquals(33.0347, $result->getCoordinates()->getLatitude(), '', 0.1); + $this->assertEquals(-96.8134, $result->getCoordinates()->getLongitude(), '', 0.1); $this->assertFalse($result->getBounds()->isDefined()); $this->assertNull($result->getStreetNumber()); $this->assertNull($result->getStreetName()); @@ -368,8 +368,8 @@ public function testGeocodeOmniServiceWithRealIPv4WithSslAndEncoding() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(-27.5833, $result->getLatitude(), '', 0.1); - $this->assertEquals(-48.5666, $result->getLongitude(), '', 0.1); + $this->assertEquals(-27.5833, $result->getCoordinates()->getLatitude(), '', 0.1); + $this->assertEquals(-48.5666, $result->getCoordinates()->getLongitude(), '', 0.1); $this->assertFalse($result->getBounds()->isDefined()); $this->assertNull($result->getStreetNumber()); $this->assertNull($result->getStreetName()); @@ -399,8 +399,8 @@ public function testGeocodeWithRealIPv6() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(40.2181, $result->getLatitude(), '', 0.1); - $this->assertEquals(-111.6133, $result->getLongitude(), '', 0.1); + $this->assertEquals(40.2181, $result->getCoordinates()->getLatitude(), '', 0.1); + $this->assertEquals(-111.6133, $result->getCoordinates()->getLongitude(), '', 0.1); $this->assertFalse($result->getBounds()->isDefined()); $this->assertNull($result->getStreetNumber()); $this->assertNull($result->getStreetName()); @@ -431,8 +431,8 @@ public function testGeocodeOmniServiceWithRealIPv6WithSsl() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(40.2181, $result->getLatitude(), '', 0.1); - $this->assertEquals(-111.6133, $result->getLongitude(), '', 0.1); + $this->assertEquals(40.2181, $result->getCoordinates()->getLatitude(), '', 0.1); + $this->assertEquals(-111.6133, $result->getCoordinates()->getLongitude(), '', 0.1); $this->assertFalse($result->getBounds()->isDefined()); $this->assertNull($result->getStreetNumber()); $this->assertNull($result->getStreetName()); diff --git a/tests/Geocoder/Tests/Provider/NominatimTest.php b/tests/Geocoder/Tests/Provider/NominatimTest.php index a9e02d475..26888f5f5 100644 --- a/tests/Geocoder/Tests/Provider/NominatimTest.php +++ b/tests/Geocoder/Tests/Provider/NominatimTest.php @@ -19,8 +19,8 @@ public function testGeocodeWithRealAddress() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(48.8565056, $result->getLatitude(), '', 0.01); - $this->assertEquals(2.3521334, $result->getLongitude(), '', 0.01); + $this->assertEquals(48.8565056, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(2.3521334, $result->getCoordinates()->getLongitude(), '', 0.01); $this->assertTrue($result->getBounds()->isDefined()); $this->assertEquals(48.8155250549316, $result->getBounds()->getSouth(), '', 0.01); $this->assertEquals(2.22412180900574, $result->getBounds()->getWest(), '', 0.01); @@ -41,8 +41,8 @@ public function testGeocodeWithRealAddress() /** @var Location $result */ $result = $results->get(1); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(48.8588408, $result->getLatitude(), '', 0.01); - $this->assertEquals(2.32003465529896, $result->getLongitude(), '', 0.01); + $this->assertEquals(48.8588408, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(2.32003465529896, $result->getCoordinates()->getLongitude(), '', 0.01); $this->assertTrue($result->getBounds()->isDefined()); $this->assertEquals(48.8155250549316, $result->getBounds()->getSouth(), '', 0.01); $this->assertEquals(2.22412180900574, $result->getBounds()->getWest(), '', 0.01); @@ -63,8 +63,8 @@ public function testGeocodeWithRealAddress() /** @var Location $result */ $result = $results->get(2); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(35.28687645, $result->getLatitude(), '', 0.01); - $this->assertEquals(-93.7354879210082, $result->getLongitude(), '', 0.01); + $this->assertEquals(35.28687645, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(-93.7354879210082, $result->getCoordinates()->getLongitude(), '', 0.01); $this->assertTrue($result->getBounds()->isDefined()); $this->assertEquals(35.2672462463379, $result->getBounds()->getSouth(), '', 0.01); $this->assertEquals(-93.7618103027344, $result->getBounds()->getWest(), '', 0.01); @@ -85,8 +85,8 @@ public function testGeocodeWithRealAddress() /** @var Location $result */ $result = $results->get(3); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(33.6751155, $result->getLatitude(), '', 0.01); - $this->assertEquals(-95.5502662477703, $result->getLongitude(), '', 0.01); + $this->assertEquals(33.6751155, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(-95.5502662477703, $result->getCoordinates()->getLongitude(), '', 0.01); $this->assertTrue($result->getBounds()->isDefined()); $this->assertEquals(33.6118507385254, $result->getBounds()->getSouth(), '', 0.01); $this->assertEquals(-95.6279296875, $result->getBounds()->getWest(), '', 0.01); @@ -107,8 +107,8 @@ public function testGeocodeWithRealAddress() /** @var Location $result */ $result = $results->get(4); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(38.2097987, $result->getLatitude(), '', 0.01); - $this->assertEquals(-84.2529869, $result->getLongitude(), '', 0.01); + $this->assertEquals(38.2097987, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(-84.2529869, $result->getCoordinates()->getLongitude(), '', 0.01); $this->assertTrue($result->getBounds()->isDefined()); $this->assertEquals(38.1649208068848, $result->getBounds()->getSouth(), '', 0.01); $this->assertEquals(-84.3073272705078, $result->getBounds()->getWest(), '', 0.01); @@ -138,8 +138,8 @@ public function testGeocodeWithRealAddressWithLocale() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(45.7586841, $result->getLatitude(), '', 0.01); - $this->assertEquals(3.1354075, $result->getLongitude(), '', 0.01); + $this->assertEquals(45.7586841, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(3.1354075, $result->getCoordinates()->getLongitude(), '', 0.01); $this->assertTrue($result->getBounds()->isDefined()); $this->assertEquals(45.7576484680176, $result->getBounds()->getSouth(), '', 0.01); $this->assertEquals(3.13258004188538, $result->getBounds()->getWest(), '', 0.01); @@ -160,8 +160,8 @@ public function testGeocodeWithRealAddressWithLocale() /** @var Location $result */ $result = $results->get(1); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(45.7586841, $result->getLatitude(), '', 0.01); - $this->assertEquals(3.1354075, $result->getLongitude(), '', 0.01); + $this->assertEquals(45.7586841, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(3.1354075, $result->getCoordinates()->getLongitude(), '', 0.01); $this->assertTrue($result->getBounds()->isDefined()); $this->assertEquals(45.7576484680176, $result->getBounds()->getSouth(), '', 0.01); $this->assertEquals(3.13258004188538, $result->getBounds()->getWest(), '', 0.01); @@ -191,8 +191,8 @@ public function testReverseWithRealCoordinates() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(60.4539, $result->getLatitude(), '', 0.001); - $this->assertEquals(22.2568, $result->getLongitude(), '', 0.001); + $this->assertEquals(60.4539, $result->getCoordinates()->getLatitude(), '', 0.001); + $this->assertEquals(22.2568, $result->getCoordinates()->getLongitude(), '', 0.001); $this->assertFalse($result->getBounds()->isDefined()); $this->assertEquals(35, $result->getStreetNumber()); $this->assertEquals('Läntinen Pitkäkatu', $result->getStreetName()); @@ -228,8 +228,8 @@ public function testReverseWithRealCoordinatesWithLocale() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(50.1856803, $result->getLatitude(), '', 0.01); - $this->assertEquals(8.6506285, $result->getLongitude(), '', 0.01); + $this->assertEquals(50.1856803, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(8.6506285, $result->getCoordinates()->getLongitude(), '', 0.01); $this->assertTrue($result->getBounds()->isDefined()); $this->assertEquals(50.1851196289062, $result->getBounds()->getSouth(), '', 0.01); $this->assertEquals(8.64984607696533, $result->getBounds()->getWest(), '', 0.01); @@ -249,8 +249,8 @@ public function testReverseWithRealCoordinatesWithLocale() /** @var Location $result */ $result = $results->get(1); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(50.1845911, $result->getLatitude(), '', 0.01); - $this->assertEquals(8.6540194, $result->getLongitude(), '', 0.01); + $this->assertEquals(50.1845911, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(8.6540194, $result->getCoordinates()->getLongitude(), '', 0.01); $this->assertTrue($result->getBounds()->isDefined()); $this->assertEquals(50.1840019226074, $result->getBounds()->getSouth(), '', 0.01); $this->assertEquals(8.65207481384277, $result->getBounds()->getWest(), '', 0.01); @@ -270,8 +270,8 @@ public function testReverseWithRealCoordinatesWithLocale() /** @var Location $result */ $result = $results->get(2); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(50.1862884, $result->getLatitude(), '', 0.01); - $this->assertEquals(8.6493167, $result->getLongitude(), '', 0.01); + $this->assertEquals(50.1862884, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(8.6493167, $result->getCoordinates()->getLongitude(), '', 0.01); $this->assertTrue($result->getBounds()->isDefined()); $this->assertEquals(50.1862106323242, $result->getBounds()->getSouth(), '', 0.01); $this->assertEquals(8.64931583404541, $result->getBounds()->getWest(), '', 0.01); @@ -291,8 +291,8 @@ public function testReverseWithRealCoordinatesWithLocale() /** @var Location $result */ $result = $results->get(3); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(50.1861344, $result->getLatitude(), '', 0.01); - $this->assertEquals(8.649578, $result->getLongitude(), '', 0.01); + $this->assertEquals(50.1861344, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(8.649578, $result->getCoordinates()->getLongitude(), '', 0.01); $this->assertTrue($result->getBounds()->isDefined()); $this->assertEquals(50.1860084533691, $result->getBounds()->getSouth(), '', 0.01); $this->assertEquals(8.64943885803223, $result->getBounds()->getWest(), '', 0.01); @@ -347,8 +347,8 @@ public function testGeocodeWithRealIPv4() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(43.6189768, $result->getLatitude(), '', 0.01); - $this->assertEquals(1.4564493, $result->getLongitude(), '', 0.01); + $this->assertEquals(43.6189768, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(1.4564493, $result->getCoordinates()->getLongitude(), '', 0.01); $this->assertTrue($result->getBounds()->isDefined()); $this->assertEquals(43.6159553527832, $result->getBounds()->getSouth(), '', 0.01); $this->assertEquals(1.45302963256836, $result->getBounds()->getWest(), '', 0.01); @@ -378,8 +378,8 @@ public function testGeocodeWithRealIPv4WithLocale() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(43.6155351, $result->getLatitude(), '', 0.01); - $this->assertEquals(1.4525647, $result->getLongitude(), '', 0.01); + $this->assertEquals(43.6155351, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(1.4525647, $result->getCoordinates()->getLongitude(), '', 0.01); $this->assertTrue($result->getBounds()->isDefined()); $this->assertEquals(43.6154556274414, $result->getBounds()->getSouth(), '', 0.01); $this->assertEquals(1.4524964094162, $result->getBounds()->getWest(), '', 0.01); diff --git a/tests/Geocoder/Tests/Provider/OpenCageTest.php b/tests/Geocoder/Tests/Provider/OpenCageTest.php index 335cbdd29..3987006f3 100644 --- a/tests/Geocoder/Tests/Provider/OpenCageTest.php +++ b/tests/Geocoder/Tests/Provider/OpenCageTest.php @@ -62,8 +62,8 @@ public function testGeocodeWithRealAddress() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(48.866205, $result->getLatitude(), '', 0.01); - $this->assertEquals(2.389089, $result->getLongitude(), '', 0.01); + $this->assertEquals(48.866205, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(2.389089, $result->getCoordinates()->getLongitude(), '', 0.01); $this->assertTrue($result->getBounds()->isDefined()); $this->assertEquals(48.863142699999997, $result->getBounds()->getSouth()); $this->assertEquals(2.3890394000000001, $result->getBounds()->getWest()); @@ -109,8 +109,8 @@ public function testReverseWithRealCoordinates() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(54.0484068, $result->getLatitude(), '', 0.001); - $this->assertEquals(-2.7990345, $result->getLongitude(), '', 0.001); + $this->assertEquals(54.0484068, $result->getCoordinates()->getLatitude(), '', 0.001); + $this->assertEquals(-2.7990345, $result->getCoordinates()->getLongitude(), '', 0.001); $this->assertTrue($result->getBounds()->isDefined()); $this->assertEquals(54.048273100000003, $result->getBounds()->getSouth()); $this->assertEquals(-2.7998815000000001, $result->getBounds()->getWest()); @@ -161,8 +161,8 @@ public function testGeocodeWithCity() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(52.374478, $result->getLatitude(), '', 0.01); - $this->assertEquals(9.738553, $result->getLongitude(), '', 0.01); + $this->assertEquals(52.374478, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(9.738553, $result->getCoordinates()->getLongitude(), '', 0.01); $this->assertEquals('Hanover', $result->getLocality()); $this->assertCount(2, $result->getAdminLevels()); $this->assertEquals('Region Hannover', $result->getAdminLevels()->get(2)->getName()); @@ -172,8 +172,8 @@ public function testGeocodeWithCity() /** @var Location $result */ $result = $results->get(1); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(37.744783, $result->getLatitude(), '', 0.01); - $this->assertEquals(-77.4464165, $result->getLongitude(), '', 0.01); + $this->assertEquals(37.744783, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(-77.4464165, $result->getCoordinates()->getLongitude(), '', 0.01); $this->assertNull($result->getLocality()); $this->assertCount(2, $result->getAdminLevels()); $this->assertEquals('Hanover', $result->getAdminLevels()->get(2)->getName()); @@ -182,8 +182,8 @@ public function testGeocodeWithCity() /** @var Location $result */ $result = $results->get(2); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(18.3840489, $result->getLatitude(), '', 0.01); - $this->assertEquals(-78.131485, $result->getLongitude(), '', 0.01); + $this->assertEquals(18.3840489, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(-78.131485, $result->getCoordinates()->getLongitude(), '', 0.01); $this->assertNull($result->getLocality()); $this->assertTrue( $result->getAdminLevels()->has(2)); $this->assertEquals('Hanover', $result->getAdminLevels()->get(2)->getName()); @@ -192,8 +192,8 @@ public function testGeocodeWithCity() /** @var Location $result */ $result = $results->get(3); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(43.7033073, $result->getLatitude(), '', 0.01); - $this->assertEquals(-72.2885663, $result->getLongitude(), '', 0.01); + $this->assertEquals(43.7033073, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(-72.2885663, $result->getCoordinates()->getLongitude(), '', 0.01); $this->assertEquals('Hanover', $result->getLocality()); $this->assertCount(2, $result->getAdminLevels()); $this->assertEquals('Grafton County', $result->getAdminLevels()->get(2)->getName()); @@ -216,8 +216,8 @@ public function testGeocodeWithCityDistrict() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(50.189062, $result->getLatitude(), '', 0.01); - $this->assertEquals(8.636567, $result->getLongitude(), '', 0.01); + $this->assertEquals(50.189062, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(8.636567, $result->getCoordinates()->getLongitude(), '', 0.01); $this->assertEquals(10, $result->getStreetNumber()); $this->assertEquals('Kalbacher Hauptstraße', $result->getStreetName()); $this->assertEquals(60437, $result->getPostalCode()); diff --git a/tests/Geocoder/Tests/Provider/TomTomTest.php b/tests/Geocoder/Tests/Provider/TomTomTest.php index 748c2b012..ee233fe25 100644 --- a/tests/Geocoder/Tests/Provider/TomTomTest.php +++ b/tests/Geocoder/Tests/Provider/TomTomTest.php @@ -94,8 +94,8 @@ public function testGeocodeWithRealAddress() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(55.704389, $result->getLatitude(), '', 0.0001); - $this->assertEquals(12.546129, $result->getLongitude(), '', 0.0001); + $this->assertEquals(55.704389, $result->getCoordinates()->getLatitude(), '', 0.0001); + $this->assertEquals(12.546129, $result->getCoordinates()->getLongitude(), '', 0.0001); $this->assertFalse($result->getBounds()->isDefined()); $this->assertNull($result->getStreetNumber()); $this->assertEquals('Tagensvej', $result->getStreetName()); @@ -123,8 +123,8 @@ public function testGeocodeWithRealAddressWithFrenchLocale() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(55.704389, $result->getLatitude(), '', 0.0001); - $this->assertEquals(12.546129, $result->getLongitude(), '', 0.0001); + $this->assertEquals(55.704389, $result->getCoordinates()->getLatitude(), '', 0.0001); + $this->assertEquals(12.546129, $result->getCoordinates()->getLongitude(), '', 0.0001); $this->assertFalse($result->getBounds()->isDefined()); $this->assertNull($result->getStreetNumber()); $this->assertEquals('Tagensvej', $result->getStreetName()); @@ -152,8 +152,8 @@ public function testGeocodeWithRealAddressWithSwedishLocale() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(55.704389, $result->getLatitude(), '', 0.0001); - $this->assertEquals(12.546129, $result->getLongitude(), '', 0.0001); + $this->assertEquals(55.704389, $result->getCoordinates()->getLatitude(), '', 0.0001); + $this->assertEquals(12.546129, $result->getCoordinates()->getLongitude(), '', 0.0001); $this->assertFalse($result->getBounds()->isDefined()); $this->assertNull($result->getStreetNumber()); $this->assertEquals('Tagensvej', $result->getStreetName()); @@ -181,8 +181,8 @@ public function testGeocodeWithRealAddressReturnsMultipleResults() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(48.856898, $result->getLatitude(), '', 0.0001); - $this->assertEquals(2.350844, $result->getLongitude(), '', 0.0001); + $this->assertEquals(48.856898, $result->getCoordinates()->getLatitude(), '', 0.0001); + $this->assertEquals(2.350844, $result->getCoordinates()->getLongitude(), '', 0.0001); $this->assertFalse($result->getBounds()->isDefined()); $this->assertNull($result->getStreetNumber()); $this->assertNull($result->getStreetName()); @@ -199,8 +199,8 @@ public function testGeocodeWithRealAddressReturnsMultipleResults() /** @var Location $result */ $result = $results->get(1); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(33.661426, $result->getLatitude(), '', 0.0001); - $this->assertEquals(-95.556321, $result->getLongitude(), '', 0.0001); + $this->assertEquals(33.661426, $result->getCoordinates()->getLatitude(), '', 0.0001); + $this->assertEquals(-95.556321, $result->getCoordinates()->getLongitude(), '', 0.0001); $this->assertEquals('Paris', $result->getLocality()); $this->assertCount(1, $result->getAdminLevels()); $this->assertEquals('Texas', $result->getAdminLevels()->get(1)->getName()); @@ -210,8 +210,8 @@ public function testGeocodeWithRealAddressReturnsMultipleResults() /** @var Location $result */ $result = $results->get(2); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(36.302754, $result->getLatitude(), '', 0.0001); - $this->assertEquals(-88.326359, $result->getLongitude(), '', 0.0001); + $this->assertEquals(36.302754, $result->getCoordinates()->getLatitude(), '', 0.0001); + $this->assertEquals(-88.326359, $result->getCoordinates()->getLongitude(), '', 0.0001); $this->assertEquals('Paris', $result->getLocality()); $this->assertCount(1, $result->getAdminLevels()); $this->assertEquals('Tennessee', $result->getAdminLevels()->get(1)->getName()); @@ -221,8 +221,8 @@ public function testGeocodeWithRealAddressReturnsMultipleResults() /** @var Location $result */ $result = $results->get(3); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(-19.039448, $result->getLatitude(), '', 0.0001); - $this->assertEquals(29.560445, $result->getLongitude(), '', 0.0001); + $this->assertEquals(-19.039448, $result->getCoordinates()->getLatitude(), '', 0.0001); + $this->assertEquals(29.560445, $result->getCoordinates()->getLongitude(), '', 0.0001); $this->assertEquals('Paris', $result->getLocality()); $this->assertCount(1, $result->getAdminLevels()); $this->assertEquals('Midlands', $result->getAdminLevels()->get(1)->getName()); @@ -232,8 +232,8 @@ public function testGeocodeWithRealAddressReturnsMultipleResults() /** @var Location $result */ $result = $results->get(4); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(35.292105, $result->getLatitude(), '', 0.0001); - $this->assertEquals(-93.729922, $result->getLongitude(), '', 0.0001); + $this->assertEquals(35.292105, $result->getCoordinates()->getLatitude(), '', 0.0001); + $this->assertEquals(-93.729922, $result->getCoordinates()->getLongitude(), '', 0.0001); $this->assertEquals('Paris', $result->getLocality()); $this->assertCount(1, $result->getAdminLevels()); $this->assertEquals('Arkansas', $result->getAdminLevels()->get(1)->getName()); @@ -364,8 +364,8 @@ public function testReverseWithRealCoordinates() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(48.86323, $result->getLatitude(), '', 0.001); - $this->assertEquals(2.38877, $result->getLongitude(), '', 0.001); + $this->assertEquals(48.86323, $result->getCoordinates()->getLatitude(), '', 0.001); + $this->assertEquals(2.38877, $result->getCoordinates()->getLongitude(), '', 0.001); $this->assertFalse($result->getBounds()->isDefined()); $this->assertNull($result->getStreetNumber()); $this->assertEquals('Avenue Gambetta', $result->getStreetName()); @@ -393,8 +393,8 @@ public function testGeocodeWithRealCoordinates() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(56.52435, $result->getLatitude(), '', 0.001); - $this->assertEquals(10.06744, $result->getLongitude(), '', 0.001); + $this->assertEquals(56.52435, $result->getCoordinates()->getLatitude(), '', 0.001); + $this->assertEquals(10.06744, $result->getCoordinates()->getLongitude(), '', 0.001); $this->assertFalse($result->getBounds()->isDefined()); $this->assertNull($result->getStreetNumber()); $this->assertEquals('Stabelsvej', $result->getStreetName()); diff --git a/tests/Geocoder/Tests/Provider/YandexTest.php b/tests/Geocoder/Tests/Provider/YandexTest.php index 77ea0170a..0ef07e19b 100644 --- a/tests/Geocoder/Tests/Provider/YandexTest.php +++ b/tests/Geocoder/Tests/Provider/YandexTest.php @@ -98,8 +98,8 @@ public function testGeocodeWithRealAddress() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('Geocoder\Model\Address', $result); - $this->assertEquals(48.863277, $result->getLatitude(), '', 0.01); - $this->assertEquals(2.389016, $result->getLongitude(), '', 0.01); + $this->assertEquals(48.863277, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(2.389016, $result->getCoordinates()->getLongitude(), '', 0.01); $this->assertTrue($result->getBounds()->isDefined()); $this->assertEquals(48.861926, $result->getBounds()->getSouth(), '', 0.01); $this->assertEquals(2.386967, $result->getBounds()->getWest(), '', 0.01); @@ -133,8 +133,8 @@ public function testGeocodeWithRealAddressWithUALocale() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('Geocoder\Model\Address', $result); - $this->assertEquals(55.675676, $result->getLatitude(), '', 0.01); - $this->assertEquals(12.567593, $result->getLongitude(), '', 0.01); + $this->assertEquals(55.675676, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(12.567593, $result->getCoordinates()->getLongitude(), '', 0.01); $this->assertTrue($result->getBounds()->isDefined()); $this->assertEquals(55.614999, $result->getBounds()->getSouth(), '', 0.01); $this->assertEquals(12.45295, $result->getBounds()->getWest(), '', 0.01); @@ -157,26 +157,26 @@ public function testGeocodeWithRealAddressWithUALocale() /** @var Location $result */ $result = $results->get(1); $this->assertInstanceOf('Geocoder\Model\Address', $result); - $this->assertEquals(55.455739, $result->getLatitude(), '', 0.01); - $this->assertEquals(9.972854, $result->getLongitude(), '', 0.01); + $this->assertEquals(55.455739, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(9.972854, $result->getCoordinates()->getLongitude(), '', 0.01); /** @var Location $result */ $result = $results->get(2); $this->assertInstanceOf('Geocoder\Model\Address', $result); - $this->assertEquals(55.713258, $result->getLatitude(), '', 0.01); - $this->assertEquals(12.534930, $result->getLongitude(), '', 0.01); + $this->assertEquals(55.713258, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(12.534930, $result->getCoordinates()->getLongitude(), '', 0.01); /** @var Location $result */ $result = $results->get(3); $this->assertInstanceOf('Geocoder\Model\Address', $result); - $this->assertEquals(55.698878, $result->getLatitude(), '', 0.01); - $this->assertEquals(12.578211, $result->getLongitude(), '', 0.01); + $this->assertEquals(55.698878, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(12.578211, $result->getCoordinates()->getLongitude(), '', 0.01); /** @var Location $result */ $result = $results->get(4); $this->assertInstanceOf('Geocoder\Model\Address', $result); - $this->assertEquals(55.690380, $result->getLatitude(), '', 0.01); - $this->assertEquals(12.554827, $result->getLongitude(), '', 0.01); + $this->assertEquals(55.690380, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(12.554827, $result->getCoordinates()->getLongitude(), '', 0.01); } public function testGeocodeWithRealAddressWithUSLocale() @@ -190,8 +190,8 @@ public function testGeocodeWithRealAddressWithUSLocale() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('Geocoder\Model\Address', $result); - $this->assertEquals(38.897695, $result->getLatitude(), '', 0.01); - $this->assertEquals(-77.038692, $result->getLongitude(), '', 0.01); + $this->assertEquals(38.897695, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(-77.038692, $result->getCoordinates()->getLongitude(), '', 0.01); $this->assertTrue($result->getBounds()->isDefined()); $this->assertEquals(38.891265, $result->getBounds()->getSouth(), '', 0.01); $this->assertEquals(-77.046921, $result->getBounds()->getWest(), '', 0.01); @@ -224,8 +224,8 @@ public function testGeocodeWithRealAddressWithBYLocale() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('Geocoder\Model\Address', $result); - $this->assertEquals(53.898077, $result->getLatitude(), '', 0.01); - $this->assertEquals(27.563673, $result->getLongitude(), '', 0.01); + $this->assertEquals(53.898077, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(27.563673, $result->getCoordinates()->getLongitude(), '', 0.01); $this->assertTrue($result->getBounds()->isDefined()); $this->assertEquals(53.896867, $result->getBounds()->getSouth(), '', 0.01); $this->assertEquals(27.561624, $result->getBounds()->getWest(), '', 0.01); @@ -286,8 +286,8 @@ public function testReverseWithRealCoordinates() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('Geocoder\Model\Address', $result); - $this->assertEquals(48.863212, $result->getLatitude(), '', 0.01); - $this->assertEquals(2.388773, $result->getLongitude(), '', 0.01); + $this->assertEquals(48.863212, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(2.388773, $result->getCoordinates()->getLongitude(), '', 0.01); $this->assertTrue($result->getBounds()->isDefined()); $this->assertEquals(48.86294, $result->getBounds()->getSouth(), '', 0.01); $this->assertEquals(2.387497, $result->getBounds()->getWest(), '', 0.01); @@ -312,14 +312,14 @@ public function testReverseWithRealCoordinates() /** @var Location $result */ $result = $results->get(1); $this->assertInstanceOf('Geocoder\Model\Address', $result); - $this->assertEquals(48.864848, $result->getLatitude(), '', 0.01); - $this->assertEquals(2.3993549, $result->getLongitude(), '', 0.01); + $this->assertEquals(48.864848, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(2.3993549, $result->getCoordinates()->getLongitude(), '', 0.01); /** @var Location $result */ $result = $results->get(2); $this->assertInstanceOf('Geocoder\Model\Address', $result); - $this->assertEquals(48.856929, $result->getLatitude(), '', 0.01); - $this->assertEquals(2.341197, $result->getLongitude(), '', 0.01); + $this->assertEquals(48.856929, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(2.341197, $result->getCoordinates()->getLongitude(), '', 0.01); } public function testReverseWithRealCoordinatesWithUSLocaleAndStreeToponym() @@ -333,8 +333,8 @@ public function testReverseWithRealCoordinatesWithUSLocaleAndStreeToponym() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('Geocoder\Model\Address', $result); - $this->assertEquals(48.87132, $result->getLatitude(), '', 0.01); - $this->assertEquals(2.404017, $result->getLongitude(), '', 0.01); + $this->assertEquals(48.87132, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(2.404017, $result->getCoordinates()->getLongitude(), '', 0.01); $this->assertTrue($result->getBounds()->isDefined()); $this->assertEquals(48.86294, $result->getBounds()->getSouth(), '', 0.01); $this->assertEquals(2.387497, $result->getBounds()->getWest(), '', 0.01); @@ -359,26 +359,26 @@ public function testReverseWithRealCoordinatesWithUSLocaleAndStreeToponym() /** @var Location $result */ $result = $results->get(1); $this->assertInstanceOf('Geocoder\Model\Address', $result); - $this->assertEquals(48.863230, $result->getLatitude(), '', 0.01); - $this->assertEquals(2.388261, $result->getLongitude(), '', 0.01); + $this->assertEquals(48.863230, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(2.388261, $result->getCoordinates()->getLongitude(), '', 0.01); /** @var Location $result */ $result = $results->get(2); $this->assertInstanceOf('Geocoder\Model\Address', $result); - $this->assertEquals(48.866022, $result->getLatitude(), '', 0.01); - $this->assertEquals(2.389662, $result->getLongitude(), '', 0.01); + $this->assertEquals(48.866022, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(2.389662, $result->getCoordinates()->getLongitude(), '', 0.01); /** @var Location $result */ $result = $results->get(3); $this->assertInstanceOf('Geocoder\Model\Address', $result); - $this->assertEquals(48.863918, $result->getLatitude(), '', 0.01); - $this->assertEquals(2.387767, $result->getLongitude(), '', 0.01); + $this->assertEquals(48.863918, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(2.387767, $result->getCoordinates()->getLongitude(), '', 0.01); /** @var Location $result */ $result = $results->get(4); $this->assertInstanceOf('Geocoder\Model\Address', $result); - $this->assertEquals(48.863787, $result->getLatitude(), '', 0.01); - $this->assertEquals(2.389600, $result->getLongitude(), '', 0.01); + $this->assertEquals(48.863787, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(2.389600, $result->getCoordinates()->getLongitude(), '', 0.01); } public function testReverseWithRealCoordinatesWithUALocaleAndHouseToponym() @@ -392,8 +392,8 @@ public function testReverseWithRealCoordinatesWithUALocaleAndHouseToponym() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('Geocoder\Model\Address', $result); - $this->assertEquals(60.454462, $result->getLatitude(), '', 0.01); - $this->assertEquals(22.256561, $result->getLongitude(), '', 0.01); + $this->assertEquals(60.454462, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(22.256561, $result->getCoordinates()->getLongitude(), '', 0.01); $this->assertTrue($result->getBounds()->isDefined()); $this->assertEquals(60.45345, $result->getBounds()->getSouth(), '', 0.01); $this->assertEquals(22.254513, $result->getBounds()->getWest(), '', 0.01); @@ -427,8 +427,8 @@ public function testReverseWithRealCoordinatesWithTRLocaleAndLocalityToponym() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('Geocoder\Model\Address', $result); - $this->assertEquals(40.874651, $result->getLatitude(), '', 0.01); - $this->assertEquals(29.129562, $result->getLongitude(), '', 0.01); + $this->assertEquals(40.874651, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(29.129562, $result->getCoordinates()->getLongitude(), '', 0.01); $this->assertTrue($result->getBounds()->isDefined()); $this->assertEquals(40.860413, $result->getBounds()->getSouth(), '', 0.01); $this->assertEquals(29.107230, $result->getBounds()->getWest(), '', 0.01); From baf73b3f4e10943a54067fc00bd66cd53c36df02 Mon Sep 17 00:00:00 2001 From: Tobias Nyholm Date: Mon, 7 Nov 2016 19:09:55 +0100 Subject: [PATCH 18/21] Renamed GeocoderResult to Collection --- CHANGELOG.md | 2 +- src/Geocoder/{GeocoderResult.php => Collection.php} | 2 +- src/Geocoder/Geocoder.php | 4 ++-- src/Geocoder/Model/AddressCollection.php | 6 +++--- src/Geocoder/Model/AddressFactory.php | 4 ++-- src/Geocoder/Provider/AbstractProvider.php | 4 ++-- src/Geocoder/Provider/FreeGeoIp.php | 4 ++-- src/Geocoder/Provider/HostIp.php | 4 ++-- src/Geocoder/Provider/IpInfoDb.php | 4 ++-- src/Geocoder/Provider/OpenCage.php | 4 ++-- 10 files changed, 19 insertions(+), 19 deletions(-) rename src/Geocoder/{GeocoderResult.php => Collection.php} (92%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 940279cf5..0615384ed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ CHANGELOG ### 4.0.0 (2016-xx-xx) -* Added: Interface for `Geocoder\Model\AddressCollection` called `Geocoder\GeocoderResult`. Public APIs are updated to type hint for `Geocoder\GeocoderResult`. +* Added: Interface for `Geocoder\Model\AddressCollection` called `Geocoder\Collection`. Public APIs are updated to type hint for `Geocoder\GeocoderResult`. * Added: Interface for `Geocoder\Model\Address` called `Geocoder\Location`. Public APIs are updated to type hint for `Geocoder\Location`. * Added: `Country::isDefined` * Added: `Cordinates::isDefined` diff --git a/src/Geocoder/GeocoderResult.php b/src/Geocoder/Collection.php similarity index 92% rename from src/Geocoder/GeocoderResult.php rename to src/Geocoder/Collection.php index e42b37806..2b357c30d 100644 --- a/src/Geocoder/GeocoderResult.php +++ b/src/Geocoder/Collection.php @@ -8,7 +8,7 @@ * @author William Durand * @author Tobias Nyholm */ -interface GeocoderResult extends \IteratorAggregate, \Countable +interface Collection extends \IteratorAggregate, \Countable { /** * {@inheritDoc} diff --git a/src/Geocoder/Geocoder.php b/src/Geocoder/Geocoder.php index b731404d3..7a90a8638 100644 --- a/src/Geocoder/Geocoder.php +++ b/src/Geocoder/Geocoder.php @@ -25,7 +25,7 @@ interface Geocoder * * @param string $value * - * @return GeocoderResult + * @return Collection * @throws \Geocoder\Exception\Exception */ public function geocode($value); @@ -36,7 +36,7 @@ public function geocode($value); * @param double $latitude * @param double $longitude * - * @return GeocoderResult + * @return Collection * @throws \Geocoder\Exception\Exception */ public function reverse($latitude, $longitude); diff --git a/src/Geocoder/Model/AddressCollection.php b/src/Geocoder/Model/AddressCollection.php index 868a3a2fd..6cdd61291 100644 --- a/src/Geocoder/Model/AddressCollection.php +++ b/src/Geocoder/Model/AddressCollection.php @@ -3,10 +3,10 @@ namespace Geocoder\Model; use Geocoder\Exception\CollectionIsEmpty; -use Geocoder\GeocoderResult; +use Geocoder\Collection; use Geocoder\Location; -final class AddressCollection implements GeocoderResult +final class AddressCollection implements Collection { /** * @var Location[] @@ -43,7 +43,7 @@ public function count() public function first() { if (empty($this->addresses)) { - throw new CollectionIsEmpty('The GeocoderResult instance is empty.'); + throw new CollectionIsEmpty('The Collection instance is empty.'); } return reset($this->addresses); diff --git a/src/Geocoder/Model/AddressFactory.php b/src/Geocoder/Model/AddressFactory.php index 87d553de1..e8c4560cb 100644 --- a/src/Geocoder/Model/AddressFactory.php +++ b/src/Geocoder/Model/AddressFactory.php @@ -10,7 +10,7 @@ namespace Geocoder\Model; -use Geocoder\GeocoderResult; +use Geocoder\Collection; /** * @author Markus Bachmann @@ -20,7 +20,7 @@ final class AddressFactory { /** * @param array $results - * @return GeocoderResult + * @return Collection */ public function createFromArray(array $results) { diff --git a/src/Geocoder/Provider/AbstractProvider.php b/src/Geocoder/Provider/AbstractProvider.php index 26f0b29da..cc25fb977 100644 --- a/src/Geocoder/Provider/AbstractProvider.php +++ b/src/Geocoder/Provider/AbstractProvider.php @@ -11,7 +11,7 @@ namespace Geocoder\Provider; use Geocoder\Geocoder; -use Geocoder\GeocoderResult; +use Geocoder\Collection; use Geocoder\Model\AddressFactory; /** @@ -97,7 +97,7 @@ protected function getLocalhostDefaults() /** * @param array $data An array of data. * - * @return GeocoderResult + * @return Collection */ protected function returnResults(array $data = []) { diff --git a/src/Geocoder/Provider/FreeGeoIp.php b/src/Geocoder/Provider/FreeGeoIp.php index c8cc4ec64..4dcd4ff02 100644 --- a/src/Geocoder/Provider/FreeGeoIp.php +++ b/src/Geocoder/Provider/FreeGeoIp.php @@ -12,7 +12,7 @@ use Geocoder\Exception\NoResult; use Geocoder\Exception\UnsupportedOperation; -use Geocoder\GeocoderResult; +use Geocoder\Collection; use Geocoder\Model\Address; /** @@ -62,7 +62,7 @@ public function getName() /** * @param string $query * - * @return GeocoderResult + * @return Collection */ private function executeQuery($query) { diff --git a/src/Geocoder/Provider/HostIp.php b/src/Geocoder/Provider/HostIp.php index 796b4ae4c..2c069e6f5 100644 --- a/src/Geocoder/Provider/HostIp.php +++ b/src/Geocoder/Provider/HostIp.php @@ -12,7 +12,7 @@ use Geocoder\Exception\NoResult; use Geocoder\Exception\UnsupportedOperation; -use Geocoder\GeocoderResult; +use Geocoder\Collection; /** * @author William Durand @@ -66,7 +66,7 @@ public function getName() /** * @param string $query * - * @return GeocoderResult + * @return Collection */ private function executeQuery($query) { diff --git a/src/Geocoder/Provider/IpInfoDb.php b/src/Geocoder/Provider/IpInfoDb.php index a0c5f21a9..5e92d92e0 100644 --- a/src/Geocoder/Provider/IpInfoDb.php +++ b/src/Geocoder/Provider/IpInfoDb.php @@ -14,7 +14,7 @@ use Geocoder\Exception\InvalidCredentials; use Geocoder\Exception\NoResult; use Geocoder\Exception\UnsupportedOperation; -use Geocoder\GeocoderResult; +use Geocoder\Collection; use Http\Client\HttpClient; /** @@ -118,7 +118,7 @@ public function getName() /** * @param string $query * - * @return GeocoderResult + * @return Collection */ private function executeQuery($query) { diff --git a/src/Geocoder/Provider/OpenCage.php b/src/Geocoder/Provider/OpenCage.php index 9f87043c0..ee3e2d3e3 100644 --- a/src/Geocoder/Provider/OpenCage.php +++ b/src/Geocoder/Provider/OpenCage.php @@ -13,7 +13,7 @@ use Geocoder\Exception\QuotaExceeded; use Geocoder\Exception\NoResult; use Geocoder\Exception\UnsupportedOperation; -use Geocoder\GeocoderResult; +use Geocoder\Collection; use Http\Client\HttpClient; /** @@ -92,7 +92,7 @@ public function getName() /** * @param $query - * @return GeocoderResult + * @return Collection */ private function executeQuery($query) { From 0c919f1f264f7f33d53c2c8091e95dd0fae96c81 Mon Sep 17 00:00:00 2001 From: Tobias Nyholm Date: Mon, 7 Nov 2016 19:12:28 +0100 Subject: [PATCH 19/21] Removed functions in Collection that are covered by the interface it extending. --- src/Geocoder/Collection.php | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/Geocoder/Collection.php b/src/Geocoder/Collection.php index 2b357c30d..c464b5183 100644 --- a/src/Geocoder/Collection.php +++ b/src/Geocoder/Collection.php @@ -10,16 +10,6 @@ */ interface Collection extends \IteratorAggregate, \Countable { - /** - * {@inheritDoc} - */ - public function getIterator(); - - /** - * {@inheritDoc} - */ - public function count(); - /** * @return Location */ From 3dd683d4e1d5b77fd44fafb15efb97faf1147762 Mon Sep 17 00:00:00 2001 From: Tobias Nyholm Date: Mon, 7 Nov 2016 21:44:12 +0100 Subject: [PATCH 20/21] Removed isDefined function --- CHANGELOG.md | 3 +- src/Geocoder/Assert.php | 50 +++++++++++++++++++ src/Geocoder/Dumper/GeoJson.php | 13 +++-- src/Geocoder/Dumper/Gpx.php | 12 +++-- src/Geocoder/Dumper/Kml.php | 9 +++- src/Geocoder/Dumper/Wkb.php | 9 +++- src/Geocoder/Dumper/Wkt.php | 9 +++- src/Geocoder/Model/Address.php | 47 ++++++++++++----- src/Geocoder/Model/AddressFactory.php | 21 +++++++- src/Geocoder/Model/Bounds.php | 24 +++++---- src/Geocoder/Model/Coordinates.php | 20 ++++---- src/Geocoder/Model/Country.php | 14 ++---- .../Tests/Model/AddressFactoryTest.php | 2 +- .../Tests/Provider/ArcGISOnlineTest.php | 10 ++-- .../Geocoder/Tests/Provider/BingMapsTest.php | 22 ++++---- tests/Geocoder/Tests/Provider/GeoIP2Test.php | 16 ++++-- tests/Geocoder/Tests/Provider/GeoIPsTest.php | 4 +- tests/Geocoder/Tests/Provider/GeoipTest.php | 4 +- .../Geocoder/Tests/Provider/GeonamesTest.php | 20 ++++---- .../Tests/Provider/GoogleMapsTest.php | 8 +-- tests/Geocoder/Tests/Provider/HostIpTest.php | 8 +-- .../Geocoder/Tests/Provider/IpInfoDbTest.php | 8 +-- .../Geocoder/Tests/Provider/MapQuestTest.php | 6 +-- .../Tests/Provider/MaxMindBinaryTest.php | 4 +- tests/Geocoder/Tests/Provider/MaxMindTest.php | 14 +++--- .../Geocoder/Tests/Provider/NominatimTest.php | 28 +++++------ .../Geocoder/Tests/Provider/OpenCageTest.php | 4 +- tests/Geocoder/Tests/Provider/TomTomTest.php | 12 ++--- tests/Geocoder/Tests/Provider/YandexTest.php | 16 +++--- 29 files changed, 271 insertions(+), 146 deletions(-) create mode 100644 src/Geocoder/Assert.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 0615384ed..8c1c18a56 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,8 @@ CHANGELOG * Added: Interface for `Geocoder\Model\Address` called `Geocoder\Location`. Public APIs are updated to type hint for `Geocoder\Location`. * Added: `Country::isDefined` * Added: `Cordinates::isDefined` -* Changed: `Location::getCoordinates`, `Location::getBounds` and `Location::getCountry` will never return null. +* Changed: `Location::getCoordinates` will return null or a `Coordinates` object with coordinates data. It will never return `Coordinates` without data. +* Changed: `Location::getBounds` will return null or a `Bounds` object with coordinates data. It will never return `Bounds` without data. * Removed: `AdminLevel::toString` in favor for `AdminLevel::__toString`. * Removed: `Country::toString` in favor for `Country::__toString`. * Removed: `Address::getCountryCode` in favor for `Address::getCountry()->getCode()`. diff --git a/src/Geocoder/Assert.php b/src/Geocoder/Assert.php new file mode 100644 index 000000000..e2fe9c31b --- /dev/null +++ b/src/Geocoder/Assert.php @@ -0,0 +1,50 @@ + 90) { + throw new \InvalidArgumentException( + sprintf($message ?: 'Latitude should be between -90 and 90. Got: %s', $value) + ); + } + } + + /** + * @param float $value + * @param string $message + */ + public static function longitude($value, $message = '') + { + if (!is_double($value)) { + throw new \InvalidArgumentException( + sprintf($message ?: 'Expected a doable. Got: %s', self::typeToString($value)) + ); + } + + if ($value < -180 || $value > 180) { + throw new \InvalidArgumentException( + sprintf($message ?: 'Latitude should be between -90 and 90. Got: %s', $value) + ); + } + } + + private static function typeToString($value) + { + return is_object($value) ? get_class($value) : gettype($value); + } + +} diff --git a/src/Geocoder/Dumper/GeoJson.php b/src/Geocoder/Dumper/GeoJson.php index 6b2257563..d8e26b9d7 100644 --- a/src/Geocoder/Dumper/GeoJson.php +++ b/src/Geocoder/Dumper/GeoJson.php @@ -36,19 +36,24 @@ public function dump(Location $location) $properties = null; } + $lat = 0; + $lon = 0; + if (null !== $coordinates = $location->getCoordinates()) { + $lat = $coordinates->getLatitude(); + $lon = $coordinates->getLongitude(); + } + $json = [ 'type' => 'Feature', 'geometry' => [ 'type' => 'Point', - 'coordinates' => [$location->getCoordinates()->getLongitude(), $location->getCoordinates()->getLatitude()] + 'coordinates' => [$lon, $lat], ], 'properties' => $properties, ]; if (null !== $bounds = $location->getBounds()) { - if ($bounds->isDefined()) { - $json['bounds'] = $bounds->toArray(); - } + $json['bounds'] = $bounds->toArray(); } return json_encode($json); diff --git a/src/Geocoder/Dumper/Gpx.php b/src/Geocoder/Dumper/Gpx.php index d7f1e61e4..cb680258b 100644 --- a/src/Geocoder/Dumper/Gpx.php +++ b/src/Geocoder/Dumper/Gpx.php @@ -37,8 +37,7 @@ public function dump(Location $location) GPX , Geocoder::VERSION); - if ($location->getBounds()->isDefined()) { - $bounds = $location->getBounds(); + if (null !== $bounds = $location->getBounds()) { $gpx .= sprintf(<< @@ -46,6 +45,13 @@ public function dump(Location $location) , $bounds->getWest(), $bounds->getSouth(), $bounds->getEast(), $bounds->getNorth()); } + $lat = null; + $lon = null; + if (null !== $coordinates = $location->getCoordinates()) { + $lat = $coordinates->getLatitude(); + $lon = $coordinates->getLongitude(); + } + $gpx .= sprintf(<< @@ -53,7 +59,7 @@ public function dump(Location $location) GPX - , $location->getCoordinates()->getLatitude(), $location->getCoordinates()->getLongitude(), $this->formatName($location)); + , $lat, $lon, $this->formatName($location)); $gpx .= << diff --git a/src/Geocoder/Dumper/Kml.php b/src/Geocoder/Dumper/Kml.php index 0c56123f6..3568d57c7 100644 --- a/src/Geocoder/Dumper/Kml.php +++ b/src/Geocoder/Dumper/Kml.php @@ -38,6 +38,13 @@ public function dump(Location $location) KML; - return sprintf($kml, $name, $name, $location->getCoordinates()->getLongitude(), $location->getCoordinates()->getLatitude()); + $lat = null; + $lon = null; + if (null !== $coordinates = $location->getCoordinates()) { + $lat = $coordinates->getLatitude(); + $lon = $coordinates->getLongitude(); + } + + return sprintf($kml, $name, $name, $lon, $lat); } } diff --git a/src/Geocoder/Dumper/Wkb.php b/src/Geocoder/Dumper/Wkb.php index 42fd7a56e..0317762ff 100644 --- a/src/Geocoder/Dumper/Wkb.php +++ b/src/Geocoder/Dumper/Wkb.php @@ -22,6 +22,13 @@ class Wkb implements Dumper */ public function dump(Location $location) { - return pack('cLdd', 1, 1, $location->getCoordinates()->getLongitude(), $location->getCoordinates()->getLatitude()); + $lat = null; + $lon = null; + if (null !== $coordinates = $location->getCoordinates()) { + $lat = $coordinates->getLatitude(); + $lon = $coordinates->getLongitude(); + } + + return pack('cLdd', 1, 1, $lon, $lat); } } diff --git a/src/Geocoder/Dumper/Wkt.php b/src/Geocoder/Dumper/Wkt.php index 3572a54b8..b58ec70f1 100644 --- a/src/Geocoder/Dumper/Wkt.php +++ b/src/Geocoder/Dumper/Wkt.php @@ -22,6 +22,13 @@ class Wkt implements Dumper */ public function dump(Location $location) { - return sprintf('POINT(%F %F)', $location->getCoordinates()->getLongitude(), $location->getCoordinates()->getLatitude()); + $lat = null; + $lon = null; + if (null !== $coordinates = $location->getCoordinates()) { + $lat = $coordinates->getLatitude(); + $lon = $coordinates->getLongitude(); + } + + return sprintf('POINT(%F %F)', $lon, $lat); } } diff --git a/src/Geocoder/Model/Address.php b/src/Geocoder/Model/Address.php index 94579bb64..d730da9f1 100644 --- a/src/Geocoder/Model/Address.php +++ b/src/Geocoder/Model/Address.php @@ -92,22 +92,22 @@ public function __construct( Country $country = null, $timezone = null ) { - $this->coordinates = $coordinates ?: new Coordinates(); - $this->bounds = $bounds ?: new Bounds(); + $this->coordinates = $coordinates; + $this->bounds = $bounds; $this->streetNumber = $streetNumber; $this->streetName = $streetName; $this->postalCode = $postalCode; $this->locality = $locality; $this->subLocality = $subLocality; $this->adminLevels = $adminLevels ?: new AdminLevelCollection(); - $this->country = $country ?: new Country(); + $this->country = $country; $this->timezone = $timezone; } /** - * Returns an array of coordinates (latitude, longitude). + * Returns the coordinates for this address. * - * @return Coordinates + * @return Coordinates|null */ public function getCoordinates() { @@ -115,9 +115,9 @@ public function getCoordinates() } /** - * Returns the bounds value. + * Returns the bounds. * - * @return Bounds + * @return Bounds|null */ public function getBounds() { @@ -188,7 +188,7 @@ public function getAdminLevels() /** * Returns the country value. * - * @return Country + * @return Country|null */ public function getCountry() { @@ -220,18 +220,39 @@ public function toArray() ]; } + $lat = null; + $lon = null; + if (null !== $coordinates = $this->getCoordinates()) { + $lat = $coordinates->getLatitude(); + $lon = $coordinates->getLongitude(); + } + + $countryName = null; + $countryCode = null; + if (null !== $country = $this->getCountry()) { + $countryName = $country->getName(); + $countryCode = $country->getCode(); + } + + $noBounds = [ + 'south' => null, + 'west' => null, + 'north' => null, + 'east' => null, + ]; + return array( - 'latitude' => $this->getCoordinates()->getLatitude(), - 'longitude' => $this->getCoordinates()->getLongitude(), - 'bounds' => $this->bounds->toArray(), + 'latitude' => $lat, + 'longitude' => $lon, + 'bounds' => null !== $this->bounds ? $this->bounds->toArray() : $noBounds, 'streetNumber' => $this->streetNumber, 'streetName' => $this->streetName, 'postalCode' => $this->postalCode, 'locality' => $this->locality, 'subLocality' => $this->subLocality, 'adminLevels' => $adminLevels, - 'country' => $this->country->getName(), - 'countryCode' => $this->country->getCode(), + 'country' => $countryName, + 'countryCode' => $countryCode, 'timezone' => $this->timezone, ); } diff --git a/src/Geocoder/Model/AddressFactory.php b/src/Geocoder/Model/AddressFactory.php index e8c4560cb..255d402a4 100644 --- a/src/Geocoder/Model/AddressFactory.php +++ b/src/Geocoder/Model/AddressFactory.php @@ -35,12 +35,13 @@ public function createFromArray(array $results) ); } + $addresses[] = new Address( $this->createCoordinates( $this->readDoubleValue($result, 'latitude'), $this->readDoubleValue($result, 'longitude') ), - new Bounds( + $this->createBounds( $this->readDoubleValue($result, 'bounds.south'), $this->readDoubleValue($result, 'bounds.west'), $this->readDoubleValue($result, 'bounds.north'), @@ -116,6 +117,8 @@ private function upperize($str) /** * @param double $latitude * @param double $longitude + * + * @return Coordinates|null */ private function createCoordinates($latitude, $longitude) { @@ -125,4 +128,20 @@ private function createCoordinates($latitude, $longitude) return new Coordinates((double) $latitude, (double) $longitude); } + + /** + * @param double $south + * @param double $west + * @param double $north + * + * @return Bounds|null + */ + private function createBounds($south, $west, $north, $east) + { + if (null === $south || null === $west || null === $north || null === $east) { + return null; + } + + return new Bounds((double) $south, (double) $west, (double) $north, (double) $east); + } } diff --git a/src/Geocoder/Model/Bounds.php b/src/Geocoder/Model/Bounds.php index e496f86a0..55fa5043d 100644 --- a/src/Geocoder/Model/Bounds.php +++ b/src/Geocoder/Model/Bounds.php @@ -10,6 +10,8 @@ namespace Geocoder\Model; +use Geocoder\Assert; + /** * @author William Durand */ @@ -41,8 +43,18 @@ final class Bounds * @param double $north * @param double $east */ - public function __construct($south = null, $west = null, $north = null, $east = null) + public function __construct($south, $west, $north, $east) { + $south = (double) $south; + $north = (double) $north; + $west = (double) $west; + $east = (double) $east; + + Assert::latitude($south); + Assert::latitude($north); + Assert::longitude($west); + Assert::longitude($east); + $this->south = $south; $this->west = $west; $this->north = $north; @@ -89,16 +101,6 @@ public function getEast() return $this->east; } - /** - * Returns whether or not bounds are defined - * - * @return bool - */ - public function isDefined() - { - return !empty($this->south) && !empty($this->east) && !empty($this->north) && !empty($this->west); - } - /** * Returns an array with bounds. * diff --git a/src/Geocoder/Model/Coordinates.php b/src/Geocoder/Model/Coordinates.php index 7255b730e..d0ca08791 100644 --- a/src/Geocoder/Model/Coordinates.php +++ b/src/Geocoder/Model/Coordinates.php @@ -10,6 +10,8 @@ namespace Geocoder\Model; +use Geocoder\Assert; + /** * @author William Durand */ @@ -29,8 +31,14 @@ final class Coordinates * @param double $latitude * @param double $longitude */ - public function __construct($latitude = null, $longitude = null) + public function __construct($latitude, $longitude) { + $latitude = (double) $latitude; + $longitude = (double) $longitude; + + Assert::latitude($latitude); + Assert::longitude($longitude); + $this->latitude = $latitude; $this->longitude = $longitude; } @@ -54,14 +62,4 @@ public function getLongitude() { return $this->longitude; } - - /** - * Returns true if we have coordinates for both longitude and latitude. - * - * @return bool - */ - public function isDefined() - { - return $this->latitude !== null && $this->longitude !== null; - } } diff --git a/src/Geocoder/Model/Country.php b/src/Geocoder/Model/Country.php index a0e2fd262..00ced44b7 100644 --- a/src/Geocoder/Model/Country.php +++ b/src/Geocoder/Model/Country.php @@ -10,6 +10,8 @@ namespace Geocoder\Model; +use Geocoder\Assert; + /** * @author William Durand */ @@ -29,7 +31,7 @@ final class Country * @param string $name * @param string $code */ - public function __construct($name = null, $code = null) + public function __construct($name, $code) { $this->name = $name; $this->code = $code; @@ -64,14 +66,4 @@ public function __toString() { return $this->getName() ?: ''; } - - /** - * Returns true if both name and code is defined. - * - * @return bool - */ - public function isDefined() - { - return !empty($this->code) && !empty($this->name); - } } diff --git a/tests/Geocoder/Tests/Model/AddressFactoryTest.php b/tests/Geocoder/Tests/Model/AddressFactoryTest.php index 72afdd9d3..265121bdc 100644 --- a/tests/Geocoder/Tests/Model/AddressFactoryTest.php +++ b/tests/Geocoder/Tests/Model/AddressFactoryTest.php @@ -37,7 +37,7 @@ public function testCreateFromArray() /** @var $location Location */ $this->assertInstanceOf('Geocoder\Model\Address', $location); $this->assertInstanceOf('Geocoder\Model\Country', $location->getCountry()); - $this->assertFalse($location->getCoordinates()->isDefined()); + $this->assertNull($location->getCoordinates()); foreach ($location->getAdminLevels() as $level => $adminLevel) { $this->assertInstanceOf('Geocoder\Model\AdminLevel', $adminLevel); diff --git a/tests/Geocoder/Tests/Provider/ArcGISOnlineTest.php b/tests/Geocoder/Tests/Provider/ArcGISOnlineTest.php index 919bd62d4..9b93882be 100644 --- a/tests/Geocoder/Tests/Provider/ArcGISOnlineTest.php +++ b/tests/Geocoder/Tests/Provider/ArcGISOnlineTest.php @@ -95,7 +95,7 @@ public function testGeocodeWithRealAddress() $this->assertEquals('Paris', $result->getAdminLevels()->get(2)->getName()); $this->assertEquals('FRA', $result->getCountry()->getCode()); - $this->assertFalse($result->getBounds()->isDefined()); + $this->assertNull($result->getBounds()); $this->assertNull($result->getSubLocality()); $this->assertNull($result->getAdminLevels()->get(2)->getCode()); $this->assertNull($result->getAdminLevels()->get(1)->getCode()); @@ -126,7 +126,7 @@ public function testGeocodeWithRealAddressAndHttps() $this->assertEquals('FRA', $result->getCountry()->getCode()); $this->assertEquals(10, $result->getStreetNumber()); - $this->assertFalse($result->getBounds()->isDefined()); + $this->assertNull($result->getBounds()); $this->assertNull($result->getSubLocality()); $this->assertNull($result->getAdminLevels()->get(2)->getCode()); $this->assertNull($result->getAdminLevels()->get(1)->getCode()); @@ -193,7 +193,7 @@ public function testReverseWithRealCoordinates() $this->assertEquals('Paris', $result->getLocality()); $this->assertEquals('FRA', $result->getCountry()->getCode()); - $this->assertFalse($result->getBounds()->isDefined()); + $this->assertNull($result->getBounds()); $this->assertNull($result->getSubLocality()); $this->assertEmpty($result->getAdminLevels()); $this->assertNull($result->getCountry()->getName()); @@ -219,7 +219,7 @@ public function testReverseWithRealCoordinatesWithHttps() $this->assertEquals('Paris', $result->getLocality()); $this->assertEquals('FRA', $result->getCountry()->getCode()); - $this->assertFalse($result->getBounds()->isDefined()); + $this->assertNull($result->getBounds()); $this->assertNull($result->getSubLocality()); $this->assertEmpty($result->getAdminLevels()); $this->assertNull($result->getCountry()->getName()); @@ -247,7 +247,7 @@ public function testGeocodeWithCity() $this->assertEquals('Niedersachsen', $result->getAdminLevels()->get(1)->getName()); $this->assertEquals('DEU', $result->getCountry()->getCode()); - $this->assertFalse($result->getBounds()->isDefined()); + $this->assertNull($result->getBounds()); $this->assertNull($result->getSubLocality()); $this->assertNull($result->getCountry()->getName()); $this->assertNull($result->getTimezone()); diff --git a/tests/Geocoder/Tests/Provider/BingMapsTest.php b/tests/Geocoder/Tests/Provider/BingMapsTest.php index d7c5f7971..61757e96b 100644 --- a/tests/Geocoder/Tests/Provider/BingMapsTest.php +++ b/tests/Geocoder/Tests/Provider/BingMapsTest.php @@ -100,7 +100,7 @@ public function testGeocodeReturnsMultipleResults() $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(48.86321675999999, $result->getCoordinates()->getLatitude(), '', 0.01); $this->assertEquals(2.3887721299999995, $result->getCoordinates()->getLongitude(), '', 0.01); - $this->assertTrue($result->getBounds()->isDefined()); + $this->assertNotNull($result->getBounds()); $this->assertEquals(48.859354042429, $result->getBounds()->getSouth(), '', 0.01); $this->assertEquals(2.3809438666389, $result->getBounds()->getWest(), '', 0.01); $this->assertEquals(48.867079477571, $result->getBounds()->getNorth(), '', 0.01); @@ -122,7 +122,7 @@ public function testGeocodeReturnsMultipleResults() $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(48.81342781, $result->getCoordinates()->getLatitude(), '', 0.01); $this->assertEquals(2.32503767, $result->getCoordinates()->getLongitude(), '', 0.01); - $this->assertTrue($result->getBounds()->isDefined()); + $this->assertNotNull($result->getBounds()); $this->assertEquals(48.809565092429, $result->getBounds()->getSouth(), '', 0.01); $this->assertEquals(2.3172171827738, $result->getBounds()->getWest(), '', 0.01); $this->assertEquals(48.817290527571, $result->getBounds()->getNorth(), '', 0.01); @@ -142,7 +142,7 @@ public function testGeocodeReturnsMultipleResults() $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(48.81014147, $result->getCoordinates()->getLatitude(), '', 0.01); $this->assertEquals(2.43568048, $result->getCoordinates()->getLongitude(), '', 0.01); - $this->assertTrue($result->getBounds()->isDefined()); + $this->assertNotNull($result->getBounds()); $this->assertEquals(48.806278752429, $result->getBounds()->getSouth(), '', 0.01); $this->assertEquals(2.4278605052897, $result->getBounds()->getWest(), '', 0.01); $this->assertEquals(48.814004187571, $result->getBounds()->getNorth(), '', 0.01); @@ -175,7 +175,7 @@ public function testReverseReturnsSingleResult() $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(48.86321648955345, $result->getCoordinates()->getLatitude(), '', 0.0001); $this->assertEquals(2.3887719959020615, $result->getCoordinates()->getLongitude(), '', 0.0001); - $this->assertTrue($result->getBounds()->isDefined()); + $this->assertNotNull($result->getBounds()); $this->assertEquals(48.859353771983, $result->getBounds()->getSouth(), '', 0.0001); $this->assertEquals(2.3809437325833, $result->getBounds()->getWest(), '', 0.0001); $this->assertEquals(48.867079207124, $result->getBounds()->getNorth(), '', 0.0001); @@ -210,7 +210,7 @@ public function testGeocodeWithRealAddressReturnsSingleResults() $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(48.86321675999999, $result->getCoordinates()->getLatitude(), '', 0.01); $this->assertEquals(2.3887721299999995, $result->getCoordinates()->getLongitude(), '', 0.01); - $this->assertTrue($result->getBounds()->isDefined()); + $this->assertNotNull($result->getBounds()); $this->assertEquals(48.859354042429, $result->getBounds()->getSouth(), '', 0.01); $this->assertEquals(2.3809438666389, $result->getBounds()->getWest(), '', 0.01); $this->assertEquals(48.867079477571, $result->getBounds()->getNorth(), '', 0.01); @@ -248,7 +248,7 @@ public function testGeocodeWithRealAddressReturnsMultipleResults() $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(44.786701202393, $result->getCoordinates()->getLatitude(), '', 0.01); $this->assertEquals(8.2841901779175, $result->getCoordinates()->getLongitude(), '', 0.01); - $this->assertTrue($result->getBounds()->isDefined()); + $this->assertNotNull($result->getBounds()); $this->assertEquals(44.775325775146, $result->getBounds()->getSouth(), '', 0.01); $this->assertEquals(8.2711343765259, $result->getBounds()->getWest(), '', 0.01); $this->assertEquals(44.795879364014, $result->getBounds()->getNorth(), '', 0.01); @@ -268,7 +268,7 @@ public function testGeocodeWithRealAddressReturnsMultipleResults() $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(46.05179977417, $result->getCoordinates()->getLatitude(), '', 0.01); $this->assertEquals(11.497699737549, $result->getCoordinates()->getLongitude(), '', 0.01); - $this->assertTrue($result->getBounds()->isDefined()); + $this->assertNotNull($result->getBounds()); $this->assertEquals(46.029235839844, $result->getBounds()->getSouth(), '', 0.01); $this->assertEquals(11.473880767822, $result->getBounds()->getWest(), '', 0.01); $this->assertEquals(46.07377243042, $result->getBounds()->getNorth(), '', 0.01); @@ -288,7 +288,7 @@ public function testGeocodeWithRealAddressReturnsMultipleResults() $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(44.987880706787, $result->getCoordinates()->getLatitude(), '', 0.01); $this->assertEquals(9.442440032959, $result->getCoordinates()->getLongitude(), '', 0.01); - $this->assertTrue($result->getBounds()->isDefined()); + $this->assertNotNull($result->getBounds()); $this->assertEquals(44.958910323795, $result->getBounds()->getSouth(), '', 0.01); $this->assertEquals(9.3878520826907, $result->getBounds()->getWest(), '', 0.01); $this->assertEquals(45.01685108978, $result->getBounds()->getNorth(), '', 0.01); @@ -308,7 +308,7 @@ public function testGeocodeWithRealAddressReturnsMultipleResults() $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(43.82638168335, $result->getCoordinates()->getLatitude(), '', 0.01); $this->assertEquals(11.068260192871, $result->getCoordinates()->getLongitude(), '', 0.01); - $this->assertTrue($result->getBounds()->isDefined()); + $this->assertNotNull($result->getBounds()); $this->assertEquals(43.797411300357, $result->getBounds()->getSouth(), '', 0.01); $this->assertEquals(11.014744487393, $result->getBounds()->getWest(), '', 0.01); $this->assertEquals(43.855352066342, $result->getBounds()->getNorth(), '', 0.01); @@ -328,7 +328,7 @@ public function testGeocodeWithRealAddressReturnsMultipleResults() $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(42.295810699463, $result->getCoordinates()->getLatitude(), '', 0.01); $this->assertEquals(13.626440048218, $result->getCoordinates()->getLongitude(), '', 0.01); - $this->assertTrue($result->getBounds()->isDefined()); + $this->assertNotNull($result->getBounds()); $this->assertEquals(42.26684031647, $result->getBounds()->getSouth(), '', 0.01); $this->assertEquals(13.574242599134, $result->getBounds()->getWest(), '', 0.01); $this->assertEquals(42.324781082455, $result->getBounds()->getNorth(), '', 0.01); @@ -381,7 +381,7 @@ public function testReverseWithRealCoordinatesReturnsSingleResult() $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(48.86321648955345, $result->getCoordinates()->getLatitude(), '', 0.0001); $this->assertEquals(2.3887719959020615, $result->getCoordinates()->getLongitude(), '', 0.0001); - $this->assertTrue($result->getBounds()->isDefined()); + $this->assertNotNull($result->getBounds()); $this->assertEquals(48.859353771983, $result->getBounds()->getSouth(), '', 0.0001); $this->assertEquals(2.3809437325833, $result->getBounds()->getWest(), '', 0.0001); $this->assertEquals(48.867079207124, $result->getBounds()->getNorth(), '', 0.0001); diff --git a/tests/Geocoder/Tests/Provider/GeoIP2Test.php b/tests/Geocoder/Tests/Provider/GeoIP2Test.php index 623fe8ba6..3474ab72a 100644 --- a/tests/Geocoder/Tests/Provider/GeoIP2Test.php +++ b/tests/Geocoder/Tests/Provider/GeoIP2Test.php @@ -166,9 +166,19 @@ public function testRetrievingGeodata($address, $adapterResponse, $expectedGeoda /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals($expectedGeodata['latitude'], $result->getCoordinates()->getLatitude()); - $this->assertEquals($expectedGeodata['longitude'], $result->getCoordinates()->getLongitude()); - $this->assertEquals($expectedGeodata['boundsDefined'], $result->getBounds()->isDefined()); + if (isset($expectedGeodata['latitude'])) { + $this->assertEquals($expectedGeodata['latitude'], $result->getCoordinates()->getLatitude()); + $this->assertEquals($expectedGeodata['longitude'], $result->getCoordinates()->getLongitude()); + } else { + $this->assertNull($result->getCoordinates()); + } + + if ($expectedGeodata['boundsDefined']) { + $this->assertNotNull($result->getBounds()); + } else { + $this->assertNull($result->getBounds()); + } + $this->assertEquals($expectedGeodata['streetNumber'], $result->getStreetNumber()); $this->assertEquals($expectedGeodata['streetName'], $result->getStreetName()); $this->assertEquals($expectedGeodata['locality'], $result->getLocality()); diff --git a/tests/Geocoder/Tests/Provider/GeoIPsTest.php b/tests/Geocoder/Tests/Provider/GeoIPsTest.php index 48f0b9e19..d79338aa8 100644 --- a/tests/Geocoder/Tests/Provider/GeoIPsTest.php +++ b/tests/Geocoder/Tests/Provider/GeoIPsTest.php @@ -135,8 +135,8 @@ public function testGeocodeWithRealIPv4GetsFakeContentFormattedEmpty() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertNull($result->getCoordinates()->getLatitude()); - $this->assertNull($result->getCoordinates()->getLongitude()); + $this->assertNull($result->getCoordinates()); + $this->assertNull($result->getPostalCode()); $this->assertNull($result->getLocality()); $this->assertEmpty($result->getAdminLevels()); diff --git a/tests/Geocoder/Tests/Provider/GeoipTest.php b/tests/Geocoder/Tests/Provider/GeoipTest.php index 3a1c7e6dd..a42696eed 100644 --- a/tests/Geocoder/Tests/Provider/GeoipTest.php +++ b/tests/Geocoder/Tests/Provider/GeoipTest.php @@ -64,8 +64,8 @@ public function testGeocodeWithLocalhostIPv4() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('Geocoder\Model\Address', $result); - $this->assertNull($result->getCoordinates()->getLatitude()); - $this->assertNull($result->getCoordinates()->getLongitude()); + $this->assertNull($result->getCoordinates()); + $this->assertNull($result->getPostalCode()); $this->assertNull($result->getTimezone()); $this->assertEmpty($result->getAdminLevels()); diff --git a/tests/Geocoder/Tests/Provider/GeonamesTest.php b/tests/Geocoder/Tests/Provider/GeonamesTest.php index bbea50056..a3706ac40 100644 --- a/tests/Geocoder/Tests/Provider/GeonamesTest.php +++ b/tests/Geocoder/Tests/Provider/GeonamesTest.php @@ -97,7 +97,7 @@ public function testGeocodeWithRealPlace() $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(51.508528775863, $result->getCoordinates()->getLatitude(), '', 0.01); $this->assertEquals(-0.12574195861816, $result->getCoordinates()->getLongitude(), '', 0.01); - $this->assertTrue($result->getBounds()->isDefined()); + $this->assertNotNull($result->getBounds()); $this->assertEquals(51.151689398345, $result->getBounds()->getSouth(), '', 0.01); $this->assertEquals(-0.70360885396019, $result->getBounds()->getWest(), '', 0.01); $this->assertEquals(51.865368153381, $result->getBounds()->getNorth(), '', 0.01); @@ -115,7 +115,7 @@ public function testGeocodeWithRealPlace() $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(-33.015285093464, $result->getCoordinates()->getLatitude(), '', 0.01); $this->assertEquals(27.911624908447, $result->getCoordinates()->getLongitude(), '', 0.01); - $this->assertTrue($result->getBounds()->isDefined()); + $this->assertNotNull($result->getBounds()); $this->assertEquals(-33.104996458003, $result->getBounds()->getSouth(), '', 0.01); $this->assertEquals(27.804746435655, $result->getBounds()->getWest(), '', 0.01); $this->assertEquals(-32.925573728925, $result->getBounds()->getNorth(), '', 0.01); @@ -134,7 +134,7 @@ public function testGeocodeWithRealPlace() $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(51.512788890295, $result->getCoordinates()->getLatitude(), '', 0.01); $this->assertEquals(-0.091838836669922, $result->getCoordinates()->getLongitude(), '', 0.01); - $this->assertTrue($result->getBounds()->isDefined()); + $this->assertNotNull($result->getBounds()); $this->assertEquals(51.155949512764, $result->getBounds()->getSouth(), '', 0.01); $this->assertEquals(-0.66976046752962, $result->getBounds()->getWest(), '', 0.01); $this->assertEquals(51.869628267826, $result->getBounds()->getNorth(), '', 0.01); @@ -153,7 +153,7 @@ public function testGeocodeWithRealPlace() $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(42.983389283, $result->getCoordinates()->getLatitude(), '', 0.01); $this->assertEquals(-81.233042387, $result->getCoordinates()->getLongitude(), '', 0.01); - $this->assertTrue($result->getBounds()->isDefined()); + $this->assertNotNull($result->getBounds()); $this->assertEquals(42.907075642763, $result->getBounds()->getSouth(), '', 0.01); $this->assertEquals(-81.337489676463, $result->getBounds()->getWest(), '', 0.01); $this->assertEquals(43.059702923237, $result->getBounds()->getNorth(), '', 0.01); @@ -170,7 +170,7 @@ public function testGeocodeWithRealPlace() $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(41.3556539, $result->getCoordinates()->getLatitude(), '', 0.01); $this->assertEquals(-72.0995209, $result->getCoordinates()->getLongitude(), '', 0.01); - $this->assertTrue($result->getBounds()->isDefined()); + $this->assertNotNull($result->getBounds()); $this->assertEquals(41.334087887904, $result->getBounds()->getSouth(), '', 0.01); $this->assertEquals(-72.128261254846, $result->getBounds()->getWest(), '', 0.01); $this->assertEquals(41.377219912096, $result->getBounds()->getNorth(), '', 0.01); @@ -201,7 +201,7 @@ public function testGeocodeWithRealPlaceWithLocale() $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(51.50853, $result->getCoordinates()->getLatitude(), '', 0.01); $this->assertEquals(-0.12574, $result->getCoordinates()->getLongitude(), '', 0.01); - $this->assertTrue($result->getBounds()->isDefined()); + $this->assertNotNull($result->getBounds()); $this->assertEquals(51.15169, $result->getBounds()->getSouth(), '', 0.01); $this->assertEquals(-0.70361, $result->getBounds()->getWest(), '', 0.01); $this->assertEquals(51.86537, $result->getBounds()->getNorth(), '', 0.01); @@ -219,7 +219,7 @@ public function testGeocodeWithRealPlaceWithLocale() $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(-33.015285093464, $result->getCoordinates()->getLatitude(), '', 0.01); $this->assertEquals(27.911624908447, $result->getCoordinates()->getLongitude(), '', 0.01); - $this->assertTrue($result->getBounds()->isDefined()); + $this->assertNotNull($result->getBounds()); $this->assertEquals(-33.104996458003, $result->getBounds()->getSouth(), '', 0.01); $this->assertEquals(27.804746435655, $result->getBounds()->getWest(), '', 0.01); $this->assertEquals(-32.925573728925, $result->getBounds()->getNorth(), '', 0.01); @@ -238,7 +238,7 @@ public function testGeocodeWithRealPlaceWithLocale() $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(51.512788890295, $result->getCoordinates()->getLatitude(), '', 0.01); $this->assertEquals(-0.091838836669922, $result->getCoordinates()->getLongitude(), '', 0.01); - $this->assertTrue($result->getBounds()->isDefined()); + $this->assertNotNull($result->getBounds()); $this->assertEquals(51.155949512764, $result->getBounds()->getSouth(), '', 0.01); $this->assertEquals(-0.66976046752962, $result->getBounds()->getWest(), '', 0.01); $this->assertEquals(51.869628267826, $result->getBounds()->getNorth(), '', 0.01); @@ -257,7 +257,7 @@ public function testGeocodeWithRealPlaceWithLocale() $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(42.983389283, $result->getCoordinates()->getLatitude(), '', 0.01); $this->assertEquals(-81.233042387, $result->getCoordinates()->getLongitude(), '', 0.01); - $this->assertTrue($result->getBounds()->isDefined()); + $this->assertNotNull($result->getBounds()); $this->assertEquals(42.907075642763, $result->getBounds()->getSouth(), '', 0.01); $this->assertEquals(-81.337489676463, $result->getBounds()->getWest(), '', 0.01); $this->assertEquals(43.059702923237, $result->getBounds()->getNorth(), '', 0.01); @@ -274,7 +274,7 @@ public function testGeocodeWithRealPlaceWithLocale() $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(41.3556539, $result->getCoordinates()->getLatitude(), '', 0.01); $this->assertEquals(-72.0995209, $result->getCoordinates()->getLongitude(), '', 0.01); - $this->assertTrue($result->getBounds()->isDefined()); + $this->assertNotNull($result->getBounds()); $this->assertEquals(41.334087887904, $result->getBounds()->getSouth(), '', 0.01); $this->assertEquals(-72.128261254846, $result->getBounds()->getWest(), '', 0.01); $this->assertEquals(41.377219912096, $result->getBounds()->getNorth(), '', 0.01); diff --git a/tests/Geocoder/Tests/Provider/GoogleMapsTest.php b/tests/Geocoder/Tests/Provider/GoogleMapsTest.php index 21c96ba71..0500644b1 100644 --- a/tests/Geocoder/Tests/Provider/GoogleMapsTest.php +++ b/tests/Geocoder/Tests/Provider/GoogleMapsTest.php @@ -125,7 +125,7 @@ public function testGeocodeWithRealAddress() $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(48.8630462, $result->getCoordinates()->getLatitude(), '', 0.001); $this->assertEquals(2.3882487, $result->getCoordinates()->getLongitude(), '', 0.001); - $this->assertTrue($result->getBounds()->isDefined()); + $this->assertNotNull($result->getBounds()); $this->assertEquals(48.8630462, $result->getBounds()->getSouth(), '', 0.001); $this->assertEquals(2.3882487, $result->getBounds()->getWest(), '', 0.001); $this->assertEquals(48.8630462, $result->getBounds()->getNorth(), '', 0.001); @@ -156,7 +156,7 @@ public function testGeocodeWithRealAddressWithSsl() $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(48.8630462, $result->getCoordinates()->getLatitude(), '', 0.001); $this->assertEquals(2.3882487, $result->getCoordinates()->getLongitude(), '', 0.001); - $this->assertTrue($result->getBounds()->isDefined()); + $this->assertNotNull($result->getBounds()); $this->assertEquals(48.8630462, $result->getBounds()->getSouth(), '', 0.001); $this->assertEquals(2.3882487, $result->getBounds()->getWest(), '', 0.001); $this->assertEquals(48.8630462, $result->getBounds()->getNorth(), '', 0.001); @@ -186,7 +186,7 @@ public function testGeocodeBoundsWithRealAddressForNonRooftopLocation() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertTrue($result->getBounds()->isDefined()); + $this->assertNotNull($result->getBounds()); $this->assertEquals(48.815573, $result->getBounds()->getSouth(), '', 0.0001); $this->assertEquals(2.224199, $result->getBounds()->getWest(), '', 0.0001); $this->assertEquals(48.902145, $result->getBounds()->getNorth(), '', 0.0001); @@ -331,7 +331,7 @@ public function testGeocodeWithRealValidApiKey() $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertNotNull($result->getCoordinates()->getLatitude()); $this->assertNotNull($result->getCoordinates()->getLongitude()); - $this->assertTrue($result->getBounds()->isDefined()); + $this->assertNotNull($result->getBounds()); $this->assertEquals('New York', $result->getLocality()); $this->assertEquals('Manhattan', $result->getSubLocality()); $this->assertCount(2, $result->getAdminLevels()); diff --git a/tests/Geocoder/Tests/Provider/HostIpTest.php b/tests/Geocoder/Tests/Provider/HostIpTest.php index 8f7c26dab..b4ea57521 100644 --- a/tests/Geocoder/Tests/Provider/HostIpTest.php +++ b/tests/Geocoder/Tests/Provider/HostIpTest.php @@ -55,8 +55,8 @@ public function testGeocodeWithLocalhostIPv4() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertNull($result->getCoordinates()->getLatitude()); - $this->assertNull($result->getCoordinates()->getLongitude()); + $this->assertNull($result->getCoordinates()); + $this->assertNull($result->getPostalCode()); $this->assertNull($result->getTimezone()); $this->assertEmpty($result->getAdminLevels()); @@ -146,7 +146,7 @@ public function testGeocodeWithAnotherIp() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertNull($result->getCoordinates()->getLatitude()); - $this->assertNull($result->getCoordinates()->getLongitude()); + $this->assertNull($result->getCoordinates()); + } } diff --git a/tests/Geocoder/Tests/Provider/IpInfoDbTest.php b/tests/Geocoder/Tests/Provider/IpInfoDbTest.php index aa2deac26..a15418f42 100644 --- a/tests/Geocoder/Tests/Provider/IpInfoDbTest.php +++ b/tests/Geocoder/Tests/Provider/IpInfoDbTest.php @@ -83,8 +83,8 @@ public function testGeocodeWithLocalhostIPv4() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertNull($result->getCoordinates()->getLatitude()); - $this->assertNull($result->getCoordinates()->getLongitude()); + $this->assertNull($result->getCoordinates()); + $this->assertNull($result->getPostalCode()); $this->assertNull($result->getTimezone()); $this->assertEmpty($result->getAdminLevels()); @@ -181,8 +181,8 @@ public function testGetGeocodedDataWithCountryPrecision() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertNull($result->getCoordinates()->getLatitude()); - $this->assertNull($result->getCoordinates()->getLongitude()); + $this->assertNull($result->getCoordinates()); + $this->assertNull($result->getPostalCode()); $this->assertNull($result->getLocality()); $this->assertEmpty($result->getAdminLevels()); diff --git a/tests/Geocoder/Tests/Provider/MapQuestTest.php b/tests/Geocoder/Tests/Provider/MapQuestTest.php index 6f687f593..d65f5c6f8 100644 --- a/tests/Geocoder/Tests/Provider/MapQuestTest.php +++ b/tests/Geocoder/Tests/Provider/MapQuestTest.php @@ -75,7 +75,7 @@ public function testGeocodeWithRealAddress() $this->assertEquals('FR', $result->getCountry()->getName()); $this->assertEquals('FR', $result->getCountry()->getCode()); - $this->assertFalse($result->getBounds()->isDefined()); + $this->assertNull($result->getBounds()); $this->assertNull($result->getStreetNumber()); $this->assertNull($result->getAdminLevels()->get(1)->getCode()); $this->assertNull($result->getTimezone()); @@ -120,7 +120,7 @@ public function testReverseWithRealCoordinates() $this->assertEquals('GB', $result->getCountry()->getName()); $this->assertEquals('GB', $result->getCountry()->getCode()); - $this->assertFalse($result->getBounds()->isDefined()); + $this->assertNull($result->getBounds()); $this->assertNull($result->getStreetNumber()); $this->assertNull($result->getAdminLevels()->get(1)->getCode()); $this->assertNull($result->getTimezone()); @@ -212,7 +212,7 @@ public function testGeocodeWithCityDistrict() $this->assertEquals('DE', $result->getCountry()->getName()); $this->assertEquals('DE', $result->getCountry()->getCode()); - $this->assertFalse($result->getBounds()->isDefined()); + $this->assertNull($result->getBounds()); $this->assertNull($result->getStreetNumber()); $this->assertNull($result->getAdminLevels()->get(1)->getCode()); $this->assertNull($result->getTimezone()); diff --git a/tests/Geocoder/Tests/Provider/MaxMindBinaryTest.php b/tests/Geocoder/Tests/Provider/MaxMindBinaryTest.php index c73b98fd8..c690371ed 100644 --- a/tests/Geocoder/Tests/Provider/MaxMindBinaryTest.php +++ b/tests/Geocoder/Tests/Provider/MaxMindBinaryTest.php @@ -56,7 +56,7 @@ public function testLocationResultContainsExpectedFieldsForAnAmericanIp() $this->assertEquals('43.089200000000005', $result->getCoordinates()->getLatitude(), '', 0.001); $this->assertEquals('-76.025000000000006', $result->getCoordinates()->getLongitude(), '', 0.001); - $this->assertFalse($result->getBounds()->isDefined()); + $this->assertNull($result->getBounds()); $this->assertNull($result->getStreetNumber()); $this->assertNull($result->getStreetName()); $this->assertNull($result->getPostalCode()); @@ -84,7 +84,7 @@ public function testLocationResultContainsExpectedFieldsForASpanishIp() $this->assertEquals('41.543299999999988', $result->getCoordinates()->getLatitude(), '', 0.001); $this->assertEquals('2.1093999999999937', $result->getCoordinates()->getLongitude(), '', 0.001); - $this->assertFalse($result->getBounds()->isDefined()); + $this->assertNull($result->getBounds()); $this->assertNull($result->getStreetNumber()); $this->assertNull($result->getStreetName()); $this->assertNull($result->getPostalCode()); diff --git a/tests/Geocoder/Tests/Provider/MaxMindTest.php b/tests/Geocoder/Tests/Provider/MaxMindTest.php index 5590e1af7..b100128ad 100644 --- a/tests/Geocoder/Tests/Provider/MaxMindTest.php +++ b/tests/Geocoder/Tests/Provider/MaxMindTest.php @@ -134,8 +134,8 @@ public function testGeocodeWithRealIPv4GetsFakeContentFormattedEmpty() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertNull($result->getCoordinates()->getLatitude()); - $this->assertNull($result->getCoordinates()->getLongitude()); + $this->assertNull($result->getCoordinates()); + $this->assertNull($result->getStreetNumber()); $this->assertNull($result->getStreetName()); $this->assertNull($result->getPostalCode()); @@ -306,7 +306,7 @@ public function testGeocodeServiceWithRealIPv4() $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(33.034698, $result->getCoordinates()->getLatitude(), '', 0.1); $this->assertEquals(-96.813400, $result->getCoordinates()->getLongitude(), '', 0.1); - $this->assertFalse($result->getBounds()->isDefined()); + $this->assertNull($result->getBounds()); $this->assertNull($result->getStreetNumber()); $this->assertNull($result->getStreetName()); $this->assertEquals(75093, $result->getPostalCode()); @@ -338,7 +338,7 @@ public function testGeocodeOmniServiceWithRealIPv4() $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(33.0347, $result->getCoordinates()->getLatitude(), '', 0.1); $this->assertEquals(-96.8134, $result->getCoordinates()->getLongitude(), '', 0.1); - $this->assertFalse($result->getBounds()->isDefined()); + $this->assertNull($result->getBounds()); $this->assertNull($result->getStreetNumber()); $this->assertNull($result->getStreetName()); $this->assertEquals(75093, $result->getPostalCode()); @@ -370,7 +370,7 @@ public function testGeocodeOmniServiceWithRealIPv4WithSslAndEncoding() $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(-27.5833, $result->getCoordinates()->getLatitude(), '', 0.1); $this->assertEquals(-48.5666, $result->getCoordinates()->getLongitude(), '', 0.1); - $this->assertFalse($result->getBounds()->isDefined()); + $this->assertNull($result->getBounds()); $this->assertNull($result->getStreetNumber()); $this->assertNull($result->getStreetName()); $this->assertNull($result->getPostalCode()); @@ -401,7 +401,7 @@ public function testGeocodeWithRealIPv6() $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(40.2181, $result->getCoordinates()->getLatitude(), '', 0.1); $this->assertEquals(-111.6133, $result->getCoordinates()->getLongitude(), '', 0.1); - $this->assertFalse($result->getBounds()->isDefined()); + $this->assertNull($result->getBounds()); $this->assertNull($result->getStreetNumber()); $this->assertNull($result->getStreetName()); $this->assertEquals(84606, $result->getPostalCode()); @@ -433,7 +433,7 @@ public function testGeocodeOmniServiceWithRealIPv6WithSsl() $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(40.2181, $result->getCoordinates()->getLatitude(), '', 0.1); $this->assertEquals(-111.6133, $result->getCoordinates()->getLongitude(), '', 0.1); - $this->assertFalse($result->getBounds()->isDefined()); + $this->assertNull($result->getBounds()); $this->assertNull($result->getStreetNumber()); $this->assertNull($result->getStreetName()); $this->assertEquals(84606, $result->getPostalCode()); diff --git a/tests/Geocoder/Tests/Provider/NominatimTest.php b/tests/Geocoder/Tests/Provider/NominatimTest.php index 26888f5f5..5d2430696 100644 --- a/tests/Geocoder/Tests/Provider/NominatimTest.php +++ b/tests/Geocoder/Tests/Provider/NominatimTest.php @@ -21,7 +21,7 @@ public function testGeocodeWithRealAddress() $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(48.8565056, $result->getCoordinates()->getLatitude(), '', 0.01); $this->assertEquals(2.3521334, $result->getCoordinates()->getLongitude(), '', 0.01); - $this->assertTrue($result->getBounds()->isDefined()); + $this->assertNotNull($result->getBounds()); $this->assertEquals(48.8155250549316, $result->getBounds()->getSouth(), '', 0.01); $this->assertEquals(2.22412180900574, $result->getBounds()->getWest(), '', 0.01); $this->assertEquals(48.902156829834, $result->getBounds()->getNorth(), '', 0.01); @@ -43,7 +43,7 @@ public function testGeocodeWithRealAddress() $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(48.8588408, $result->getCoordinates()->getLatitude(), '', 0.01); $this->assertEquals(2.32003465529896, $result->getCoordinates()->getLongitude(), '', 0.01); - $this->assertTrue($result->getBounds()->isDefined()); + $this->assertNotNull($result->getBounds()); $this->assertEquals(48.8155250549316, $result->getBounds()->getSouth(), '', 0.01); $this->assertEquals(2.22412180900574, $result->getBounds()->getWest(), '', 0.01); $this->assertEquals(48.902156829834, $result->getBounds()->getNorth(), '', 0.01); @@ -65,7 +65,7 @@ public function testGeocodeWithRealAddress() $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(35.28687645, $result->getCoordinates()->getLatitude(), '', 0.01); $this->assertEquals(-93.7354879210082, $result->getCoordinates()->getLongitude(), '', 0.01); - $this->assertTrue($result->getBounds()->isDefined()); + $this->assertNotNull($result->getBounds()); $this->assertEquals(35.2672462463379, $result->getBounds()->getSouth(), '', 0.01); $this->assertEquals(-93.7618103027344, $result->getBounds()->getWest(), '', 0.01); $this->assertEquals(35.3065032958984, $result->getBounds()->getNorth(), '', 0.01); @@ -87,7 +87,7 @@ public function testGeocodeWithRealAddress() $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(33.6751155, $result->getCoordinates()->getLatitude(), '', 0.01); $this->assertEquals(-95.5502662477703, $result->getCoordinates()->getLongitude(), '', 0.01); - $this->assertTrue($result->getBounds()->isDefined()); + $this->assertNotNull($result->getBounds()); $this->assertEquals(33.6118507385254, $result->getBounds()->getSouth(), '', 0.01); $this->assertEquals(-95.6279296875, $result->getBounds()->getWest(), '', 0.01); $this->assertEquals(33.7383804321289, $result->getBounds()->getNorth(), '', 0.01); @@ -109,7 +109,7 @@ public function testGeocodeWithRealAddress() $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(38.2097987, $result->getCoordinates()->getLatitude(), '', 0.01); $this->assertEquals(-84.2529869, $result->getCoordinates()->getLongitude(), '', 0.01); - $this->assertTrue($result->getBounds()->isDefined()); + $this->assertNotNull($result->getBounds()); $this->assertEquals(38.1649208068848, $result->getBounds()->getSouth(), '', 0.01); $this->assertEquals(-84.3073272705078, $result->getBounds()->getWest(), '', 0.01); $this->assertEquals(38.2382736206055, $result->getBounds()->getNorth(), '', 0.01); @@ -140,7 +140,7 @@ public function testGeocodeWithRealAddressWithLocale() $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(45.7586841, $result->getCoordinates()->getLatitude(), '', 0.01); $this->assertEquals(3.1354075, $result->getCoordinates()->getLongitude(), '', 0.01); - $this->assertTrue($result->getBounds()->isDefined()); + $this->assertNotNull($result->getBounds()); $this->assertEquals(45.7576484680176, $result->getBounds()->getSouth(), '', 0.01); $this->assertEquals(3.13258004188538, $result->getBounds()->getWest(), '', 0.01); $this->assertEquals(45.7595367431641, $result->getBounds()->getNorth(), '', 0.01); @@ -162,7 +162,7 @@ public function testGeocodeWithRealAddressWithLocale() $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(45.7586841, $result->getCoordinates()->getLatitude(), '', 0.01); $this->assertEquals(3.1354075, $result->getCoordinates()->getLongitude(), '', 0.01); - $this->assertTrue($result->getBounds()->isDefined()); + $this->assertNotNull($result->getBounds()); $this->assertEquals(45.7576484680176, $result->getBounds()->getSouth(), '', 0.01); $this->assertEquals(3.13258004188538, $result->getBounds()->getWest(), '', 0.01); $this->assertEquals(45.7595367431641, $result->getBounds()->getNorth(), '', 0.01); @@ -193,7 +193,7 @@ public function testReverseWithRealCoordinates() $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(60.4539, $result->getCoordinates()->getLatitude(), '', 0.001); $this->assertEquals(22.2568, $result->getCoordinates()->getLongitude(), '', 0.001); - $this->assertFalse($result->getBounds()->isDefined()); + $this->assertNull($result->getBounds()); $this->assertEquals(35, $result->getStreetNumber()); $this->assertEquals('Läntinen Pitkäkatu', $result->getStreetName()); $this->assertEquals(20100, $result->getPostalCode()); @@ -230,7 +230,7 @@ public function testReverseWithRealCoordinatesWithLocale() $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(50.1856803, $result->getCoordinates()->getLatitude(), '', 0.01); $this->assertEquals(8.6506285, $result->getCoordinates()->getLongitude(), '', 0.01); - $this->assertTrue($result->getBounds()->isDefined()); + $this->assertNotNull($result->getBounds()); $this->assertEquals(50.1851196289062, $result->getBounds()->getSouth(), '', 0.01); $this->assertEquals(8.64984607696533, $result->getBounds()->getWest(), '', 0.01); $this->assertEquals(50.1860122680664, $result->getBounds()->getNorth(), '', 0.01); @@ -251,7 +251,7 @@ public function testReverseWithRealCoordinatesWithLocale() $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(50.1845911, $result->getCoordinates()->getLatitude(), '', 0.01); $this->assertEquals(8.6540194, $result->getCoordinates()->getLongitude(), '', 0.01); - $this->assertTrue($result->getBounds()->isDefined()); + $this->assertNotNull($result->getBounds()); $this->assertEquals(50.1840019226074, $result->getBounds()->getSouth(), '', 0.01); $this->assertEquals(8.65207481384277, $result->getBounds()->getWest(), '', 0.01); $this->assertEquals(50.1851234436035, $result->getBounds()->getNorth(), '', 0.01); @@ -272,7 +272,7 @@ public function testReverseWithRealCoordinatesWithLocale() $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(50.1862884, $result->getCoordinates()->getLatitude(), '', 0.01); $this->assertEquals(8.6493167, $result->getCoordinates()->getLongitude(), '', 0.01); - $this->assertTrue($result->getBounds()->isDefined()); + $this->assertNotNull($result->getBounds()); $this->assertEquals(50.1862106323242, $result->getBounds()->getSouth(), '', 0.01); $this->assertEquals(8.64931583404541, $result->getBounds()->getWest(), '', 0.01); $this->assertEquals(50.1862907409668, $result->getBounds()->getNorth(), '', 0.01); @@ -293,7 +293,7 @@ public function testReverseWithRealCoordinatesWithLocale() $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(50.1861344, $result->getCoordinates()->getLatitude(), '', 0.01); $this->assertEquals(8.649578, $result->getCoordinates()->getLongitude(), '', 0.01); - $this->assertTrue($result->getBounds()->isDefined()); + $this->assertNotNull($result->getBounds()); $this->assertEquals(50.1860084533691, $result->getBounds()->getSouth(), '', 0.01); $this->assertEquals(8.64943885803223, $result->getBounds()->getWest(), '', 0.01); $this->assertEquals(50.1862144470215, $result->getBounds()->getNorth(), '', 0.01); @@ -349,7 +349,7 @@ public function testGeocodeWithRealIPv4() $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(43.6189768, $result->getCoordinates()->getLatitude(), '', 0.01); $this->assertEquals(1.4564493, $result->getCoordinates()->getLongitude(), '', 0.01); - $this->assertTrue($result->getBounds()->isDefined()); + $this->assertNotNull($result->getBounds()); $this->assertEquals(43.6159553527832, $result->getBounds()->getSouth(), '', 0.01); $this->assertEquals(1.45302963256836, $result->getBounds()->getWest(), '', 0.01); $this->assertEquals(43.623119354248, $result->getBounds()->getNorth(), '', 0.01); @@ -380,7 +380,7 @@ public function testGeocodeWithRealIPv4WithLocale() $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(43.6155351, $result->getCoordinates()->getLatitude(), '', 0.01); $this->assertEquals(1.4525647, $result->getCoordinates()->getLongitude(), '', 0.01); - $this->assertTrue($result->getBounds()->isDefined()); + $this->assertNotNull($result->getBounds()); $this->assertEquals(43.6154556274414, $result->getBounds()->getSouth(), '', 0.01); $this->assertEquals(1.4524964094162, $result->getBounds()->getWest(), '', 0.01); $this->assertEquals(43.6156005859375, $result->getBounds()->getNorth(), '', 0.01); diff --git a/tests/Geocoder/Tests/Provider/OpenCageTest.php b/tests/Geocoder/Tests/Provider/OpenCageTest.php index 3987006f3..cd895df56 100644 --- a/tests/Geocoder/Tests/Provider/OpenCageTest.php +++ b/tests/Geocoder/Tests/Provider/OpenCageTest.php @@ -64,7 +64,7 @@ public function testGeocodeWithRealAddress() $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(48.866205, $result->getCoordinates()->getLatitude(), '', 0.01); $this->assertEquals(2.389089, $result->getCoordinates()->getLongitude(), '', 0.01); - $this->assertTrue($result->getBounds()->isDefined()); + $this->assertNotNull($result->getBounds()); $this->assertEquals(48.863142699999997, $result->getBounds()->getSouth()); $this->assertEquals(2.3890394000000001, $result->getBounds()->getWest()); $this->assertEquals(48.863242700000001, $result->getBounds()->getNorth()); @@ -111,7 +111,7 @@ public function testReverseWithRealCoordinates() $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(54.0484068, $result->getCoordinates()->getLatitude(), '', 0.001); $this->assertEquals(-2.7990345, $result->getCoordinates()->getLongitude(), '', 0.001); - $this->assertTrue($result->getBounds()->isDefined()); + $this->assertNotNull($result->getBounds()); $this->assertEquals(54.048273100000003, $result->getBounds()->getSouth()); $this->assertEquals(-2.7998815000000001, $result->getBounds()->getWest()); $this->assertEquals(54.0494992, $result->getBounds()->getNorth()); diff --git a/tests/Geocoder/Tests/Provider/TomTomTest.php b/tests/Geocoder/Tests/Provider/TomTomTest.php index ee233fe25..36462b7a2 100644 --- a/tests/Geocoder/Tests/Provider/TomTomTest.php +++ b/tests/Geocoder/Tests/Provider/TomTomTest.php @@ -96,7 +96,7 @@ public function testGeocodeWithRealAddress() $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(55.704389, $result->getCoordinates()->getLatitude(), '', 0.0001); $this->assertEquals(12.546129, $result->getCoordinates()->getLongitude(), '', 0.0001); - $this->assertFalse($result->getBounds()->isDefined()); + $this->assertNull($result->getBounds()); $this->assertNull($result->getStreetNumber()); $this->assertEquals('Tagensvej', $result->getStreetName()); $this->assertNull($result->getPostalCode()); @@ -125,7 +125,7 @@ public function testGeocodeWithRealAddressWithFrenchLocale() $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(55.704389, $result->getCoordinates()->getLatitude(), '', 0.0001); $this->assertEquals(12.546129, $result->getCoordinates()->getLongitude(), '', 0.0001); - $this->assertFalse($result->getBounds()->isDefined()); + $this->assertNull($result->getBounds()); $this->assertNull($result->getStreetNumber()); $this->assertEquals('Tagensvej', $result->getStreetName()); $this->assertNull($result->getPostalCode()); @@ -154,7 +154,7 @@ public function testGeocodeWithRealAddressWithSwedishLocale() $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(55.704389, $result->getCoordinates()->getLatitude(), '', 0.0001); $this->assertEquals(12.546129, $result->getCoordinates()->getLongitude(), '', 0.0001); - $this->assertFalse($result->getBounds()->isDefined()); + $this->assertNull($result->getBounds()); $this->assertNull($result->getStreetNumber()); $this->assertEquals('Tagensvej', $result->getStreetName()); $this->assertNull($result->getPostalCode()); @@ -183,7 +183,7 @@ public function testGeocodeWithRealAddressReturnsMultipleResults() $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(48.856898, $result->getCoordinates()->getLatitude(), '', 0.0001); $this->assertEquals(2.350844, $result->getCoordinates()->getLongitude(), '', 0.0001); - $this->assertFalse($result->getBounds()->isDefined()); + $this->assertNull($result->getBounds()); $this->assertNull($result->getStreetNumber()); $this->assertNull($result->getStreetName()); $this->assertNull($result->getPostalCode()); @@ -366,7 +366,7 @@ public function testReverseWithRealCoordinates() $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(48.86323, $result->getCoordinates()->getLatitude(), '', 0.001); $this->assertEquals(2.38877, $result->getCoordinates()->getLongitude(), '', 0.001); - $this->assertFalse($result->getBounds()->isDefined()); + $this->assertNull($result->getBounds()); $this->assertNull($result->getStreetNumber()); $this->assertEquals('Avenue Gambetta', $result->getStreetName()); $this->assertNull($result->getPostalCode()); @@ -395,7 +395,7 @@ public function testGeocodeWithRealCoordinates() $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(56.52435, $result->getCoordinates()->getLatitude(), '', 0.001); $this->assertEquals(10.06744, $result->getCoordinates()->getLongitude(), '', 0.001); - $this->assertFalse($result->getBounds()->isDefined()); + $this->assertNull($result->getBounds()); $this->assertNull($result->getStreetNumber()); $this->assertEquals('Stabelsvej', $result->getStreetName()); $this->assertNull($result->getPostalCode()); diff --git a/tests/Geocoder/Tests/Provider/YandexTest.php b/tests/Geocoder/Tests/Provider/YandexTest.php index 0ef07e19b..138b06393 100644 --- a/tests/Geocoder/Tests/Provider/YandexTest.php +++ b/tests/Geocoder/Tests/Provider/YandexTest.php @@ -100,7 +100,7 @@ public function testGeocodeWithRealAddress() $this->assertInstanceOf('Geocoder\Model\Address', $result); $this->assertEquals(48.863277, $result->getCoordinates()->getLatitude(), '', 0.01); $this->assertEquals(2.389016, $result->getCoordinates()->getLongitude(), '', 0.01); - $this->assertTrue($result->getBounds()->isDefined()); + $this->assertNotNull($result->getBounds()); $this->assertEquals(48.861926, $result->getBounds()->getSouth(), '', 0.01); $this->assertEquals(2.386967, $result->getBounds()->getWest(), '', 0.01); $this->assertEquals(48.864629, $result->getBounds()->getNorth(), '', 0.01); @@ -135,7 +135,7 @@ public function testGeocodeWithRealAddressWithUALocale() $this->assertInstanceOf('Geocoder\Model\Address', $result); $this->assertEquals(55.675676, $result->getCoordinates()->getLatitude(), '', 0.01); $this->assertEquals(12.567593, $result->getCoordinates()->getLongitude(), '', 0.01); - $this->assertTrue($result->getBounds()->isDefined()); + $this->assertNotNull($result->getBounds()); $this->assertEquals(55.614999, $result->getBounds()->getSouth(), '', 0.01); $this->assertEquals(12.45295, $result->getBounds()->getWest(), '', 0.01); $this->assertEquals(55.73259, $result->getBounds()->getNorth(), '', 0.01); @@ -192,7 +192,7 @@ public function testGeocodeWithRealAddressWithUSLocale() $this->assertInstanceOf('Geocoder\Model\Address', $result); $this->assertEquals(38.897695, $result->getCoordinates()->getLatitude(), '', 0.01); $this->assertEquals(-77.038692, $result->getCoordinates()->getLongitude(), '', 0.01); - $this->assertTrue($result->getBounds()->isDefined()); + $this->assertNotNull($result->getBounds()); $this->assertEquals(38.891265, $result->getBounds()->getSouth(), '', 0.01); $this->assertEquals(-77.046921, $result->getBounds()->getWest(), '', 0.01); $this->assertEquals(38.904125, $result->getBounds()->getNorth(), '', 0.01); @@ -226,7 +226,7 @@ public function testGeocodeWithRealAddressWithBYLocale() $this->assertInstanceOf('Geocoder\Model\Address', $result); $this->assertEquals(53.898077, $result->getCoordinates()->getLatitude(), '', 0.01); $this->assertEquals(27.563673, $result->getCoordinates()->getLongitude(), '', 0.01); - $this->assertTrue($result->getBounds()->isDefined()); + $this->assertNotNull($result->getBounds()); $this->assertEquals(53.896867, $result->getBounds()->getSouth(), '', 0.01); $this->assertEquals(27.561624, $result->getBounds()->getWest(), '', 0.01); $this->assertEquals(53.899286, $result->getBounds()->getNorth(), '', 0.01); @@ -288,7 +288,7 @@ public function testReverseWithRealCoordinates() $this->assertInstanceOf('Geocoder\Model\Address', $result); $this->assertEquals(48.863212, $result->getCoordinates()->getLatitude(), '', 0.01); $this->assertEquals(2.388773, $result->getCoordinates()->getLongitude(), '', 0.01); - $this->assertTrue($result->getBounds()->isDefined()); + $this->assertNotNull($result->getBounds()); $this->assertEquals(48.86294, $result->getBounds()->getSouth(), '', 0.01); $this->assertEquals(2.387497, $result->getBounds()->getWest(), '', 0.01); $this->assertEquals(48.877038, $result->getBounds()->getNorth(), '', 0.01); @@ -335,7 +335,7 @@ public function testReverseWithRealCoordinatesWithUSLocaleAndStreeToponym() $this->assertInstanceOf('Geocoder\Model\Address', $result); $this->assertEquals(48.87132, $result->getCoordinates()->getLatitude(), '', 0.01); $this->assertEquals(2.404017, $result->getCoordinates()->getLongitude(), '', 0.01); - $this->assertTrue($result->getBounds()->isDefined()); + $this->assertNotNull($result->getBounds()); $this->assertEquals(48.86294, $result->getBounds()->getSouth(), '', 0.01); $this->assertEquals(2.387497, $result->getBounds()->getWest(), '', 0.01); $this->assertEquals(48.877038, $result->getBounds()->getNorth(), '', 0.01); @@ -394,7 +394,7 @@ public function testReverseWithRealCoordinatesWithUALocaleAndHouseToponym() $this->assertInstanceOf('Geocoder\Model\Address', $result); $this->assertEquals(60.454462, $result->getCoordinates()->getLatitude(), '', 0.01); $this->assertEquals(22.256561, $result->getCoordinates()->getLongitude(), '', 0.01); - $this->assertTrue($result->getBounds()->isDefined()); + $this->assertNotNull($result->getBounds()); $this->assertEquals(60.45345, $result->getBounds()->getSouth(), '', 0.01); $this->assertEquals(22.254513, $result->getBounds()->getWest(), '', 0.01); $this->assertEquals(60.455474, $result->getBounds()->getNorth(), '', 0.01); @@ -429,7 +429,7 @@ public function testReverseWithRealCoordinatesWithTRLocaleAndLocalityToponym() $this->assertInstanceOf('Geocoder\Model\Address', $result); $this->assertEquals(40.874651, $result->getCoordinates()->getLatitude(), '', 0.01); $this->assertEquals(29.129562, $result->getCoordinates()->getLongitude(), '', 0.01); - $this->assertTrue($result->getBounds()->isDefined()); + $this->assertNotNull($result->getBounds()); $this->assertEquals(40.860413, $result->getBounds()->getSouth(), '', 0.01); $this->assertEquals(29.107230, $result->getBounds()->getWest(), '', 0.01); $this->assertEquals(40.876111, $result->getBounds()->getNorth(), '', 0.01); From 431e08100ea075137e2c65fa3fb099f8540897d2 Mon Sep 17 00:00:00 2001 From: Tobias Nyholm Date: Mon, 7 Nov 2016 21:45:50 +0100 Subject: [PATCH 21/21] Updated changelog with removed isDefined functions --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8c1c18a56..9c8724504 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,8 +5,6 @@ CHANGELOG * Added: Interface for `Geocoder\Model\AddressCollection` called `Geocoder\Collection`. Public APIs are updated to type hint for `Geocoder\GeocoderResult`. * Added: Interface for `Geocoder\Model\Address` called `Geocoder\Location`. Public APIs are updated to type hint for `Geocoder\Location`. -* Added: `Country::isDefined` -* Added: `Cordinates::isDefined` * Changed: `Location::getCoordinates` will return null or a `Coordinates` object with coordinates data. It will never return `Coordinates` without data. * Changed: `Location::getBounds` will return null or a `Bounds` object with coordinates data. It will never return `Bounds` without data. * Removed: `AdminLevel::toString` in favor for `AdminLevel::__toString`. @@ -14,6 +12,8 @@ CHANGELOG * Removed: `Address::getCountryCode` in favor for `Address::getCountry()->getCode()`. * Removed: `Address::getLongitude` in favor for `Address::getCoordinates()->getLongitude()`. * Removed: `Address::getLatitude` in favor for `Address::getCoordinates()->getLatitude()`. +* Removed: `Bounds::isDefined` as it is always defined. + ### 3.3.0 (2015-12-06)