/** * @param $latitude * @param $longitude * @return \Niborb\PostcodeAPI\Address * @throws \LogicException */ public function getAddressByLatitudeAndLongitude($latitude, $longitude) { $response = $this->client->wgs84($latitude, $longitude); if (!$response instanceof Response) { throw new \LogicException('Client::wsg84 should return instanceof Response'); } return $this->getAddressFromResponse($response); }
function it_should_return_address_information_by_latitude_and_longitude(Response $response, Address $address) { $latitude = 51.5664; $longitude = 5.07718; $address->getStreet()->willReturn('Wilhelminapark'); $address->getPostcode()->willReturn('5041EB'); $address->getTown()->willReturn('Tilburg'); $address->getLatitude()->willReturn($latitude); $address->getLongitude()->willReturn($longitude); $address->getXPos()->willReturn(133504); $address->getYPos()->willReturn(397543); $response->getAddress()->willReturn($address); $this->client->wgs84($latitude, $longitude)->willReturn($response); /** @var Address $address */ $this->getAddressByLatitudeAndLongitude($latitude, $longitude)->shouldReturn($address); }